@@ -193,7 +193,7 @@ foreach(entry ${runtimes})
193
193
endforeach ()
194
194
195
195
function (runtime_default_target)
196
- cmake_parse_arguments (ARG "" "" "DEPENDS;PREFIXES" ${ARGN} )
196
+ cmake_parse_arguments (ARG "" "" "DEPENDS;CMAKE_ARGS; PREFIXES" ${ARGN} )
197
197
198
198
include (${LLVM_BINARY_DIR} /runtimes/Components.cmake OPTIONAL )
199
199
set (SUB_CHECK_TARGETS ${SUB_CHECK_TARGETS} PARENT_SCOPE)
@@ -236,6 +236,7 @@ function(runtime_default_target)
236
236
-DCMAKE_ASM_COMPILER_WORKS=ON
237
237
${COMMON_CMAKE_ARGS}
238
238
${RUNTIMES_CMAKE_ARGS}
239
+ ${ARG_CMAKE_ARGS}
239
240
PASSTHROUGH_PREFIXES LLVM_ENABLE_RUNTIMES
240
241
LLVM_USE_LINKER
241
242
${ARG_PREFIXES}
@@ -384,15 +385,31 @@ if(runtimes)
384
385
list (APPEND extra_deps llvm-link)
385
386
endif ()
386
387
endif ()
388
+ if ("libc" IN_LIST LLVM_ENABLE_RUNTIMES AND LLVM_LIBC_FULL_BUILD)
389
+ if (TARGET libc-hdrgen)
390
+ set (libc_tools libc-hdrgen)
391
+ set (libc_cmake_args "-DLIBC_HDRGEN_EXE=$<TARGET_FILE:libc-hdrgen>"
392
+ "-DLLVM_LIBC_FULL_BUILD=ON" )
393
+ list (APPEND extra_deps ${libc_tools} )
394
+ else ()
395
+ # We want to build the libc build tools before we can build the libc
396
+ # itself. So, the libc project should be included in LLVM_ENABLE_PROJECTS.
397
+ # This should have been done in llvm/CMakeLists.txt automatically when
398
+ # "libc" is detected in LLVM_ENABLE_RUNTIMES.
399
+ message (FATAL_ERROR "libc-hdrgen target missing unexpectedly" )
400
+ endif ()
401
+ endif ()
387
402
if (NOT LLVM_RUNTIME_TARGETS)
388
403
runtime_default_target(
389
404
DEPENDS ${builtins_dep} ${extra_deps}
405
+ CMAKE_ARGS ${libc_cmake_args}
390
406
PREFIXES ${prefixes} )
391
407
set (test_targets check-runtimes)
392
408
else ()
393
409
if ("default" IN_LIST LLVM_RUNTIME_TARGETS)
394
410
runtime_default_target(
395
411
DEPENDS ${builtins_dep} ${extra_deps}
412
+ CMAKE_ARGS ${libc_cmake_args}
396
413
PREFIXES ${prefixes} )
397
414
list (REMOVE_ITEM LLVM_RUNTIME_TARGETS "default" )
398
415
else ()
@@ -428,7 +445,8 @@ if(runtimes)
428
445
endif ()
429
446
endif ()
430
447
runtime_register_target(${name} ${name}
431
- DEPENDS ${builtins_dep_name} )
448
+ DEPENDS ${builtins_dep_name} ${libc_tools}
449
+ CMAKE_ARGS ${libc_cmake_args} )
432
450
433
451
add_dependencies (runtimes runtimes-${name} )
434
452
add_dependencies (runtimes-configure runtimes-${name} -configure)
0 commit comments