From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 28AD83858C2C for ; Sat, 29 Oct 2022 04:03:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 28AD83858C2C Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=google.com Received: by mail-pf1-x436.google.com with SMTP id g62so6347210pfb.10 for ; Fri, 28 Oct 2022 21:03:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=V9LI+4ybT5DWr2EYwjH7SjNqziY9lEKEIrravTMF1vo=; b=N7qKsUxz2VC+y6xtXclHYn5qah3Uv1XOdX9vhCQfL5wyxZCQHcOQg8DzSErKm1wbe2 fslIsL1xUTsjWvAuNtRhYgLFiKbCXgj73BzSalYLN9usWpUke4ssaZCf/s8Osh/mpvn2 eWremVMI1k6yU/BiRMP28qstWsS0RqPS4XUPyArfc5et2hT1ITQJKE8uR45thJA8cMCg XF4Iyd8Ie2X4YBB0qWySgCcnkEMjhv/REZG535+ZVyFGtMcqy+dMIl1cCjVw1Msy9LWg NbJeJHRrurCSpFzsNEoXAnZvZfyMrJVEd3EiWB/iehSesop3bXKeJp3xEtWmGhqHv+zC ajAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=V9LI+4ybT5DWr2EYwjH7SjNqziY9lEKEIrravTMF1vo=; b=dXoY0XsznwGtoW0OAxVDi1lgg8bB998Zpp94+vnPjbjPtZuwAU+KfR/sro6++L8EMG r9sqZk73ZDzw3kfF8fJt1OXuzB97vDz/+GoY6UcIZT21tE0KDX01sMlwNkQzx2gAqo4t u7pOwBF4aJ/LfpGrRqhUS6IskdLYrllVCEPfSjuPPctGYd5RplGWsDk3eHl90/K2rTLc PBNfGcIaPgCve94pIuPF2XdVUMlI3MwnyXihyCfe8oshiyV84MVyh3Frw7k0my+BbV1Q KE/5ZmDKo/Yati0ea5JZUZpChdo86LGIXrcxDNimXCctO7sODXWs54m7CzDcYHiFGYyr zIdQ== X-Gm-Message-State: ACrzQf1ZL/0u++RFpMTwF1FFJ7r2IaHJTdRcBH8KvoZoYIA9xo9ChdMw axnd6azODEgMsSGeLR06gohLtLL2qNn13Q== X-Google-Smtp-Source: AMsMyM4taZjQgtXxKq+eS7d+7YmEWQWmx8WJOOmbEIvXwImevtmpf7dPNEEg93SK/7IJ+o/RuOR8tw== X-Received: by 2002:a05:6a00:d72:b0:56c:3c45:6953 with SMTP id n50-20020a056a000d7200b0056c3c456953mr2817640pfv.54.1667016236075; Fri, 28 Oct 2022 21:03:56 -0700 (PDT) Received: from google.com ([2620:15c:2ce:200:8981:f21e:b257:256]) by smtp.gmail.com with ESMTPSA id j4-20020a170902690400b00186ffe62502sm220961plk.254.2022.10.28.21.03.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 21:03:54 -0700 (PDT) Date: Fri, 28 Oct 2022 21:03:51 -0700 From: Fangrui Song To: Adhemerval Zanella Cc: libc-alpha@sourceware.org Subject: Re: [PATCH 03/11] Rewrite find_cxx_header config configure.ac Message-ID: <20221029040351.na7thddiyzrem6ud@google.com> References: <20221028173532.876027-1-adhemerval.zanella@linaro.org> <20221028173532.876027-4-adhemerval.zanella@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20221028173532.876027-4-adhemerval.zanella@linaro.org> X-Spam-Status: No, score=-26.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,ENV_AND_HDR_SPF_MATCH,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 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. >--- > 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}' > } > 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 >