]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Rewrite find_cxx_header config configure.ac
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 2 Nov 2022 14:55:57 +0000 (11:55 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 7 Nov 2022 13:40:17 +0000 (10:40 -0300)
With clang if the main file is <stdin>, the first non-main-file
dependency is not listed in the -MP output.  Although it was fixed
on clang-16 [1], this change adds portability for older version.

[1] https://github.com/llvm/llvm-project/commit/ff9576f74514b836e1ba0268409a2ecb919d7118

Reviewed-by: Fangrui Song <maskray@google.com>
configure
configure.ac

index fc3d7842de7e59560760a447df38e530ee58829a..cb0996d59e2139e67952e253f4a2d5999d9b0c67 100755 (executable)
--- a/configure
+++ b/configure
@@ -5669,8 +5669,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 \
+        | $AWK '$1 == "."{print $2}'
   }
   CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
   CXX_CMATH_HEADER="$(find_cxx_header cmath)"
index 9fc1fb1c1c9a6f71adb52cd23a6c1c99ac84668d..20b5e8043fad17bef6fe0d0accc0c4872dbb27f2 100644 (file)
@@ -1137,8 +1137,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 \
+        | $AWK '$1 == "."{print $2}'
   }
   CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
   CXX_CMATH_HEADER="$(find_cxx_header cmath)"