From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by sourceware.org (Postfix) with ESMTPS id 284963857686 for ; Mon, 31 Oct 2022 19:30:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 284963857686 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oi1-x22d.google.com with SMTP id r76so7269800oie.13 for ; Mon, 31 Oct 2022 12:30:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=0Y48ZeMAIuF4zpCaxYAAGHKsHr9w2qCsYS9Fllw7uDQ=; b=UlqRlvTzEvpzAeo788H34xrdpFI4AtdQzeS5fLkF7nq1tyQqZCp2myqhP3rR2NqQ9X 5z2QxlmJLZ0Px6OtuCGnf6zl5ng/prYUH/AswG4uM03DLbIQJ518qBmOGgYowu3J6oV+ VvAOBX7AGe6SoOyLskyoDTiUrf9ucGyUgXZHOeHsRDS24r2j4akxKZUw7CahjYo3TgpQ IkVr911uk623l3xQhI2AIVjl1v8hnzTr71RMHeKEdx/9l790otIZOsO4aDemBIPKBp0B 7cVCdGlVrcVcFb+1ixM0imTkGQhRJ1jfnfGeZUb8D2F4BdMTKAQOLNb+9BLz9l30clCL 1EjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0Y48ZeMAIuF4zpCaxYAAGHKsHr9w2qCsYS9Fllw7uDQ=; b=LNPOgI0Lf3j9/i1EmYYenPrjWdhdaFyeuK8eNZIqYIq3BNkKa6LFNGvrKVN3u5wmjT xSclJvNj2lheNLav1excxjcmKOlbtL+3uZhs537MJomAOOJRmhmtY86hQCqlClSbLw4b fmvLsqkN3yn32fcwrDbguVHM02CYrqogTRMVKT89ovHejLaQN/s/gVxiil8evnq5+zPy Kmd9PHwm1KSWPr+BqA0nkcGXlNAfmsOpTpfishmD7waZBeLSfAEbeXw87PHqNZxcM8FP SOvyt/VCAallcp1fosaEFZzzeypcXtHS8Qc4KEmulP60sSLzxmlSws+WNWxsZplBobRk 0Slg== X-Gm-Message-State: ACrzQf3Cpd9PmcBFjMMoIbqLRQNR9BhR31gnnIN+XHEbD8cHeT/Td/PW bo+vih61brHjn/XCvqApm5ng9/mF/v291kIq X-Google-Smtp-Source: AMsMyM5mh+PL3Cw+zZbmuOK5R2Q/oaYv1LNxli000C+aQd036qom66TmAE3NNvSSCG/gVVt/2wwIFg== X-Received: by 2002:a05:6808:118c:b0:34f:9fc9:ce15 with SMTP id j12-20020a056808118c00b0034f9fc9ce15mr15734801oil.220.1667244615418; Mon, 31 Oct 2022 12:30:15 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c0:17c8:29c8:c66:a795:b2b1? ([2804:1b3:a7c0:17c8:29c8:c66:a795:b2b1]) by smtp.gmail.com with ESMTPSA id w25-20020a9d6399000000b0066c39c99ae5sm3120090otk.25.2022.10.31.12.30.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 31 Oct 2022 12:30:15 -0700 (PDT) Message-ID: Date: Mon, 31 Oct 2022 16:30:12 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH 03/11] Rewrite find_cxx_header config configure.ac Content-Language: en-US To: Fangrui Song Cc: libc-alpha@sourceware.org References: <20221028173532.876027-1-adhemerval.zanella@linaro.org> <20221028173532.876027-4-adhemerval.zanella@linaro.org> <20221029040351.na7thddiyzrem6ud@google.com> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <20221029040351.na7thddiyzrem6ud@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 29/10/22 01:03, Fangrui Song wrote: > On 2022-10-28, Adhemerval Zanella via Libc-alpha wrote: >> clang does not support -MP option to create phony target for each >> dependency other than the main file.  Use -fsyntax-only with a >> more comprensible regex to get the the cxx header. > > Clang has supported -MP for many years. > The problem was that when the main file is , the first non-main-file dependency is not listed > in the -MP output. > >     echo "#include " | fclang++ -M -MP -x c++ - 2>/dev/null | sed -n "\,cstdlib:,{s/:\$//;p}" > > I just fixed this in https://github.com/llvm/llvm-project/commit/ff9576f74514b836e1ba0268409a2ecb919d7118 > which shall be included in Clang 16. You are right, I did not write down my finding and I have to hasty (and wrongly) described the patch. > > > >> --- >> configure    | 4 ++-- >> configure.ac | 4 ++-- >> 2 files changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/configure b/configure >> index ff2c406b3b..26bd8200dd 100755 >> --- a/configure >> +++ b/configure >> @@ -5579,8 +5579,8 @@ fi >> # copy of those headers in Makerules. >> if test -n "$CXX"; then >>   find_cxx_header () { >> -    echo "#include <$1>" | $CXX -M -MP -x c++ - 2>/dev/null \ >> -     | sed -n "\,$1:,{s/:\$//;p}" >> +    echo "#include <$1>" | $CXX -H -fsyntax-only -x c++ - 2>&1 \ >> +     | sed -rn "\,^\.? .,{s/^\.*\. //p}" > > That said, the patch looks good to support more Clang versions. > > For portability, prefer -E to -r and add `;` before `}` (FreeBSD sed doesn't allow `p}`). > > Actually no ERE is needed and   sed -n "\,^\. .,{s/^\. //;p;}"  should work. > Alternatively, use      awk '$1 == "."{print $2}' The awk does seems to be simpler solution indeed. > >>   } >>   CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)" >>   CXX_CMATH_HEADER="$(find_cxx_header cmath)" >> diff --git a/configure.ac b/configure.ac >> index eb5bc6a131..a009e7a17f 100644 >> --- a/configure.ac >> +++ b/configure.ac >> @@ -1136,8 +1136,8 @@ AC_SUBST(CXX_SYSINCLUDES) >> # copy of those headers in Makerules. >> if test -n "$CXX"; then >>   find_cxx_header () { >> -    echo "#include <$1>" | $CXX -M -MP -x c++ - 2>/dev/null \ >> -     | sed -n "\,$1:,{s/:\$//;p}" >> +    echo "#include <$1>" | $CXX -H -fsyntax-only -x c++ - 2>&1 \ >> +     | sed -rn "\,^\.? .,{s/[^\.]*\. //p}" >>   } >>   CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)" >>   CXX_CMATH_HEADER="$(find_cxx_header cmath)" >> --  >> 2.34.1 >>