llvmorg-22-init-4745-gbe179d069664.patch (1689B)
1 From be179d069664ce03c485e49fa1f6e2ca3d6286fa Mon Sep 17 00:00:00 2001 2 From: Mike Hommey <mh@glandium.org> 3 Date: Fri, 22 Aug 2025 14:55:42 +0900 4 Subject: [PATCH] Be explicit about what libstdc++ C++11 ABI to use (#154447) 5 6 libstdc++ can be configured to default to a different C++11 ABI, and 7 when the system that is used to build clang has a different default than 8 the system used to build a clang plugin, that leads to uses of different 9 ABIs, leading to breakage (missing symbols) when using clang APIs that 10 use types like std::string. 11 12 We arbitrarily choose to default to the old ABI, but the user can opt-in 13 to the new ABI. The important part is that whichever is picked is 14 reflected in llvm-config's output. 15 --- 16 llvm/cmake/modules/HandleLLVMOptions.cmake | 18 ++++++++++++++++++ 17 1 file changed, 18 insertions(+) 18 19 diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake 20 index c487f57da346..373b9052c91d 100644 21 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake 22 +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake 23 @@ -175,6 +175,24 @@ if(LLVM_ENABLE_EXPENSIVE_CHECKS) 24 endif() 25 endif() 26 27 +CHECK_CXX_SOURCE_COMPILES(" 28 +#include <iosfwd> 29 +#if !defined(__GLIBCXX__) 30 +#error Not libstdc++ 31 +#endif 32 +int main() { return 0; } 33 +" LLVM_USES_LIBSTDCXX) 34 + 35 +option(GLIBCXX_USE_CXX11_ABI "Use new libstdc++ CXX11 ABI" OFF) 36 + 37 +if (LLVM_USES_LIBSTDCXX) 38 + if (GLIBCXX_USE_CXX11_ABI) 39 + add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=1) 40 + else() 41 + add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0) 42 + endif() 43 +endif() 44 + 45 if (LLVM_ENABLE_STRICT_FIXED_SIZE_VECTORS) 46 add_compile_definitions(STRICT_FIXED_SIZE_VECTORS) 47 endif() 48 -- 49 2.51.0.1.g7a422dac74