Index: compiler-rt/CMakeLists.txt =================================================================== --- compiler-rt/CMakeLists.txt +++ compiler-rt/CMakeLists.txt @@ -89,12 +89,12 @@ endif() construct_compiler_rt_default_triple() -if ("${COMPILER_RT_DEFAULT_TARGET_ABI}" MATCHES "hf$") +if ("${COMPILER_RT_DEFAULT_TARGET_TRIPLE}" MATCHES ".*hf$") if (${COMPILER_RT_DEFAULT_TARGET_ARCH} MATCHES "^arm") set(COMPILER_RT_DEFAULT_TARGET_ARCH "armhf") endif() endif() -if ("${COMPILER_RT_DEFAULT_TARGET_ABI}" MATCHES "^android") +if ("${COMPILER_RT_DEFAULT_TARGET_TRIPLE}" MATCHES ".*android.*") set(ANDROID 1) endif() pythonize_bool(ANDROID) Index: compiler-rt/cmake/Modules/CompilerRTUtils.cmake =================================================================== --- compiler-rt/cmake/Modules/CompilerRTUtils.cmake +++ compiler-rt/cmake/Modules/CompilerRTUtils.cmake @@ -88,6 +88,26 @@ set(${input_list} "${replaced_list}" PARENT_SCOPE) endfunction() +# TODO: CMake 3.12 has list(SUBLIST ...) which implements the same +# interface, so once LLVM moves past that version as the minimum +# requirement, this can be replaced with the builtin one. +function(list_sublist list begin length variable) + set(sublist) + list(LENGTH ${list} list_length) + if(NOT ${length} EQUAL -1) + math(EXPR end "${begin}+${length}") + else() + math(EXPR end "${list_length}-1") + endif() + foreach(index RANGE ${begin} ${end}) + if(index LESS list_length) + list(GET ${list} ${index} component) + list(APPEND sublist ${component}) + endif() + endforeach() + set(${variable} "${sublist}" PARENT_SCOPE) +endfunction() + # Takes ${ARGN} and puts only supported architectures in @out_var list. function(filter_available_targets out_var) set(archs ${${out_var}}) @@ -276,11 +296,6 @@ string(REPLACE "-" ";" TARGET_TRIPLE_LIST ${COMPILER_RT_DEFAULT_TARGET_TRIPLE}) list(GET TARGET_TRIPLE_LIST 0 COMPILER_RT_DEFAULT_TARGET_ARCH) - list(GET TARGET_TRIPLE_LIST 1 COMPILER_RT_DEFAULT_TARGET_OS) - list(LENGTH TARGET_TRIPLE_LIST TARGET_TRIPLE_LIST_LENGTH) - if(TARGET_TRIPLE_LIST_LENGTH GREATER 2) - list(GET TARGET_TRIPLE_LIST 2 COMPILER_RT_DEFAULT_TARGET_ABI) - endif() # Determine if test target triple is specified explicitly, and doesn't match the # default. if(NOT COMPILER_RT_DEFAULT_TARGET_TRIPLE STREQUAL TARGET_TRIPLE) @@ -320,13 +335,14 @@ endfunction() function(get_compiler_rt_target arch variable) + string(REPLACE "-" ";" triple_list ${COMPILER_RT_DEFAULT_TARGET_TRIPLE}) + list_sublist(triple_list 1 -1 triple_sublist) + string(REPLACE ";" "-" os_abi "${triple_sublist}") + if(ANDROID AND ${arch} STREQUAL "i386") - set(target "i686${COMPILER_RT_OS_SUFFIX}-${COMPILER_RT_DEFAULT_TARGET_OS}") + set(target "i686${COMPILER_RT_OS_SUFFIX}-${os_abi}") else() - set(target "${arch}-${COMPILER_RT_DEFAULT_TARGET_OS}") - endif() - if(COMPILER_RT_DEFAULT_TARGET_ABI) - set(target "${target}-${COMPILER_RT_DEFAULT_TARGET_ABI}") + set(target "${arch}-${os_abi}") endif() set(${variable} ${target} PARENT_SCOPE) endfunction()