@@ -193,7 +193,7 @@ foreach(entry ${runtimes})
193193endforeach ()
194194
195195function (runtime_default_target)
196- cmake_parse_arguments (ARG "" "" "DEPENDS;PREFIXES" ${ARGN} )
196+ cmake_parse_arguments (ARG "" "" "DEPENDS;CMAKE_ARGS; PREFIXES" ${ARGN} )
197197
198198 include (${LLVM_BINARY_DIR} /runtimes/Components.cmake OPTIONAL )
199199 set (SUB_CHECK_TARGETS ${SUB_CHECK_TARGETS} PARENT_SCOPE)
@@ -236,6 +236,7 @@ function(runtime_default_target)
236236 -DCMAKE_ASM_COMPILER_WORKS=ON
237237 ${COMMON_CMAKE_ARGS}
238238 ${RUNTIMES_CMAKE_ARGS}
239+ ${ARG_CMAKE_ARGS}
239240 PASSTHROUGH_PREFIXES LLVM_ENABLE_RUNTIMES
240241 LLVM_USE_LINKER
241242 ${ARG_PREFIXES}
@@ -384,15 +385,31 @@ if(runtimes)
384385 list (APPEND extra_deps llvm-link)
385386 endif ()
386387 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 ()
387402 if (NOT LLVM_RUNTIME_TARGETS)
388403 runtime_default_target(
389404 DEPENDS ${builtins_dep} ${extra_deps}
405+ CMAKE_ARGS ${libc_cmake_args}
390406 PREFIXES ${prefixes} )
391407 set (test_targets check-runtimes)
392408 else ()
393409 if ("default" IN_LIST LLVM_RUNTIME_TARGETS)
394410 runtime_default_target(
395411 DEPENDS ${builtins_dep} ${extra_deps}
412+ CMAKE_ARGS ${libc_cmake_args}
396413 PREFIXES ${prefixes} )
397414 list (REMOVE_ITEM LLVM_RUNTIME_TARGETS "default" )
398415 else ()
@@ -428,7 +445,8 @@ if(runtimes)
428445 endif ()
429446 endif ()
430447 runtime_register_target(${name} ${name}
431- DEPENDS ${builtins_dep_name} )
448+ DEPENDS ${builtins_dep_name} ${libc_tools}
449+ CMAKE_ARGS ${libc_cmake_args} )
432450
433451 add_dependencies (runtimes runtimes-${name} )
434452 add_dependencies (runtimes-configure runtimes-${name} -configure)
0 commit comments