@@ -96,36 +96,33 @@ function(builtin_default_target compiler_rt_path)
96
96
${EXTRA_ARGS} )
97
97
endfunction ()
98
98
99
- function (builtin_register_target compiler_rt_path target )
100
- cmake_parse_arguments (ARG "" "" "DEPENDS" ${ARGN} )
101
-
102
- check_apple_target(${target} builtin)
99
+ function (builtin_register_target compiler_rt_path name )
100
+ cmake_parse_arguments (ARG "" "" "DEPENDS;CMAKE_ARGS;EXTRA_ARGS" ${ARGN} )
103
101
104
- get_cmake_property (variableNames VARIABLES )
105
- foreach (variableName ${variableNames} )
106
- string (FIND "${variableName} " "BUILTINS_${target} " out)
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)
107
106
if ("${out} " EQUAL 0)
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} " )
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} " )
111
110
endif ()
112
111
endforeach ()
113
112
114
- llvm_ExternalProject_Add(builtins-${target }
113
+ llvm_ExternalProject_Add(builtins-${name }
115
114
${compiler_rt_path} /lib/builtins
116
115
DEPENDS ${ARG_DEPENDS}
117
116
CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
118
117
-DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
119
- -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
120
118
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
121
119
-DCMAKE_C_COMPILER_WORKS=ON
122
120
-DCMAKE_ASM_COMPILER_WORKS=ON
123
121
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
124
122
${COMMON_CMAKE_ARGS}
125
- ${${target } _extra_args}
123
+ ${${name } _extra_args}
126
124
USE_TOOLCHAIN
127
- TARGET_TRIPLE ${target}
128
- ${EXTRA_ARGS} )
125
+ ${EXTRA_ARGS} ${ARG_EXTRA_ARGS} )
129
126
endfunction ()
130
127
131
128
# If compiler-rt is present we need to build the builtin libraries first. This
@@ -148,8 +145,12 @@ if(compiler_rt_path)
148
145
endif ()
149
146
150
147
foreach (target ${LLVM_BUILTIN_TARGETS} )
148
+ check_apple_target(${target} builtin)
149
+
151
150
builtin_register_target(${compiler_rt_path} ${target}
152
- DEPENDS clang-resource -headers)
151
+ DEPENDS clang-resource -headers
152
+ CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
153
+ EXTRA_ARGS TARGET_TRIPLE ${target} )
153
154
154
155
add_dependencies (builtins builtins-${target} )
155
156
add_dependencies (install -builtins install -builtins-${target} )
@@ -254,20 +255,13 @@ function(runtime_default_target)
254
255
${EXTRA_ARGS} )
255
256
endfunction ()
256
257
257
- # runtime_register_target(target )
258
+ # runtime_register_target(name )
258
259
# Utility function to register external runtime target.
259
- function (runtime_register_target name target )
260
- cmake_parse_arguments (ARG "" "" "DEPENDS;CMAKE_ARGS" ${ARGN} )
260
+ function (runtime_register_target name )
261
+ cmake_parse_arguments (ARG "" "BASE_NAME " "DEPENDS;CMAKE_ARGS;EXTRA_ARGS " ${ARGN} )
261
262
include (${LLVM_BINARY_DIR} /runtimes/${name} /Components.cmake OPTIONAL )
262
263
set_property (DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR} /runtimes/${name} /Components.cmake)
263
264
264
- check_apple_target(${target} runtime)
265
-
266
- set (${name} _deps ${ARG_DEPENDS} )
267
- if (NOT name STREQUAL target )
268
- list (APPEND ${name} _deps runtimes-${target} )
269
- endif ()
270
-
271
265
foreach (runtime_name ${runtime_names} )
272
266
set (${runtime_name} -${name} ${runtime_name} )
273
267
set (install -${runtime_name} -${name} install -${runtime_name} )
@@ -279,15 +273,15 @@ function(runtime_register_target name target)
279
273
endif ()
280
274
endforeach ()
281
275
282
- foreach (target_name IN LISTS SUB_COMPONENTS)
283
- set (${target_name } -${name} ${target_name } )
284
- list (APPEND ${name} _extra_targets ${target_name } -${name} )
276
+ foreach (component IN LISTS SUB_COMPONENTS)
277
+ set (${component } -${name} ${component } )
278
+ list (APPEND ${name} _extra_targets ${component } -${name} )
285
279
endforeach ()
286
280
287
- foreach (target_name IN LISTS SUB_INSTALL_TARGETS)
288
- set (${target_name } -${name} ${target_name } )
289
- set (${target_name } -${name} -stripped ${target_name } -stripped)
290
- list (APPEND ${name} _extra_targets ${target_name } -${name} ${target_name } -${name} -stripped)
281
+ foreach (target IN LISTS SUB_INSTALL_TARGETS)
282
+ set (${target } -${name} ${target } )
283
+ set (${target } -${name} -stripped ${target } -stripped)
284
+ list (APPEND ${name} _extra_targets ${target } -${name} ${target } -${name} -stripped)
291
285
endforeach ()
292
286
293
287
foreach (component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS} )
@@ -313,53 +307,39 @@ function(runtime_register_target name target)
313
307
endif ()
314
308
endforeach ()
315
309
316
- foreach (target_name IN LISTS SUB_CHECK_TARGETS component_check_targets)
317
- set (${target_name } -${name} ${target_name } )
318
- list (APPEND ${name} _test_targets ${target_name } -${name} )
319
- list (APPEND test_targets ${target_name } -${name} )
310
+ foreach (target IN LISTS SUB_CHECK_TARGETS component_check_targets)
311
+ set (${target } -${name} ${target } )
312
+ list (APPEND ${name} _test_targets ${target } -${name} )
313
+ list (APPEND test_targets ${target } -${name} )
320
314
endforeach ()
321
315
set (test_targets "${test_targets} " PARENT_SCOPE)
322
316
endif ()
323
317
324
318
set (${name} _extra_args ${ARG_CMAKE_ARGS} )
325
- get_cmake_property (variableNames VARIABLES )
326
- foreach (variableName ${variableNames} )
327
- string (FIND "${variableName} " "RUNTIMES_${target} _" out)
328
- if ("${out} " EQUAL 0)
329
- string (REPLACE "RUNTIMES_${target} _" "" new_name ${variableName} )
330
- string (REPLACE ";" "|" new_value "${${variableName} }" )
331
- list (APPEND ${name} _extra_args "-D${new_name} =${new_value} " )
332
- endif ()
333
- endforeach ()
334
- if (NOT "${name} " STREQUAL "${target} " )
335
- foreach (variableName ${variableNames} )
336
- string (FIND "${variableName} " "RUNTIMES_${name} _" out)
319
+ string (REPLACE ";" "|" LVM_ENABLE_RUNTIMES_PASSTHROUGH "${LLVM_ENABLE_RUNTIMES} " )
320
+ list (APPEND ${name} _extra_args -DLLVM_ENABLE_RUNTIMES=${LLVM_ENABLE_RUNTIMES_PASSTHROUGH} )
321
+ list (APPEND ${name} _extra_args -DLLVM_USE_LINKER=${LLVM_USE_LINKER} )
322
+
323
+ get_cmake_property (variable_names VARIABLES )
324
+ foreach (extra_name IN ITEMS ${ARG_BASE_NAME} ${name} )
325
+ foreach (variable_name ${variable_names} )
326
+ string (FIND "${variable_name} " "RUNTIMES_${extra_name} _" out)
337
327
if ("${out} " EQUAL 0)
338
- string (REPLACE "RUNTIMES_${name } _" "" new_name ${variableName } )
339
- string (REPLACE ";" "|" new_value "${${variableName } }" )
328
+ string (REPLACE "RUNTIMES_${extra_name } _" "" new_name ${variable_name } )
329
+ string (REPLACE ";" "|" new_value "${${variable_name } }" )
340
330
list (APPEND ${name} _extra_args "-D${new_name} =${new_value} " )
341
331
endif ()
342
332
endforeach ()
343
- endif ()
344
-
345
- if (NOT RUNTIMES_${name} _LLVM_ENABLE_RUNTIMES AND NOT RUNTIMES_${target} _LLVM_ENABLE_RUNTIMES)
346
- string (REPLACE ";" "|" LLVM_ENABLE_RUNTIMES_PASSTHROUGH "${LLVM_ENABLE_RUNTIMES} " )
347
- list (APPEND ${name} _extra_args -DLLVM_ENABLE_RUNTIMES=${LLVM_ENABLE_RUNTIMES_PASSTHROUGH} )
348
- endif ()
349
-
350
- if (NOT RUNTIMES_${name} _LLVM_USE_LINKER AND NOT RUNTIMES_${target} _LLVM_USE_LINKER)
351
- list (APPEND ${name} _extra_args -DLLVM_USE_LINKER=${LLVM_USE_LINKER} )
352
- endif ()
333
+ endforeach ()
353
334
354
335
set_enable_per_target_runtime_dir()
355
336
356
337
llvm_ExternalProject_Add(runtimes-${name}
357
338
${CMAKE_CURRENT_SOURCE_DIR} /../../runtimes
358
- DEPENDS ${${name} _deps }
339
+ DEPENDS ${ARG_DEPENDS }
359
340
# Builtins were built separately above
360
- CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
341
+ CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=OFF
361
342
-DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
362
- -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
363
343
-DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
364
344
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR}
365
345
-DCMAKE_C_COMPILER_WORKS=ON
@@ -372,8 +352,7 @@ function(runtime_register_target name target)
372
352
EXTRA_TARGETS ${${name} _extra_targets}
373
353
${${name} _test_targets}
374
354
USE_TOOLCHAIN
375
- TARGET_TRIPLE ${target}
376
- ${EXTRA_ARGS} )
355
+ ${EXTRA_ARGS} ${ARG_EXTRA_ARGS} )
377
356
endfunction ()
378
357
379
358
if (runtimes)
@@ -452,9 +431,13 @@ if(runtimes)
452
431
set (builtins_dep_name ${builtins_dep} )
453
432
endif ()
454
433
endif ()
455
- runtime_register_target(${name} ${name}
434
+
435
+ check_apple_target(${name} runtime)
436
+
437
+ runtime_register_target(${name}
456
438
DEPENDS ${builtins_dep_name} ${libc_tools}
457
- CMAKE_ARGS ${libc_cmake_args} )
439
+ CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${name} ${libc_cmake_args}
440
+ EXTRA_ARGS TARGET_TRIPLE ${name} )
458
441
459
442
add_dependencies (runtimes runtimes-${name} )
460
443
add_dependencies (runtimes-configure runtimes-${name} -configure)
@@ -478,10 +461,14 @@ if(runtimes)
478
461
479
462
foreach (multilib ${LLVM_RUNTIME_MULTILIBS} )
480
463
foreach (name ${LLVM_RUNTIME_MULTILIB_${multilib} _TARGETS})
481
- runtime_register_target(${name} +${multilib} ${name}
464
+ runtime_register_target(${name} +${multilib}
482
465
DEPENDS runtimes-${name}
483
- CMAKE_ARGS -DLLVM_RUNTIMES_PREFIX=${name} /
484
- -DLLVM_RUNTIMES_LIBDIR_SUBDIR=${multilib} )
466
+ CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${name}
467
+ -DLLVM_RUNTIMES_PREFIX=${name} /
468
+ -DLLVM_RUNTIMES_LIBDIR_SUBDIR=${multilib}
469
+ BASE_NAME ${name}
470
+ EXTRA_ARGS TARGET_TRIPLE ${name} )
471
+
485
472
add_dependencies (runtimes runtimes-${name} +${multilib} )
486
473
add_dependencies (runtimes-configure runtimes-${name} +${multilib} -configure)
487
474
add_dependencies (install -runtimes install -runtimes-${name} +${multilib} )
0 commit comments