[llvm] 8dac97e - Revert "[CMake] Support runtimes targets without specifying triple"
Petr Hosek via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 5 18:52:15 PST 2023
Author: Petr Hosek
Date: 2023-02-06T02:52:09Z
New Revision: 8dac97efe46b63231775a840b610eee22e62cd8c
URL: https://github.com/llvm/llvm-project/commit/8dac97efe46b63231775a840b610eee22e62cd8c
DIFF: https://github.com/llvm/llvm-project/commit/8dac97efe46b63231775a840b610eee22e62cd8c.diff
LOG: Revert "[CMake] Support runtimes targets without specifying triple"
This reverts commit e6975c4ced27fe93945393603df79557aeb23d83 since it
broke the bootstrapping build on Windows.
Added:
Modified:
llvm/runtimes/CMakeLists.txt
Removed:
################################################################################
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 72c4d0a79de1c..5bb890452c215 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -96,33 +96,36 @@ function(builtin_default_target compiler_rt_path)
${EXTRA_ARGS})
endfunction()
-function(builtin_register_target compiler_rt_path name)
- cmake_parse_arguments(ARG "" "" "DEPENDS;CMAKE_ARGS;EXTRA_ARGS" ${ARGN})
+function(builtin_register_target compiler_rt_path target)
+ cmake_parse_arguments(ARG "" "" "DEPENDS" ${ARGN})
- set(${name}_extra_args ${ARG_CMAKE_ARGS})
- get_cmake_property(variable_names VARIABLES)
- foreach(variable_name ${variable_names})
- string(FIND "${variable_name}" "BUILTINS_${name}" out)
+ check_apple_target(${target} builtin)
+
+ get_cmake_property(variableNames VARIABLES)
+ foreach(variableName ${variableNames})
+ string(FIND "${variableName}" "BUILTINS_${target}" out)
if("${out}" EQUAL 0)
- string(REPLACE "BUILTINS_${name}_" "" new_name ${variable_name})
- string(REPLACE ";" "|" new_value "${${variable_name}}")
- list(APPEND ${name}_extra_args "-D${new_name}=${new_value}")
+ string(REPLACE "BUILTINS_${target}_" "" new_name ${variableName})
+ string(REPLACE ";" "|" new_value "${${variableName}}")
+ list(APPEND ${target}_extra_args "-D${new_name}=${new_value}")
endif()
endforeach()
- llvm_ExternalProject_Add(builtins-${name}
+ llvm_ExternalProject_Add(builtins-${target}
${compiler_rt_path}/lib/builtins
DEPENDS ${ARG_DEPENDS}
CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
-DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
+ -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
-DCMAKE_C_COMPILER_WORKS=ON
-DCMAKE_ASM_COMPILER_WORKS=ON
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
${COMMON_CMAKE_ARGS}
- ${${name}_extra_args}
+ ${${target}_extra_args}
USE_TOOLCHAIN
- ${EXTRA_ARGS} ${ARG_EXTRA_ARGS})
+ TARGET_TRIPLE ${target}
+ ${EXTRA_ARGS})
endfunction()
# If compiler-rt is present we need to build the builtin libraries first. This
@@ -145,12 +148,8 @@ if(compiler_rt_path)
endif()
foreach(target ${LLVM_BUILTIN_TARGETS})
- check_apple_target(${target} builtin)
-
builtin_register_target(${compiler_rt_path} ${target}
- DEPENDS clang-resource-headers
- CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
- EXTRA_ARGS TARGET_TRIPLE ${target})
+ DEPENDS clang-resource-headers)
add_dependencies(builtins builtins-${target})
add_dependencies(install-builtins install-builtins-${target})
@@ -250,13 +249,20 @@ function(runtime_default_target)
${EXTRA_ARGS})
endfunction()
-# runtime_register_target(name)
+# runtime_register_target(target)
# Utility function to register external runtime target.
-function(runtime_register_target name)
- cmake_parse_arguments(ARG "" "" "DEPENDS;CMAKE_ARGS;BASE_NAME;EXTRA_ARGS" ${ARGN})
+function(runtime_register_target name target)
+ cmake_parse_arguments(ARG "" "" "DEPENDS;CMAKE_ARGS" ${ARGN})
include(${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake OPTIONAL)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake)
+ check_apple_target(${target} runtime)
+
+ set(${name}_deps ${ARG_DEPENDS})
+ if(NOT name STREQUAL target)
+ list(APPEND ${name}_deps runtimes-${target})
+ endif()
+
foreach(runtime_name ${runtime_names})
set(${runtime_name}-${name} ${runtime_name})
set(install-${runtime_name}-${name} install-${runtime_name})
@@ -268,15 +274,15 @@ function(runtime_register_target name)
endif()
endforeach()
- foreach(component IN LISTS SUB_COMPONENTS)
- set(${component}-${name} ${component})
- list(APPEND ${name}_extra_targets ${component}-${name})
+ foreach(target_name IN LISTS SUB_COMPONENTS)
+ set(${target_name}-${name} ${target_name})
+ list(APPEND ${name}_extra_targets ${target_name}-${name})
endforeach()
- foreach(target IN LISTS SUB_INSTALL_TARGETS)
- set(${target}-${name} ${target})
- set(${target}-${name}-stripped ${target}-stripped)
- list(APPEND ${name}_extra_targets ${target}-${name} ${target}-${name}-stripped)
+ foreach(target_name IN LISTS SUB_INSTALL_TARGETS)
+ set(${target_name}-${name} ${target_name})
+ set(${target_name}-${name}-stripped ${target_name}-stripped)
+ list(APPEND ${name}_extra_targets ${target_name}-${name} ${target_name}-${name}-stripped)
endforeach()
foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
@@ -302,28 +308,36 @@ function(runtime_register_target name)
endif()
endforeach()
- foreach(target IN LISTS SUB_CHECK_TARGETS component_check_targets)
- set(${target}-${name} ${target})
- list(APPEND ${name}_test_targets ${target}-${name})
- list(APPEND test_targets ${target}-${name})
+ foreach(target_name IN LISTS SUB_CHECK_TARGETS component_check_targets)
+ set(${target_name}-${name} ${target_name})
+ list(APPEND ${name}_test_targets ${target_name}-${name})
+ list(APPEND test_targets ${target_name}-${name})
endforeach()
set(test_targets "${test_targets}" PARENT_SCOPE)
endif()
set(${name}_extra_args ${ARG_CMAKE_ARGS})
- get_cmake_property(variable_names VARIABLES)
- foreach(extra_name IN ITEMS ${name} ${ARG_BASE_NAME})
- foreach(variable_name ${variable_names})
- string(FIND "${variable_name}" "RUNTIMES_${extra_name}_" out)
+ get_cmake_property(variableNames VARIABLES)
+ foreach(variableName ${variableNames})
+ string(FIND "${variableName}" "RUNTIMES_${target}_" out)
+ if("${out}" EQUAL 0)
+ string(REPLACE "RUNTIMES_${target}_" "" new_name ${variableName})
+ string(REPLACE ";" "|" new_value "${${variableName}}")
+ list(APPEND ${name}_extra_args "-D${new_name}=${new_value}")
+ endif()
+ endforeach()
+ if(NOT "${name}" STREQUAL "${target}")
+ foreach(variableName ${variableNames})
+ string(FIND "${variableName}" "RUNTIMES_${name}_" out)
if("${out}" EQUAL 0)
- string(REPLACE "RUNTIMES_${extra_name}_" "" new_name ${variable_name})
- string(REPLACE ";" "|" new_value "${${variable_name}}")
+ string(REPLACE "RUNTIMES_${name}_" "" new_name ${variableName})
+ string(REPLACE ";" "|" new_value "${${variableName}}")
list(APPEND ${name}_extra_args "-D${new_name}=${new_value}")
endif()
endforeach()
- endforeach()
+ endif()
- if(NOT RUNTIMES_${name}_LLVM_ENABLE_RUNTIMES)
+ if(NOT RUNTIMES_${name}_LLVM_ENABLE_RUNTIMES AND NOT RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES)
string(REPLACE ";" "|" LLVM_ENABLE_RUNTIMES_PASSTHROUGH "${LLVM_ENABLE_RUNTIMES}")
list(APPEND ${name}_extra_args -DLLVM_ENABLE_RUNTIMES=${LLVM_ENABLE_RUNTIMES_PASSTHROUGH})
endif()
@@ -336,10 +350,11 @@ function(runtime_register_target name)
llvm_ExternalProject_Add(runtimes-${name}
${CMAKE_CURRENT_SOURCE_DIR}/../../runtimes
- DEPENDS ${ARG_DEPENDS}
+ DEPENDS ${${name}_deps}
# Builtins were built separately above
- CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=OFF
+ CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
-DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
+ -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
-DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR}
-DCMAKE_C_COMPILER_WORKS=ON
@@ -352,7 +367,8 @@ function(runtime_register_target name)
EXTRA_TARGETS ${${name}_extra_targets}
${${name}_test_targets}
USE_TOOLCHAIN
- ${EXTRA_ARGS} ${ARG_EXTRA_ARGS})
+ TARGET_TRIPLE ${target}
+ ${EXTRA_ARGS})
endfunction()
if(runtimes)
@@ -411,13 +427,8 @@ if(runtimes)
set(builtins_dep_name ${builtins_dep})
endif()
endif()
-
- check_apple_target(${name} runtime)
-
- runtime_register_target(${name}
- DEPENDS ${builtins_dep_name}
- CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${name}
- EXTRA_ARGS TARGET_TRIPLE ${name})
+ runtime_register_target(${name} ${name}
+ DEPENDS ${builtins_dep_name})
add_dependencies(runtimes runtimes-${name})
add_dependencies(runtimes-configure runtimes-${name}-configure)
@@ -441,14 +452,10 @@ if(runtimes)
foreach(multilib ${LLVM_RUNTIME_MULTILIBS})
foreach(name ${LLVM_RUNTIME_MULTILIB_${multilib}_TARGETS})
- runtime_register_target(${name}+${multilib}
+ runtime_register_target(${name}+${multilib} ${name}
DEPENDS runtimes-${name}
- CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${name}
- -DLLVM_RUNTIMES_PREFIX=${name}/
- -DLLVM_RUNTIMES_LIBDIR_SUBDIR=${multilib}
- BASE_NAME ${name}
- EXTRA_ARGS TARGET_TRIPLE ${name})
-
+ CMAKE_ARGS -DLLVM_RUNTIMES_PREFIX=${name}/
+ -DLLVM_RUNTIMES_LIBDIR_SUBDIR=${multilib})
add_dependencies(runtimes runtimes-${name}+${multilib})
add_dependencies(runtimes-configure runtimes-${name}+${multilib}-configure)
add_dependencies(install-runtimes install-runtimes-${name}+${multilib})
More information about the llvm-commits
mailing list