[PATCH] D31617: [CMake][libcxx] Use builtins rather than gcc_s when compiler-rt is requested
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 3 12:34:36 PDT 2017
phosek created this revision.
Herald added subscribers: mgorny, dberris.
When compiler-rt is requested, we should attempt to link compiler-rt builtins library rather than gcc_s.
Repository:
rL LLVM
https://reviews.llvm.org/D31617
Files:
cmake/Modules/HandleCompilerRT.cmake
lib/CMakeLists.txt
Index: lib/CMakeLists.txt
===================================================================
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -83,7 +83,12 @@
add_library_flags_if(LIBCXX_HAS_C_LIB c)
add_library_flags_if(LIBCXX_HAS_M_LIB m)
add_library_flags_if(LIBCXX_HAS_RT_LIB rt)
-add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+if (LIBCXX_USE_COMPILER_RT)
+ find_compiler_rt_library(builtins LIBCXX_BUILTINS_LIBRARY)
+ add_library_flags_if(LIBCXX_BUILTINS_LIBRARY "${LIBCXX_BUILTINS_LIBRARY}")
+else()
+ add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+endif()
add_library_flags_if(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB atomic)
# Add the unwinder library.
Index: cmake/Modules/HandleCompilerRT.cmake
===================================================================
--- cmake/Modules/HandleCompilerRT.cmake
+++ cmake/Modules/HandleCompilerRT.cmake
@@ -3,8 +3,11 @@
message(FATAL_ERROR "LIBCXX_COMPILE_FLAGS must be defined when using this function")
endif()
set(dest "" PARENT_SCOPE)
- set(CLANG_COMMAND ${CMAKE_CXX_COMPILER} ${LIBCXX_COMPILE_FLAGS}
+ set(CLANG_COMMAND ${CMAKE_CXX_COMPILER} ${TARGET_TRIPLE} ${LIBCXX_COMPILE_FLAGS}
"--rtlib=compiler-rt" "--print-libgcc-file-name")
+ if (CMAKE_CXX_COMPILER_ID MATCHES Clang AND CMAKE_CXX_COMPILER_TARGET)
+ list(APPEND CLANG_COMMAND "--target=${CMAKE_CXX_COMPILER_TARGET}")
+ endif()
execute_process(
COMMAND ${CLANG_COMMAND}
RESULT_VARIABLE HAD_ERROR
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31617.93920.patch
Type: text/x-patch
Size: 1460 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170403/1cc90a7f/attachment.bin>
More information about the llvm-commits
mailing list