Skip to content

Commit 8dac97e

Browse files
committed
Revert "[CMake] Support runtimes targets without specifying triple"
This reverts commit e6975c4 since it broke the bootstrapping build on Windows.
1 parent 03ff435 commit 8dac97e

File tree

1 file changed

+63
-56
lines changed

1 file changed

+63
-56
lines changed

llvm/runtimes/CMakeLists.txt

Lines changed: 63 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -96,33 +96,36 @@ function(builtin_default_target compiler_rt_path)
9696
${EXTRA_ARGS})
9797
endfunction()
9898

99-
function(builtin_register_target compiler_rt_path name)
100-
cmake_parse_arguments(ARG "" "" "DEPENDS;CMAKE_ARGS;EXTRA_ARGS" ${ARGN})
99+
function(builtin_register_target compiler_rt_path target)
100+
cmake_parse_arguments(ARG "" "" "DEPENDS" ${ARGN})
101101

102-
set(${name}_extra_args ${ARG_CMAKE_ARGS})
103-
get_cmake_property(variable_names VARIABLES)
104-
foreach(variable_name ${variable_names})
105-
string(FIND "${variable_name}" "BUILTINS_${name}" out)
102+
check_apple_target(${target} builtin)
103+
104+
get_cmake_property(variableNames VARIABLES)
105+
foreach(variableName ${variableNames})
106+
string(FIND "${variableName}" "BUILTINS_${target}" out)
106107
if("${out}" EQUAL 0)
107-
string(REPLACE "BUILTINS_${name}_" "" new_name ${variable_name})
108-
string(REPLACE ";" "|" new_value "${${variable_name}}")
109-
list(APPEND ${name}_extra_args "-D${new_name}=${new_value}")
108+
string(REPLACE "BUILTINS_${target}_" "" new_name ${variableName})
109+
string(REPLACE ";" "|" new_value "${${variableName}}")
110+
list(APPEND ${target}_extra_args "-D${new_name}=${new_value}")
110111
endif()
111112
endforeach()
112113

113-
llvm_ExternalProject_Add(builtins-${name}
114+
llvm_ExternalProject_Add(builtins-${target}
114115
${compiler_rt_path}/lib/builtins
115116
DEPENDS ${ARG_DEPENDS}
116117
CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
117118
-DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
119+
-DLLVM_DEFAULT_TARGET_TRIPLE=${target}
118120
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
119121
-DCMAKE_C_COMPILER_WORKS=ON
120122
-DCMAKE_ASM_COMPILER_WORKS=ON
121123
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
122124
${COMMON_CMAKE_ARGS}
123-
${${name}_extra_args}
125+
${${target}_extra_args}
124126
USE_TOOLCHAIN
125-
${EXTRA_ARGS} ${ARG_EXTRA_ARGS})
127+
TARGET_TRIPLE ${target}
128+
${EXTRA_ARGS})
126129
endfunction()
127130

128131
# If compiler-rt is present we need to build the builtin libraries first. This
@@ -145,12 +148,8 @@ if(compiler_rt_path)
145148
endif()
146149

147150
foreach(target ${LLVM_BUILTIN_TARGETS})
148-
check_apple_target(${target} builtin)
149-
150151
builtin_register_target(${compiler_rt_path} ${target}
151-
DEPENDS clang-resource-headers
152-
CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
153-
EXTRA_ARGS TARGET_TRIPLE ${target})
152+
DEPENDS clang-resource-headers)
154153

155154
add_dependencies(builtins builtins-${target})
156155
add_dependencies(install-builtins install-builtins-${target})
@@ -250,13 +249,20 @@ function(runtime_default_target)
250249
${EXTRA_ARGS})
251250
endfunction()
252251

253-
# runtime_register_target(name)
252+
# runtime_register_target(target)
254253
# Utility function to register external runtime target.
255-
function(runtime_register_target name)
256-
cmake_parse_arguments(ARG "" "" "DEPENDS;CMAKE_ARGS;BASE_NAME;EXTRA_ARGS" ${ARGN})
254+
function(runtime_register_target name target)
255+
cmake_parse_arguments(ARG "" "" "DEPENDS;CMAKE_ARGS" ${ARGN})
257256
include(${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake OPTIONAL)
258257
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake)
259258

259+
check_apple_target(${target} runtime)
260+
261+
set(${name}_deps ${ARG_DEPENDS})
262+
if(NOT name STREQUAL target)
263+
list(APPEND ${name}_deps runtimes-${target})
264+
endif()
265+
260266
foreach(runtime_name ${runtime_names})
261267
set(${runtime_name}-${name} ${runtime_name})
262268
set(install-${runtime_name}-${name} install-${runtime_name})
@@ -268,15 +274,15 @@ function(runtime_register_target name)
268274
endif()
269275
endforeach()
270276

271-
foreach(component IN LISTS SUB_COMPONENTS)
272-
set(${component}-${name} ${component})
273-
list(APPEND ${name}_extra_targets ${component}-${name})
277+
foreach(target_name IN LISTS SUB_COMPONENTS)
278+
set(${target_name}-${name} ${target_name})
279+
list(APPEND ${name}_extra_targets ${target_name}-${name})
274280
endforeach()
275281

276-
foreach(target IN LISTS SUB_INSTALL_TARGETS)
277-
set(${target}-${name} ${target})
278-
set(${target}-${name}-stripped ${target}-stripped)
279-
list(APPEND ${name}_extra_targets ${target}-${name} ${target}-${name}-stripped)
282+
foreach(target_name IN LISTS SUB_INSTALL_TARGETS)
283+
set(${target_name}-${name} ${target_name})
284+
set(${target_name}-${name}-stripped ${target_name}-stripped)
285+
list(APPEND ${name}_extra_targets ${target_name}-${name} ${target_name}-${name}-stripped)
280286
endforeach()
281287

282288
foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
@@ -302,28 +308,36 @@ function(runtime_register_target name)
302308
endif()
303309
endforeach()
304310

305-
foreach(target IN LISTS SUB_CHECK_TARGETS component_check_targets)
306-
set(${target}-${name} ${target})
307-
list(APPEND ${name}_test_targets ${target}-${name})
308-
list(APPEND test_targets ${target}-${name})
311+
foreach(target_name IN LISTS SUB_CHECK_TARGETS component_check_targets)
312+
set(${target_name}-${name} ${target_name})
313+
list(APPEND ${name}_test_targets ${target_name}-${name})
314+
list(APPEND test_targets ${target_name}-${name})
309315
endforeach()
310316
set(test_targets "${test_targets}" PARENT_SCOPE)
311317
endif()
312318

313319
set(${name}_extra_args ${ARG_CMAKE_ARGS})
314-
get_cmake_property(variable_names VARIABLES)
315-
foreach(extra_name IN ITEMS ${name} ${ARG_BASE_NAME})
316-
foreach(variable_name ${variable_names})
317-
string(FIND "${variable_name}" "RUNTIMES_${extra_name}_" out)
320+
get_cmake_property(variableNames VARIABLES)
321+
foreach(variableName ${variableNames})
322+
string(FIND "${variableName}" "RUNTIMES_${target}_" out)
323+
if("${out}" EQUAL 0)
324+
string(REPLACE "RUNTIMES_${target}_" "" new_name ${variableName})
325+
string(REPLACE ";" "|" new_value "${${variableName}}")
326+
list(APPEND ${name}_extra_args "-D${new_name}=${new_value}")
327+
endif()
328+
endforeach()
329+
if(NOT "${name}" STREQUAL "${target}")
330+
foreach(variableName ${variableNames})
331+
string(FIND "${variableName}" "RUNTIMES_${name}_" out)
318332
if("${out}" EQUAL 0)
319-
string(REPLACE "RUNTIMES_${extra_name}_" "" new_name ${variable_name})
320-
string(REPLACE ";" "|" new_value "${${variable_name}}")
333+
string(REPLACE "RUNTIMES_${name}_" "" new_name ${variableName})
334+
string(REPLACE ";" "|" new_value "${${variableName}}")
321335
list(APPEND ${name}_extra_args "-D${new_name}=${new_value}")
322336
endif()
323337
endforeach()
324-
endforeach()
338+
endif()
325339

326-
if(NOT RUNTIMES_${name}_LLVM_ENABLE_RUNTIMES)
340+
if(NOT RUNTIMES_${name}_LLVM_ENABLE_RUNTIMES AND NOT RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES)
327341
string(REPLACE ";" "|" LLVM_ENABLE_RUNTIMES_PASSTHROUGH "${LLVM_ENABLE_RUNTIMES}")
328342
list(APPEND ${name}_extra_args -DLLVM_ENABLE_RUNTIMES=${LLVM_ENABLE_RUNTIMES_PASSTHROUGH})
329343
endif()
@@ -336,10 +350,11 @@ function(runtime_register_target name)
336350

337351
llvm_ExternalProject_Add(runtimes-${name}
338352
${CMAKE_CURRENT_SOURCE_DIR}/../../runtimes
339-
DEPENDS ${ARG_DEPENDS}
353+
DEPENDS ${${name}_deps}
340354
# Builtins were built separately above
341-
CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=OFF
355+
CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
342356
-DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
357+
-DLLVM_DEFAULT_TARGET_TRIPLE=${target}
343358
-DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
344359
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR}
345360
-DCMAKE_C_COMPILER_WORKS=ON
@@ -352,7 +367,8 @@ function(runtime_register_target name)
352367
EXTRA_TARGETS ${${name}_extra_targets}
353368
${${name}_test_targets}
354369
USE_TOOLCHAIN
355-
${EXTRA_ARGS} ${ARG_EXTRA_ARGS})
370+
TARGET_TRIPLE ${target}
371+
${EXTRA_ARGS})
356372
endfunction()
357373

358374
if(runtimes)
@@ -411,13 +427,8 @@ if(runtimes)
411427
set(builtins_dep_name ${builtins_dep})
412428
endif()
413429
endif()
414-
415-
check_apple_target(${name} runtime)
416-
417-
runtime_register_target(${name}
418-
DEPENDS ${builtins_dep_name}
419-
CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${name}
420-
EXTRA_ARGS TARGET_TRIPLE ${name})
430+
runtime_register_target(${name} ${name}
431+
DEPENDS ${builtins_dep_name})
421432

422433
add_dependencies(runtimes runtimes-${name})
423434
add_dependencies(runtimes-configure runtimes-${name}-configure)
@@ -441,14 +452,10 @@ if(runtimes)
441452

442453
foreach(multilib ${LLVM_RUNTIME_MULTILIBS})
443454
foreach(name ${LLVM_RUNTIME_MULTILIB_${multilib}_TARGETS})
444-
runtime_register_target(${name}+${multilib}
455+
runtime_register_target(${name}+${multilib} ${name}
445456
DEPENDS runtimes-${name}
446-
CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${name}
447-
-DLLVM_RUNTIMES_PREFIX=${name}/
448-
-DLLVM_RUNTIMES_LIBDIR_SUBDIR=${multilib}
449-
BASE_NAME ${name}
450-
EXTRA_ARGS TARGET_TRIPLE ${name})
451-
457+
CMAKE_ARGS -DLLVM_RUNTIMES_PREFIX=${name}/
458+
-DLLVM_RUNTIMES_LIBDIR_SUBDIR=${multilib})
452459
add_dependencies(runtimes runtimes-${name}+${multilib})
453460
add_dependencies(runtimes-configure runtimes-${name}+${multilib}-configure)
454461
add_dependencies(install-runtimes install-runtimes-${name}+${multilib})

0 commit comments

Comments
 (0)