From 1b0b8ef4e04b7430a3cdf9e39a03f3200a01df06 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 14 Jul 2024 00:53:57 +0200 Subject: [PATCH] stdlib: Support use of clang++ on Ubuntu. * lib/stdlib.in.h: Ignore __need_system_stdlib_h when GCC's c++/11/stdlib.h is being included or has been included. --- ChangeLog | 6 ++++++ lib/stdlib.in.h | 13 +++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e43d26a02b..c7af30b4c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-07-13 Bruno Haible + + stdlib: Support use of clang++ on Ubuntu. + * lib/stdlib.in.h: Ignore __need_system_stdlib_h when GCC's + c++/11/stdlib.h is being included or has been included. + 2024-07-10 Pip Cet timespec-sub: Fix compilation error on clang. diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index cfc69d0a50..47a8856dc7 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -20,9 +20,18 @@ #endif @PRAGMA_COLUMNS@ -#if defined __need_system_stdlib_h || defined __need_malloc_and_calloc +#if (defined __need_system_stdlib_h && !defined _GLIBCXX_STDLIB_H) || defined __need_malloc_and_calloc /* Special invocation conventions inside some gnulib header files, - and inside some glibc header files, respectively. */ + and inside some glibc header files, respectively. + Do not recognize this special invocation convention when GCC's + c++/11/stdlib.h is being included or has been included. This is needed + to support the use of clang+llvm binaries on Ubuntu 22.04 with + CXX="$clangdir/bin/clang++ -I/usr/include/c++/11 \ + -I/usr/include/x86_64-linux-gnu/c++/11 + -L/usr/lib/gcc/x86_64-linux-gnu/11 + -Wl,-rpath,$clangdir/lib" + because in this case /usr/include/c++/11/stdlib.h (which does not support + the convention) is seen before the gnulib-generated stdlib.h. */ #@INCLUDE_NEXT@ @NEXT_STDLIB_H@ -- 2.39.5