Skip to content

Commit be179d0

Browse files
authored
Be explicit about what libstdc++ C++11 ABI to use (#154447)
libstdc++ can be configured to default to a different C++11 ABI, and when the system that is used to build clang has a different default than the system used to build a clang plugin, that leads to uses of different ABIs, leading to breakage (missing symbols) when using clang APIs that use types like std::string. We arbitrarily choose to default to the old ABI, but the user can opt-in to the new ABI. The important part is that whichever is picked is reflected in llvm-config's output.
1 parent dee25a8 commit be179d0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

llvm/cmake/modules/HandleLLVMOptions.cmake

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,24 @@ if(LLVM_ENABLE_EXPENSIVE_CHECKS)
175175
endif()
176176
endif()
177177

178+
CHECK_CXX_SOURCE_COMPILES("
179+
#include <iosfwd>
180+
#if !defined(__GLIBCXX__)
181+
#error Not libstdc++
182+
#endif
183+
int main() { return 0; }
184+
" LLVM_USES_LIBSTDCXX)
185+
186+
option(GLIBCXX_USE_CXX11_ABI "Use new libstdc++ CXX11 ABI" OFF)
187+
188+
if (LLVM_USES_LIBSTDCXX)
189+
if (GLIBCXX_USE_CXX11_ABI)
190+
add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=1)
191+
else()
192+
add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0)
193+
endif()
194+
endif()
195+
178196
if (LLVM_ENABLE_STRICT_FIXED_SIZE_VECTORS)
179197
add_compile_definitions(STRICT_FIXED_SIZE_VECTORS)
180198
endif()

0 commit comments

Comments
 (0)