Index: compiler-rt/trunk/CMakeLists.txt =================================================================== --- compiler-rt/trunk/CMakeLists.txt +++ compiler-rt/trunk/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) Index: compiler-rt/trunk/cmake/config-ix.cmake =================================================================== --- compiler-rt/trunk/cmake/config-ix.cmake +++ compiler-rt/trunk/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)