@@ -96,33 +96,36 @@ function(builtin_default_target compiler_rt_path)
96
96
${EXTRA_ARGS} )
97
97
endfunction ()
98
98
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} )
101
101
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 )
106
107
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} " )
110
111
endif ()
111
112
endforeach ()
112
113
113
- llvm_ExternalProject_Add (builtins-${name }
114
+ llvm_ExternalProject_Add (builtins-${target }
114
115
${compiler_rt_path} /lib/builtins
115
116
DEPENDS ${ARG_DEPENDS}
116
117
CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
117
118
-DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
119
+ -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
118
120
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
119
121
-DCMAKE_C_COMPILER_WORKS=ON
120
122
-DCMAKE_ASM_COMPILER_WORKS=ON
121
123
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
122
124
${COMMON_CMAKE_ARGS}
123
- ${${name }_extra_args}
125
+ ${${target }_extra_args}
124
126
USE_TOOLCHAIN
125
- ${EXTRA_ARGS} ${ARG_EXTRA_ARGS} )
127
+ TARGET_TRIPLE ${target}
128
+ ${EXTRA_ARGS} )
126
129
endfunction ()
127
130
128
131
# If compiler-rt is present we need to build the builtin libraries first. This
@@ -145,12 +148,8 @@ if(compiler_rt_path)
145
148
endif ()
146
149
147
150
foreach (target ${LLVM_BUILTIN_TARGETS} )
148
- check_apple_target (${target} builtin )
149
-
150
151
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 )
154
153
155
154
add_dependencies (builtins builtins-${target} )
156
155
add_dependencies (install -builtins install -builtins-${target} )
@@ -250,13 +249,20 @@ function(runtime_default_target)
250
249
${EXTRA_ARGS} )
251
250
endfunction ()
252
251
253
- # runtime_register_target(name )
252
+ # runtime_register_target(target )
254
253
# 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} )
257
256
include (${LLVM_BINARY_DIR} /runtimes/${name}/Components.cmake OPTIONAL )
258
257
set_property (DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR} /runtimes/${name}/Components.cmake )
259
258
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
+
260
266
foreach (runtime_name ${runtime_names} )
261
267
set (${runtime_name} -${name} ${runtime_name} )
262
268
set (install -${runtime_name}-${name} install -${runtime_name} )
@@ -268,15 +274,15 @@ function(runtime_register_target name)
268
274
endif ()
269
275
endforeach ()
270
276
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} )
274
280
endforeach ()
275
281
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 )
280
286
endforeach ()
281
287
282
288
foreach (component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS} )
@@ -302,28 +308,36 @@ function(runtime_register_target name)
302
308
endif ()
303
309
endforeach ()
304
310
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} )
309
315
endforeach ()
310
316
set (test_targets "${test_targets} " PARENT_SCOPE )
311
317
endif ()
312
318
313
319
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 )
318
332
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 } }" )
321
335
list (APPEND ${name} _extra_args "-D${new_name} =${new_value} " )
322
336
endif ()
323
337
endforeach ()
324
- endforeach ()
338
+ endif ()
325
339
326
- if (NOT RUNTIMES_${name}_LLVM_ENABLE_RUNTIMES )
340
+ if (NOT RUNTIMES_${name}_LLVM_ENABLE_RUNTIMES AND NOT RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES )
327
341
string (REPLACE ";" "|" LLVM_ENABLE_RUNTIMES_PASSTHROUGH "${LLVM_ENABLE_RUNTIMES} " )
328
342
list (APPEND ${name} _extra_args -DLLVM_ENABLE_RUNTIMES=${LLVM_ENABLE_RUNTIMES_PASSTHROUGH} )
329
343
endif ()
@@ -336,10 +350,11 @@ function(runtime_register_target name)
336
350
337
351
llvm_ExternalProject_Add (runtimes-${name}
338
352
${CMAKE_CURRENT_SOURCE_DIR} /../../runtimes
339
- DEPENDS ${ARG_DEPENDS }
353
+ DEPENDS ${${name}_deps }
340
354
# Builtins were built separately above
341
- CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=OFF
355
+ CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
342
356
-DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
357
+ -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
343
358
-DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
344
359
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR}
345
360
-DCMAKE_C_COMPILER_WORKS=ON
@@ -352,7 +367,8 @@ function(runtime_register_target name)
352
367
EXTRA_TARGETS ${${name}_extra_targets}
353
368
${${name}_test_targets}
354
369
USE_TOOLCHAIN
355
- ${EXTRA_ARGS} ${ARG_EXTRA_ARGS} )
370
+ TARGET_TRIPLE ${target}
371
+ ${EXTRA_ARGS} )
356
372
endfunction ()
357
373
358
374
if (runtimes )
@@ -411,13 +427,8 @@ if(runtimes)
411
427
set (builtins_dep_name ${builtins_dep} )
412
428
endif ()
413
429
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} )
421
432
422
433
add_dependencies (runtimes runtimes-${name} )
423
434
add_dependencies (runtimes-configure runtimes-${name}-configure )
@@ -441,14 +452,10 @@ if(runtimes)
441
452
442
453
foreach (multilib ${LLVM_RUNTIME_MULTILIBS} )
443
454
foreach (name ${LLVM_RUNTIME_MULTILIB_${multilib}_TARGETS} )
444
- runtime_register_target (${name} +${multilib}
455
+ runtime_register_target (${name} +${multilib} ${name}
445
456
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} )
452
459
add_dependencies (runtimes runtimes-${name}+${multilib} )
453
460
add_dependencies (runtimes-configure runtimes-${name}+${multilib}-configure )
454
461
add_dependencies (install -runtimes install -runtimes-${name}+${multilib} )
0 commit comments