| Link libcxx with gcc_eh when linking with gcc_s is |
| not desired. Normally, llvm's libunwind would be used but |
| we are not using libunwind in ChromeOS right now because of |
| some reported crashes when libunwind was used. |
| https://crbug.com/747113 |
| |
| diff --git a/libcxx/cmake/config-ix.cmake b/libcxx/cmake/config-ix.cmake |
| index 23ae71025e5..6820970c616 100644 |
| --- a/libcxx/cmake/config-ix.cmake |
| +++ b/libcxx/cmake/config-ix.cmake |
| @@ -27,7 +27,7 @@ endif() |
| # configuration checks to avoid spurious link errors. |
| check_c_compiler_flag(-nodefaultlibs LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG) |
| if (LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG) |
| - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs") |
| + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++") |
| if (LIBCXX_HAS_C_LIB) |
| list(APPEND CMAKE_REQUIRED_LIBRARIES c) |
| endif () |
| diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt |
| index 4f6e2b4aa62..0706cc46182 100644 |
| --- a/libcxx/src/CMakeLists.txt |
| +++ b/libcxx/src/CMakeLists.txt |
| @@ -136,7 +136,7 @@ if (APPLE AND LLVM_USE_SANITIZER) |
| endif() |
| |
| function(cxx_link_system_libraries target) |
| - target_add_link_flags_if_supported(${target} PRIVATE "-nodefaultlibs") |
| + target_add_link_flags_if_supported(${target} PRIVATE "-nostdlib++") |
| target_add_compile_flags_if_supported(${target} PRIVATE "/Zl") |
| target_add_link_flags_if_supported(${target} PRIVATE "/nodefaultlib") |
| |
| @@ -161,10 +161,7 @@ function(cxx_link_system_libraries target) |
| endif() |
| |
| if (LIBCXX_USE_COMPILER_RT) |
| - find_compiler_rt_library(builtins LIBCXX_BUILTINS_LIBRARY) |
| - if (LIBCXX_BUILTINS_LIBRARY) |
| - target_link_libraries(${target} PUBLIC "${LIBCXX_BUILTINS_LIBRARY}") |
| - endif() |
| + add_link_flags("-rtlib=compiler-rt") |
| elseif (LIBCXX_HAS_GCC_S_LIB) |
| target_link_libraries(${target} PUBLIC gcc_s) |
| endif() |
| @@ -255,6 +256,8 @@ if (LIBCXX_ENABLE_SHARED) |
| target_link_libraries(cxx_shared PRIVATE unwind) |
| list(APPEND LIBCXX_INTERFACE_LIBRARIES unwind) # For the linker script |
| endif() |
| + elseif (NOT LIBCXX_HAS_GCC_S_LIB) |
| + add_library_flags(gcc_eh) |
| endif() |
| |
| # Link against libc++abi |