aboutsummaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorPetr Hosek <phosek@google.com>2021-01-21 22:55:12 -0800
committerPetr Hosek <phosek@google.com>2021-01-28 13:13:06 -0800
commit1daaa6432e844404006aca55358e0500928d65fb (patch)
tree68aa569ae7e8e5716b72c51259a0f8cce77c2230 /libc
parent[CMake][libc] Don't do CPU feature detection when cross-compiling (diff)
downloadllvm-project-1daaa6432e844404006aca55358e0500928d65fb.tar.gz
llvm-project-1daaa6432e844404006aca55358e0500928d65fb.tar.bz2
llvm-project-1daaa6432e844404006aca55358e0500928d65fb.zip
[CMake][libc] Support cross-compiling libc-hdrgen
This is useful when cross-compiling libc to another target in which case we first need to compile libc-hdrgen for host. We rely on the existing LLVM CMake infrastructure for that. Differential Revision: https://reviews.llvm.org/D95205
Diffstat (limited to 'libc')
-rw-r--r--libc/CMakeLists.txt6
-rw-r--r--libc/cmake/modules/LLVMLibCHeaderRules.cmake5
-rw-r--r--libc/utils/CMakeLists.txt2
-rw-r--r--libc/utils/HdrGen/CMakeLists.txt2
4 files changed, 9 insertions, 6 deletions
diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index a7600980c979..be22fb6c9a66 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -40,7 +40,7 @@ else()
--print-resource-dir not supported by host compiler")
endif()
-option(LLVM_LIBC_ENABLE_LINTING "Enables linting of libc source files" ON)
+option(LLVM_LIBC_ENABLE_LINTING "Enables linting of libc source files" OFF)
if(LLVM_LIBC_ENABLE_LINTING)
if("clang-tools-extra" IN_LIST LLVM_ENABLE_PROJECTS
AND "clang" IN_LIST LLVM_ENABLE_PROJECTS)
@@ -81,6 +81,10 @@ foreach(entrypoint IN LISTS TARGET_LIBC_ENTRYPOINTS TARGET_LIBM_ENTRYPOINTS)
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)
diff --git a/libc/cmake/modules/LLVMLibCHeaderRules.cmake b/libc/cmake/modules/LLVMLibCHeaderRules.cmake
index c01cf25b199e..ab1f6fe161bd 100644
--- a/libc/cmake/modules/LLVMLibCHeaderRules.cmake
+++ b/libc/cmake/modules/LLVMLibCHeaderRules.cmake
@@ -89,14 +89,15 @@ function(add_gen_header target_name)
add_custom_command(
OUTPUT ${out_file}
- COMMAND $<TARGET_FILE:libc-hdrgen> -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)
diff --git a/libc/utils/CMakeLists.txt b/libc/utils/CMakeLists.txt
index a55182065d20..dfee2646b9b1 100644
--- a/libc/utils/CMakeLists.txt
+++ b/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)
diff --git a/libc/utils/HdrGen/CMakeLists.txt b/libc/utils/HdrGen/CMakeLists.txt
index 8aaaa965acbf..75192a057af4 100644
--- a/libc/utils/HdrGen/CMakeLists.txt
+++ b/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