public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Fangrui Song <maskray@google.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH 03/11] Rewrite find_cxx_header config configure.ac
Date: Mon, 31 Oct 2022 16:30:12 -0300	[thread overview]
Message-ID: <f765db39-e888-3d22-b4b1-64154990eb9c@linaro.org> (raw)
In-Reply-To: <20221029040351.na7thddiyzrem6ud@google.com>



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 <stdin>, the first non-main-file dependency is not listed
> in the -MP output.
> 
>     echo "#include <cstdlib>" | 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
>>

  reply	other threads:[~2022-10-31 19:30 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-28 17:35 [PATCH 00/11] Initial fixes for clang build support Adhemerval Zanella
2022-10-28 17:35 ` [PATCH 01/11] stdlib/longlong.h: Remove incorrect lvalue to rvalue conversion from asm output constraints Adhemerval Zanella
2022-10-28 21:05   ` Joseph Myers
2022-10-28 21:32     ` Fangrui Song
2022-10-31 18:32       ` Adhemerval Zanella Netto
2022-11-01 13:56         ` Adhemerval Zanella Netto
2022-11-01 14:18           ` Joseph Myers
2022-11-01 17:05             ` Adhemerval Zanella Netto
2022-11-02 15:14               ` Cristian Rodríguez
2022-11-02 17:10                 ` Adhemerval Zanella Netto
2022-11-02 19:43                   ` Cristian Rodríguez
2022-11-03 12:17                     ` Adhemerval Zanella Netto
2022-11-01 17:11   ` Andrew Pinski
2022-11-06 19:30     ` Fangrui Song
2022-11-06 19:32     ` Fangrui Song
2022-11-07 13:39       ` Adhemerval Zanella Netto
2022-10-28 17:35 ` [PATCH 02/11] Disable __USE_EXTERN_INLINES for clang Adhemerval Zanella
2022-10-28 21:06   ` Joseph Myers
2022-10-28 22:02     ` Fangrui Song
2022-10-31 18:33       ` Adhemerval Zanella Netto
2022-10-28 17:35 ` [PATCH 03/11] Rewrite find_cxx_header config configure.ac Adhemerval Zanella
2022-10-29  4:03   ` Fangrui Song
2022-10-31 19:30     ` Adhemerval Zanella Netto [this message]
2022-10-28 17:35 ` [PATCH 04/11] linux: Move hidden_proto before static inline usage on not-cancel.h Adhemerval Zanella
2022-10-29  4:23   ` Fangrui Song
2022-10-31 19:48     ` Adhemerval Zanella Netto
2022-10-28 17:35 ` [PATCH 05/11] intl: Fix clang -Wunused-but-set-variable on plural.c Adhemerval Zanella
2022-10-29  0:44   ` Fangrui Song
2022-10-31 19:54     ` Adhemerval Zanella Netto
2022-10-28 17:35 ` [PATCH 06/11] Disable use of -fsignaling-nans if compiler does not support it Adhemerval Zanella
2022-10-29  4:19   ` Fangrui Song
2022-10-31 20:01     ` Fangrui Song
2022-10-28 17:35 ` [PATCH 07/11] stdlib: Move attribute_hidden definition to function prototype at gmp.h Adhemerval Zanella
2022-10-29  4:37   ` Fangrui Song
2022-10-31 19:55     ` Adhemerval Zanella Netto
2022-10-28 17:35 ` [PATCH 08/11] configure: Use -Wno-ignored-attributes if compiler warns about multiple aliases Adhemerval Zanella
2022-10-29  5:59   ` Fangrui Song
2022-10-31 19:59     ` Adhemerval Zanella Netto
2022-10-31 20:11       ` Fangrui Song
2022-10-28 17:35 ` [PATCH 09/11] alloc_buffer: Apply asm redirection before first use Adhemerval Zanella
2022-10-29  0:32   ` Fangrui Song
2022-10-31 20:01     ` Adhemerval Zanella Netto
2022-10-28 17:35 ` [PATCH 10/11] allocate_once: " Adhemerval Zanella
2022-10-29  0:34   ` Fangrui Song
2022-10-28 17:35 ` [PATCH 11/11] nptl: Fix pthread_create.c build with clang Adhemerval Zanella
2022-10-29  4:51   ` Fangrui Song
2022-10-31 20:03     ` Adhemerval Zanella Netto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f765db39-e888-3d22-b4b1-64154990eb9c@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    --cc=maskray@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).