[compiler-rt] r333037 - [CMake] Support builtins as Clang default rtlib in compiler-rt
Petr Hosek via llvm-commits
llvm-commits at lists.llvm.org
Tue May 22 15:58:48 PDT 2018
Author: phosek
Date: Tue May 22 15:58:48 2018
New Revision: 333037
URL: http://llvm.org/viewvc/llvm-project?rev=333037&view=rev
Log:
[CMake] Support builtins as Clang default rtlib in compiler-rt
Use compiler-rt builtins when selected as default Clang rtlib and avoid
explicitly passing -rtlib= flag to avoid the "argument unused during
compilation" warning.
This is a partial alternative to D47094 that does not rely on compiler
runtime checks.
Differential Revision: https://reviews.llvm.org/D47115
Modified:
compiler-rt/trunk/CMakeLists.txt
compiler-rt/trunk/cmake/config-ix.cmake
Modified: compiler-rt/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/CMakeLists.txt?rev=333037&r1=333036&r2=333037&view=diff
==============================================================================
--- compiler-rt/trunk/CMakeLists.txt (original)
+++ compiler-rt/trunk/CMakeLists.txt Tue May 22 15:58:48 2018
@@ -152,9 +152,19 @@ else()
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 @@ append_list_if(COMPILER_RT_HAS_WD4800_FL
# 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)
Modified: compiler-rt/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/config-ix.cmake?rev=333037&r1=333036&r2=333037&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/config-ix.cmake (original)
+++ compiler-rt/trunk/cmake/config-ix.cmake Tue May 22 15:58:48 2018
@@ -13,7 +13,10 @@ function(check_linker_flag flag out_var)
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_NODEFAULTLIBS_FLAG)
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)
More information about the llvm-commits
mailing list