diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt --- a/llvm/runtimes/CMakeLists.txt +++ b/llvm/runtimes/CMakeLists.txt @@ -233,6 +233,33 @@ set(EXTRA_ARGS EXCLUDE_FROM_ALL) endif() + function(check_apple_target triple) + set(error "\ +compiler-rt for Darwin builds for all platforms and architectures using a \ +single configuration. Specify only a single darwin triple (e.g. x86_64-apple-darwin) \ +in your targets list (and not a triple for a specific platform such as macos). \ +You can use variables such as COMPILER_RT_ENABLE_IOS and DARWIN_ios_ARCHS to \ +control the specific platforms and architectures to build.") + + string(REPLACE "-" ";" triple_components ${triple}) + foreach(component ${triple_components}) + string(TOLOWER "${component}" component_lower) + if(component_lower MATCHES "^darwin") + get_property(darwin_triple_seen GLOBAL PROPERTY runtimes_darwin_triple_seen) + if(darwin_triple_seen) + message(FATAL_ERROR "${error}") + endif() + set_property(GLOBAL PROPERTY runtimes_darwin_triple_seen YES) + if(NOT RUNTIMES_BUILD_ALLOW_DARWIN) + message(FATAL_ERROR "\ +${error} Set RUNTIMES_BUILD_ALLOW_DARWIN to allow a single darwin triple.") + endif() + elseif(component_lower MATCHES "^ios|^macos|^tvos|^watchos") + message(FATAL_ERROR "${error}") + endif() + endforeach() + endfunction() + function(builtin_default_target compiler_rt_path) cmake_parse_arguments(ARG "" "" "DEPENDS" ${ARGN}) @@ -256,13 +283,7 @@ function(builtin_register_target compiler_rt_path target) cmake_parse_arguments(ARG "" "" "DEPENDS" ${ARGN}) - string(REPLACE "-" ";" builtin_target_list ${target}) - foreach(item ${builtin_target_list}) - string(TOLOWER "${item}" item_lower) - if(item_lower MATCHES "darwin") - message(FATAL_ERROR "LLVM_BUILTIN_TARGETS isn't implemented for Darwin platform!") - endif() - endforeach() + check_apple_target(${target}) get_cmake_property(variableNames VARIABLES) foreach(variableName ${variableNames})