Index: libcxx/trunk/cmake/Modules/HandleCompilerRT.cmake =================================================================== --- libcxx/trunk/cmake/Modules/HandleCompilerRT.cmake +++ libcxx/trunk/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 Index: libcxx/trunk/cmake/config-ix.cmake =================================================================== --- libcxx/trunk/cmake/config-ix.cmake +++ libcxx/trunk/cmake/config-ix.cmake @@ -31,7 +31,9 @@ list(APPEND CMAKE_REQUIRED_LIBRARIES c) endif () if (LIBCXX_USE_COMPILER_RT) - list(APPEND CMAKE_REQUIRED_LIBRARIES -rtlib=compiler-rt) + list(APPEND CMAKE_REQUIRED_FLAGS -rtlib=compiler-rt) + find_compiler_rt_library(builtins LIBCXX_BUILTINS_LIBRARY) + list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBCXX_BUILTINS_LIBRARY}") elseif (LIBCXX_HAS_GCC_S_LIB) list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s) endif () Index: libcxx/trunk/lib/CMakeLists.txt =================================================================== --- libcxx/trunk/lib/CMakeLists.txt +++ libcxx/trunk/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.