summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorTobias Hieta <tobias@hieta.se>2022-03-01 08:22:53 +0100
committerTobias Hieta <tobias@hieta.se>2022-03-14 07:49:29 +0100
commit45ab1904b34458a55dee471c39df8ea91b43bd52 (patch)
treea927a039f970431e7d3e5a3d2ca448923f571d93 /cmake
parentc572c6ae5627837084389894c5614aed8a889167 (diff)
downloadllvm-45ab1904b34458a55dee471c39df8ea91b43bd52.tar.gz
Correctly find builtins library with clang-cl
When using COMPILER_RT_USE_BUILTINS_LIBRARY=ON and clang-cl there where several places where it didn't work as expected. First -print-libgcc-file-name has to be prefixed with /clang: Then the regex that matched the builtins library was wrong because the builtins library is called clang_rt.builtins_<arch>.lib and the regex only matched libclang_rt.builtins_arch.a With this commit you can use a runtime build on Windows with this option enabled. Reviewed By: phosek Differential Revision: https://reviews.llvm.org/D120698
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Modules/HandleCompilerRT.cmake10
1 files changed, 7 insertions, 3 deletions
diff --git a/cmake/Modules/HandleCompilerRT.cmake b/cmake/Modules/HandleCompilerRT.cmake
index 178e4e5d0b66..51409d6f97f2 100644
--- a/cmake/Modules/HandleCompilerRT.cmake
+++ b/cmake/Modules/HandleCompilerRT.cmake
@@ -54,8 +54,12 @@ function(find_compiler_rt_library name variable)
get_property(cxx_flags CACHE CMAKE_CXX_FLAGS PROPERTY VALUE)
string(REPLACE " " ";" cxx_flags "${cxx_flags}")
list(APPEND clang_command ${cxx_flags})
+ set(cmd_prefix "")
+ if(MSVC AND ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
+ set(cmd_prefix "/clang:")
+ endif()
execute_process(
- COMMAND ${clang_command} "--rtlib=compiler-rt" "-print-libgcc-file-name"
+ COMMAND ${clang_command} "${cmd_prefix}--rtlib=compiler-rt" "${cmd_prefix}-print-libgcc-file-name"
RESULT_VARIABLE had_error
OUTPUT_VARIABLE library_file
)
@@ -72,7 +76,7 @@ function(find_compiler_rt_library name variable)
set(dirname "${resource_dir}/lib/darwin")
endif()
get_filename_component(basename ${library_file} NAME)
- if(basename MATCHES "libclang_rt\.([a-z0-9_\-]+)\.a")
+ if(basename MATCHES ".*clang_rt\.([a-z0-9_\-]+)\.(a|lib)")
set(from_name ${CMAKE_MATCH_1})
get_component_name(${CMAKE_MATCH_1} to_name)
string(REPLACE "${from_name}" "${to_name}" basename "${basename}")
@@ -90,7 +94,7 @@ function(find_compiler_rt_library name variable)
# path and then checking if the resultant path exists. The result of
# this check is also cached by cache_compiler_rt_library.
set(library_file "${COMPILER_RT_LIBRARY_builtins_${target}}")
- if(library_file MATCHES ".*libclang_rt\.([a-z0-9_\-]+)\.a")
+ if(library_file MATCHES ".*clang_rt\.([a-z0-9_\-]+)\.(a|lib)")
set(from_name ${CMAKE_MATCH_0})
get_component_name(${name} to_name)
string(REPLACE "${from_name}" "${to_name}" library_file "${library_file}")