[PATCH] D120698: Correctly find builtins library with clang-cl
Tobias Hieta via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 28 23:21:23 PST 2022
thieta created this revision.
Herald added a subscriber: mgorny.
thieta requested review of this revision.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D120698
Files:
cmake/Modules/HandleCompilerRT.cmake
compiler-rt/cmake/Modules/AddCompilerRT.cmake
Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake
===================================================================
--- compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -261,6 +261,7 @@
NOT name STREQUAL "clang_rt.builtins")
get_compiler_rt_target(${arch} target)
find_compiler_rt_library(builtins builtins_${libname} TARGET ${target})
+ message(${builtins_${libname}})
if(builtins_${libname} STREQUAL "NOTFOUND")
message(FATAL_ERROR "Cannot find builtins library for the target architecture")
endif()
Index: cmake/Modules/HandleCompilerRT.cmake
===================================================================
--- cmake/Modules/HandleCompilerRT.cmake
+++ cmake/Modules/HandleCompilerRT.cmake
@@ -54,8 +54,13 @@
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()
+ message(STATUS ${clang_command} "${cmd_prefix}--rtlib=compiler-rt" "${cmd_prefix}-print-libgcc-file-name")
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 +77,7 @@
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 +95,7 @@
# 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}")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120698.411979.patch
Type: text/x-patch
Size: 2470 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220301/c3cc2508/attachment.bin>
More information about the llvm-commits
mailing list