@@ -51,7 +51,7 @@ endfunction()
51
51
# This calls cache_compiler_rt_library that caches the path to speed up
52
52
# repeated invocations with the same `name` and `target`.
53
53
function (find_compiler_rt_library name variable )
54
- cmake_parse_arguments (ARG "" "TARGET;FLAGS" "" ${ARGN} )
54
+ cmake_parse_arguments (ARG "SHARED " "TARGET;FLAGS" "" ${ARGN} )
55
55
# While we can use compiler-rt runtimes with other compilers, we need to
56
56
# query the compiler for runtime location and thus we require Clang.
57
57
if (NOT CMAKE_CXX_COMPILER_ID MATCHES Clang)
@@ -112,12 +112,16 @@ function(find_compiler_rt_library name variable)
112
112
# path and then checking if the resultant path exists. The result of
113
113
# this check is also cached by cache_compiler_rt_library.
114
114
set (library_file "${COMPILER_RT_LIBRARY_builtins_${target} }" )
115
- if (library_file MATCHES ".*clang_rt\. ([a-z0-9_\- ]+)\. (a|lib)" )
116
- set (from_name ${CMAKE_MATCH_0} )
117
- get_component_name(${name} to_name)
118
- string (REPLACE "${from_name} " "${to_name} " library_file "${library_file} " )
119
- cache_compiler_rt_library(FALSE "${name} " "${target} " "${library_file} " )
115
+ get_component_name("builtins" from_name)
116
+ get_component_name(${name} to_name)
117
+ get_filename_component (basename ${library_file} NAME )
118
+ string (REPLACE "${from_name} " "${to_name} " basename "${basename} " )
119
+ if (ARG_SHARED)
120
+ string (REGEX REPLACE "\. (a|lib)$" ".so" basename "${basename} " )
120
121
endif ()
122
+ get_filename_component (dirname ${library_file} DIRECTORY )
123
+ set (library_file "${dirname} /${basename} " )
124
+ cache_compiler_rt_library(FALSE "${name} " "${target} " "${library_file} " )
121
125
endif ()
122
126
set (${variable} "${COMPILER_RT_LIBRARY_${name} _${target} }" PARENT_SCOPE)
123
127
endfunction ()
0 commit comments