[PATCH] D47115: [CMake] Support builtins as Clang default rtlib in compiler-rt
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 22 14:39:47 PDT 2018
phosek updated this revision to Diff 148103.
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D47115
Files:
compiler-rt/CMakeLists.txt
compiler-rt/cmake/config-ix.cmake
Index: compiler-rt/cmake/config-ix.cmake
===================================================================
--- compiler-rt/cmake/config-ix.cmake
+++ compiler-rt/cmake/config-ix.cmake
@@ -13,7 +13,10 @@
endfunction()
check_library_exists(c fopen "" COMPILER_RT_HAS_LIBC)
-if (NOT SANITIZER_USE_COMPILER_RT)
+if (COMPILER_RT_RUNTIME_LIBRARY STREQUAL "builtins")
+ include(HandleCompilerRT)
+ find_compiler_rt_library(builtins COMPILER_RT_BUILTINS_LIBRARY)
+else()
if (ANDROID)
check_library_exists(gcc __gcc_personality_v0 "" COMPILER_RT_HAS_GCC_LIB)
else()
@@ -27,9 +30,7 @@
if (COMPILER_RT_HAS_LIBC)
list(APPEND CMAKE_REQUIRED_LIBRARIES c)
endif ()
- if (SANITIZER_USE_COMPILER_RT)
- list(APPEND CMAKE_REQUIRED_FLAGS -rtlib=compiler-rt)
- find_compiler_rt_library(builtins COMPILER_RT_BUILTINS_LIBRARY)
+ if (COMPILER_RT_RUNTIME_LIBRARY STREQUAL "builtins")
list(APPEND CMAKE_REQUIRED_LIBRARIES "${COMPILER_RT_BUILTINS_LIBRARY}")
elseif (COMPILER_RT_HAS_GCC_S_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
Index: compiler-rt/CMakeLists.txt
===================================================================
--- compiler-rt/CMakeLists.txt
+++ compiler-rt/CMakeLists.txt
@@ -152,9 +152,19 @@
set(SANITIZER_CXX_ABI_SYSTEM 1)
endif()
-option(SANITIZER_USE_COMPILER_RT "Use compiler-rt builtins instead of libgcc" OFF)
+set(COMPILER_RT_RUNTIME "default" CACHE STRING
+ "Compiler runtime to use.")
+
+if (COMPILER_RT_RUNTIME STREQUAL "default")
+ if (CLANG_DEFAULT_RTLIB STREQUAL "compiler-rt")
+ set(COMPILER_RT_RUNTIME_LIBRARY "builtins")
+ elseif (FUCHSIA)
+ set(COMPILER_RT_RUNTIME_LIBRARY "builtins")
+ endif()
+else()
+ set(COMPILER_RT_RUNTIME_LIBRARY "${COMPILER_RT_RUNTIME}")
+endif()
-include(HandleCompilerRT)
include(config-ix)
#================================
@@ -303,9 +313,7 @@
# Set common link flags.
append_list_if(COMPILER_RT_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs SANITIZER_COMMON_LINK_FLAGS)
-if (SANITIZER_USE_COMPILER_RT)
- list(APPEND SANITIZER_COMMON_LINK_FLAGS -rtlib=compiler-rt)
- find_compiler_rt_library(builtins COMPILER_RT_BUILTINS_LIBRARY)
+if (COMPILER_RT_RUNTIME_LIBRARY STREQUAL "builtins")
list(APPEND SANITIZER_COMMON_LINK_LIBS ${COMPILER_RT_BUILTINS_LIBRARY})
else()
if (ANDROID)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47115.148103.patch
Type: text/x-patch
Size: 2305 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180522/94d24911/attachment.bin>
More information about the llvm-commits
mailing list