Skip to content

Commit f668708

Browse files
[libc] Disable old headergen checks unless enabled (#104522)
Old Headergen needed extra build rules to ensure that it worked in runtimes mode. This patch disables those checks if new headergen is enabled. Also some new headers were not being properly built with new headergen, and that's also fixed.
1 parent ab5102d commit f668708

File tree

3 files changed

+27
-23
lines changed

3 files changed

+27
-23
lines changed

libc/CMakeLists.txt

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,31 +50,32 @@ set(LIBC_NAMESPACE ${default_namespace}
5050
CACHE STRING "The namespace to use to enclose internal implementations. Must start with '__llvm_libc'."
5151
)
5252

53+
option(LIBC_USE_NEW_HEADER_GEN "Generate header files using new headergen instead of the old one" ON)
5354

54-
add_subdirectory(newhdrgen)
55-
56-
57-
if(LLVM_LIBC_FULL_BUILD OR LLVM_LIBC_GPU_BUILD)
58-
if(NOT LIBC_HDRGEN_EXE)
59-
# We need to set up hdrgen first since other targets depend on it.
60-
add_subdirectory(utils/LibcTableGenUtil)
61-
add_subdirectory(utils/HdrGen)
62-
# Calling add_tablegen sets variables like LIBC_TABLEGEN_EXE in
63-
# PARENT_SCOPE which get lost until saved in the cache.
64-
set(LIBC_TABLEGEN_EXE "${LIBC_TABLEGEN_EXE}" CACHE INTERNAL "")
65-
set(LIBC_TABLEGEN_TARGET "${LIBC_TABLEGEN_TARGET}" CACHE INTERNAL "")
66-
else()
67-
message(STATUS "Will use ${LIBC_HDRGEN_EXE} for libc header generation.")
55+
if(LIBC_USE_NEW_HEADER_GEN)
56+
add_subdirectory(newhdrgen)
57+
else()
58+
if(LLVM_LIBC_FULL_BUILD OR LLVM_LIBC_GPU_BUILD)
59+
if(NOT LIBC_HDRGEN_EXE)
60+
# We need to set up hdrgen first since other targets depend on it.
61+
add_subdirectory(utils/LibcTableGenUtil)
62+
add_subdirectory(utils/HdrGen)
63+
# Calling add_tablegen sets variables like LIBC_TABLEGEN_EXE in
64+
# PARENT_SCOPE which get lost until saved in the cache.
65+
set(LIBC_TABLEGEN_EXE "${LIBC_TABLEGEN_EXE}" CACHE INTERNAL "")
66+
set(LIBC_TABLEGEN_TARGET "${LIBC_TABLEGEN_TARGET}" CACHE INTERNAL "")
67+
else()
68+
message(STATUS "Will use ${LIBC_HDRGEN_EXE} for libc header generation.")
69+
endif()
6870
endif()
6971
endif()
72+
7073
# We will build the GPU utilities if we are not doing a runtimes build.
7174
option(LIBC_BUILD_GPU_LOADER "Always build the GPU loader utilities" OFF)
7275
if(LIBC_BUILD_GPU_LOADER OR (LLVM_LIBC_GPU_BUILD AND NOT LLVM_RUNTIMES_BUILD))
7376
add_subdirectory(utils/gpu)
7477
endif()
7578

76-
option(LIBC_USE_NEW_HEADER_GEN "Generate header files using new headergen instead of the old one" ON)
77-
7879
set(NEED_LIBC_HDRGEN FALSE)
7980
if(NOT LLVM_RUNTIMES_BUILD)
8081
if("libc" IN_LIST LLVM_ENABLE_RUNTIMES)

libc/include/CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -420,19 +420,21 @@ add_header_macro(
420420
.llvm-libc-types.posix_spawn_file_actions_t
421421
)
422422

423-
add_gen_header(
423+
add_header_macro(
424424
link
425-
DEF_FILE link.h.def
426-
GEN_HDR link.h
425+
../libc/newhdrgen/yaml/link.yaml
426+
link.h.def
427+
link.h
427428
DEPENDS
428429
.llvm_libc_common_h
429430
.llvm-libc-macros.link_macros
430431
)
431432

432-
add_gen_header(
433+
add_header_macro(
433434
elf
434-
DEF_FILE elf.h.def
435-
GEN_HDR elf.h
435+
../libc/newhdrgen/yaml/elf.yaml
436+
elf.h.def
437+
elf.h
436438
DEPENDS
437439
.llvm-libc-macros.elf_macros
438440
)

llvm/runtimes/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,8 @@ if(build_runtimes)
521521
endforeach()
522522
endif()
523523
if("libc" IN_LIST LLVM_ENABLE_PROJECTS AND
524-
(LLVM_LIBC_FULL_BUILD OR LLVM_LIBC_GPU_BUILD))
524+
(LLVM_LIBC_FULL_BUILD OR LLVM_LIBC_GPU_BUILD) AND
525+
(NOT LIBC_USE_NEW_HEADER_GEN))
525526
if(LIBC_HDRGEN_EXE)
526527
set(hdrgen_exe ${LIBC_HDRGEN_EXE})
527528
else()

0 commit comments

Comments
 (0)