Index: libc/CMakeLists.txt =================================================================== --- libc/CMakeLists.txt +++ libc/CMakeLists.txt @@ -40,26 +40,28 @@ --print-resource-dir not supported by host compiler") endif() -option(LLVM_LIBC_ENABLE_LINTING "Enables linting of libc source files" ON) -if(LLVM_LIBC_ENABLE_LINTING) - if("clang-tools-extra" IN_LIST LLVM_ENABLE_PROJECTS - AND "clang" IN_LIST LLVM_ENABLE_PROJECTS) - add_custom_target(lint-libc) +if(NOT LLVM_TARGET_IS_CROSSCOMPILE_HOST) + option(LLVM_LIBC_ENABLE_LINTING "Enables linting of libc source files" ON) + if(LLVM_LIBC_ENABLE_LINTING) + if("clang-tools-extra" IN_LIST LLVM_ENABLE_PROJECTS + AND "clang" IN_LIST LLVM_ENABLE_PROJECTS) + add_custom_target(lint-libc) + else() + message(FATAL_ERROR " + 'clang' and 'clang-tools-extra' are required in LLVM_ENABLE_PROJECTS to + lint llvm-libc. The linting step performs important checks to help prevent + the introduction of subtle bugs, but it may increase build times. + + To disable linting set LLVM_LIBC_ENABLE_LINTING to OFF + (pass -DLLVM_LIBC_ENABLE_LINTING=OFF to cmake).") + endif() else() - message(FATAL_ERROR " - 'clang' and 'clang-tools-extra' are required in LLVM_ENABLE_PROJECTS to - lint llvm-libc. The linting step performs important checks to help prevent - the introduction of subtle bugs, but it may increase build times. + message(WARNING " + Linting for libc is currently disabled. - To disable linting set LLVM_LIBC_ENABLE_LINTING to OFF - (pass -DLLVM_LIBC_ENABLE_LINTING=OFF to cmake).") + This is not recommended, to enable set LLVM_LIBC_ENABLE_LINTING to ON + (pass -DLLVM_LIBC_ENABLE_LINTING=ON to cmake).") endif() -else() - message(WARNING " - Linting for libc is currently disabled. - - This is not recommended, to enable set LLVM_LIBC_ENABLE_LINTING to ON - (pass -DLLVM_LIBC_ENABLE_LINTING=ON to cmake).") endif() include(CMakeParseArguments) @@ -81,6 +83,10 @@ list(APPEND TARGET_ENTRYPOINT_NAME_LIST ${entrypoint_name}) endforeach() +# We need to set up hdrgen first since other targets depend on it. +add_subdirectory(utils/LibcTableGenUtil) +add_subdirectory(utils/HdrGen) + add_subdirectory(include) add_subdirectory(config) add_subdirectory(src) Index: libc/cmake/modules/LLVMLibCHeaderRules.cmake =================================================================== --- libc/cmake/modules/LLVMLibCHeaderRules.cmake +++ libc/cmake/modules/LLVMLibCHeaderRules.cmake @@ -89,14 +89,15 @@ add_custom_command( OUTPUT ${out_file} - COMMAND $ -o ${out_file} --header ${ADD_GEN_HDR_GEN_HDR} + COMMAND ${LIBC_TABLEGEN_EXE} -o ${out_file} --header ${ADD_GEN_HDR_GEN_HDR} --def ${in_file} ${replacement_params} -I ${LIBC_SOURCE_DIR} ${ENTRYPOINT_NAME_LIST_ARG} ${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${in_file} ${fq_data_files} ${td_includes} - ${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td libc-hdrgen + ${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td + ${LIBC_TABLEGEN_EXE} ${LIBC_TABLEGEN_TARGET} ) get_fq_target_name(${target_name} fq_target_name) Index: libc/utils/CMakeLists.txt =================================================================== --- libc/utils/CMakeLists.txt +++ libc/utils/CMakeLists.txt @@ -1,7 +1,5 @@ add_subdirectory(CPP) add_subdirectory(FPUtil) -add_subdirectory(LibcTableGenUtil) -add_subdirectory(HdrGen) add_subdirectory(MPFRWrapper) add_subdirectory(testutils) add_subdirectory(tools) Index: libc/utils/HdrGen/CMakeLists.txt =================================================================== --- libc/utils/HdrGen/CMakeLists.txt +++ libc/utils/HdrGen/CMakeLists.txt @@ -1,6 +1,6 @@ set(LLVM_LINK_COMPONENTS Support) -add_tablegen(libc-hdrgen llvm-libc +add_tablegen(libc-hdrgen LIBC Command.h Command.cpp Generator.cpp