diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt --- a/llvm/runtimes/CMakeLists.txt +++ b/llvm/runtimes/CMakeLists.txt @@ -161,12 +161,6 @@ # for all variables that will apply to runtimes. foreach(entry ${runtimes}) get_filename_component(projName ${entry} NAME) - if(projName STREQUAL "libc") - # For now, we will use the name "llvmlibc" for the libc project as it is - # not a full libc yet. Also, if we leave it as is, the "lib" prefix gets - # stripped below and the targets endup having the name "c", "check-c" etc. - set(projName "llvmlibc") - endif() string(REPLACE "-" "_" canon_name ${projName}) string(TOUPPER ${canon_name} canon_name) list(APPEND prefixes ${canon_name}) @@ -178,20 +172,20 @@ if(canon_name STREQUAL "COMPILER_RT") list(APPEND prefixes SANITIZER DARWIN) endif() - if(canon_name STREQUAL "LLVMLIBC") + if(canon_name STREQUAL "LIBC") list(APPEND prefixes "LLVM_LIBC") list(APPEND prefixes "LIBC_") endif() string(FIND ${projName} "lib" LIB_IDX) - if(LIB_IDX EQUAL 0) + if(LIB_IDX EQUAL 0 AND NOT projName STREQUAL "libc") string(SUBSTRING ${projName} 3 -1 projName) endif() list(APPEND runtime_names ${projName}) endforeach() function(runtime_default_target) - cmake_parse_arguments(ARG "" "" "DEPENDS;PREFIXES" ${ARGN}) + cmake_parse_arguments(ARG "" "" "DEPENDS;CMAKE_ARGS;PREFIXES" ${ARGN}) include(${LLVM_BINARY_DIR}/runtimes/Components.cmake OPTIONAL) set(SUB_CHECK_TARGETS ${SUB_CHECK_TARGETS} PARENT_SCOPE) @@ -238,6 +232,7 @@ -DCMAKE_ASM_COMPILER_WORKS=ON ${COMMON_CMAKE_ARGS} ${RUNTIMES_CMAKE_ARGS} + ${ARG_CMAKE_ARGS} PASSTHROUGH_PREFIXES LLVM_ENABLE_RUNTIMES LLVM_USE_LINKER ${ARG_PREFIXES} @@ -254,7 +249,7 @@ # runtime_register_target(target) # Utility function to register external runtime target. function(runtime_register_target name target) - cmake_parse_arguments(ARG "" "" "DEPENDS;CMAKE_ARGS" ${ARGN}) + cmake_parse_arguments(ARG "" "" "DEPENDS;CMAKE_ARGS;PREFIXES" ${ARGN}) include(${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake OPTIONAL) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake) @@ -364,6 +359,7 @@ -DLLVM_RUNTIMES_TARGET=${name} ${COMMON_CMAKE_ARGS} ${${name}_extra_args} + PASSTHROUGH_PREFIXES ${ARG_PREFIXES} EXTRA_TARGETS ${${name}_extra_targets} ${${name}_test_targets} USE_TOOLCHAIN @@ -384,15 +380,31 @@ list(APPEND extra_deps llvm-link) endif() endif() + set(libc_tools) + set(libc_cmake_args) + if("libc" IN_LIST LLVM_ENABLE_RUNTIMES) + if(TARGET libc-hdrgen) + set(libc_tools libc-hdrgen) + set(libc_cmake_args "-DLIBC_HDRGEN_EXE=$") + list(APPEND extra_deps ${libc_tools}) + else() + # We want to build the libc build tools before we can build the libc + # itself. So, the libc project should be included in LLVM_ENABLE_PROJECTS. + message(FATAL_ERROR + "libc-hdrgen target missing; Add the libc project in -LLVM_ENABLE_PROJECTS") + endif() + endif() if(NOT LLVM_RUNTIME_TARGETS) runtime_default_target( DEPENDS ${builtins_dep} ${extra_deps} + CMAKE_ARGS ${libc_cmake_args} PREFIXES ${prefixes}) set(test_targets check-runtimes) else() if("default" IN_LIST LLVM_RUNTIME_TARGETS) runtime_default_target( DEPENDS ${builtins_dep} ${extra_deps} + CMAKE_ARGS ${libc_cmake_args} PREFIXES ${prefixes}) list(REMOVE_ITEM LLVM_RUNTIME_TARGETS "default") else() @@ -428,7 +440,9 @@ endif() endif() runtime_register_target(${name} ${name} - DEPENDS ${builtins_dep_name}) + DEPENDS ${builtins_dep_name} ${libc_tools} + CMAKE_ARGS ${libc_cmake_args} + PREFIXES ${prefixes}) add_dependencies(runtimes runtimes-${name}) add_dependencies(runtimes-configure runtimes-${name}-configure)