about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-11-02 11:55:57 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-11-07 10:40:17 -0300
commit596183a1eed0699be96bdcd495ab1b497370afda (patch)
treebdf392139f9162cf9bb0c572248d139920d79307
parentd1d0162e50afe7fa1e2fc4a901eb411db48acd7b (diff)
downloadglibc-596183a1eed0699be96bdcd495ab1b497370afda.tar.gz
glibc-596183a1eed0699be96bdcd495ab1b497370afda.tar.xz
glibc-596183a1eed0699be96bdcd495ab1b497370afda.zip
Rewrite find_cxx_header config configure.ac
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>
-rwxr-xr-xconfigure4
-rw-r--r--configure.ac4
2 files changed, 4 insertions, 4 deletions
diff --git a/configure b/configure
index fc3d7842de..cb0996d59e 100755
--- 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)"
diff --git a/configure.ac b/configure.ac
index 9fc1fb1c1c..20b5e8043f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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)"