@@ -51,7 +51,7 @@ endfunction()
5151# This calls cache_compiler_rt_library that caches the path to speed up
5252# repeated invocations with the same `name` and `target`.
5353function (find_compiler_rt_library name variable )
54- cmake_parse_arguments (ARG "" "TARGET;FLAGS" "" ${ARGN} )
54+ cmake_parse_arguments (ARG "SHARED " "TARGET;FLAGS" "" ${ARGN} )
5555 # While we can use compiler-rt runtimes with other compilers, we need to
5656 # query the compiler for runtime location and thus we require Clang.
5757 if (NOT CMAKE_CXX_COMPILER_ID MATCHES Clang)
@@ -112,12 +112,16 @@ function(find_compiler_rt_library name variable)
112112 # path and then checking if the resultant path exists. The result of
113113 # this check is also cached by cache_compiler_rt_library.
114114 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} " )
120121 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} " )
121125 endif ()
122126 set (${variable} "${COMPILER_RT_LIBRARY_${name} _${target} }" PARENT_SCOPE)
123127endfunction ()
0 commit comments