Skip to content

Commit 3cbf6d0

Browse files
[libc] delete hdrgen
Thanks to the effort of @RoseZhang03 and @aaryanshukla under the guidance of @michaelrj-google and @amykhuang, we now have newhdrgen and no longer have a dependency on TableGen and thus LLVM in order to start bootstrapping a full build. This PR: - Removes being able to set `LIBC_HDRGEN_EXE`. - LIBC_HDRGEN_EXE; the in tree newhdrgen is the only hdrgen that can be used. - LIBC_USE_NEW_HEADER_GEN; newhdrgen is the default and only option. - LIBC_HDRGEN_ONLY; there is no need to have a distinct build step for old hdrgen. - libc-api-test and libc-api-test-tidy build targets. - Deletes all .td files. It does not rename newhdrgen to just hdrgen. Will follow up with a distinct PR for that. Link: #117209 Fixes: #117208
1 parent 8663b87 commit 3cbf6d0

36 files changed

+13
-6747
lines changed

libc/CMakeLists.txt

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,27 +54,12 @@ set(LIBC_NAMESPACE ${default_namespace}
5454
add_subdirectory(newhdrgen)
5555

5656

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.")
68-
endif()
69-
endif()
7057
# We will build the GPU utilities if we are not doing a runtimes build.
7158
option(LIBC_BUILD_GPU_LOADER "Always build the GPU loader utilities" OFF)
7259
if(LIBC_BUILD_GPU_LOADER OR (LLVM_LIBC_GPU_BUILD AND NOT LLVM_RUNTIMES_BUILD))
7360
add_subdirectory(utils/gpu)
7461
endif()
7562

76-
option(LIBC_USE_NEW_HEADER_GEN "Generate header files using new headergen instead of the old one" ON)
77-
7863
set(NEED_LIBC_HDRGEN FALSE)
7964
if(NOT LLVM_RUNTIMES_BUILD)
8065
if("libc" IN_LIST LLVM_ENABLE_RUNTIMES)
@@ -88,8 +73,7 @@ if(NOT LLVM_RUNTIMES_BUILD)
8873
endforeach()
8974
endif()
9075
endif()
91-
option(LIBC_HDRGEN_ONLY "Only build the 'libc-hdrgen' executable" OFF)
92-
if(LIBC_HDRGEN_ONLY OR NEED_LIBC_HDRGEN)
76+
if(NEED_LIBC_HDRGEN)
9377
# When libc is build as part of the runtimes/bootstrap build's CMake run, we
9478
# only need to build the host tools to build the libc. So, we just do enough
9579
# to build libc-hdrgen and return.

libc/cmake/modules/LLVMLibCHeaderRules.cmake

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -220,46 +220,13 @@ function(add_gen_header target_name)
220220

221221
set(gen_hdr_script "${LIBC_BUILD_SCRIPTS_DIR}/gen_hdr.py")
222222

223-
file(GLOB td_includes ${LIBC_SOURCE_DIR}/spec/*.td)
224-
225223
set(ENTRYPOINT_NAME_LIST_ARG ${TARGET_ENTRYPOINT_NAME_LIST})
226224
list(TRANSFORM ENTRYPOINT_NAME_LIST_ARG PREPEND "--e=")
227225

228-
if(LIBC_HDRGEN_EXE)
229-
set(hdrgen_exe ${LIBC_HDRGEN_EXE})
230-
else()
231-
set(hdrgen_exe ${LIBC_TABLEGEN_EXE})
232-
set(hdrgen_deps "${LIBC_TABLEGEN_EXE};${LIBC_TABLEGEN_TARGET}")
233-
endif()
234-
add_custom_command(
235-
OUTPUT ${out_file}
236-
COMMAND ${hdrgen_exe} -o ${out_file} --header ${ADD_GEN_HDR_GEN_HDR}
237-
--def ${in_file} ${replacement_params} -I ${LIBC_SOURCE_DIR}
238-
${ENTRYPOINT_NAME_LIST_ARG}
239-
${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td
240-
241-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
242-
DEPENDS ${in_file} ${fq_data_files} ${td_includes}
243-
${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td
244-
${hdrgen_deps}
245-
)
246-
247226
if(LIBC_TARGET_OS_IS_GPU)
248227
file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/llvm-libc-decls)
249228
file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/llvm-libc-decls/gpu)
250229
set(decl_out_file ${LIBC_INCLUDE_DIR}/llvm-libc-decls/${relative_path})
251-
add_custom_command(
252-
OUTPUT ${decl_out_file}
253-
COMMAND ${hdrgen_exe} -o ${decl_out_file}
254-
--header ${ADD_GEN_HDR_GEN_HDR} --def ${in_file} --export-decls
255-
${replacement_params} -I ${LIBC_SOURCE_DIR} ${ENTRYPOINT_NAME_LIST_ARG}
256-
${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td
257-
258-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
259-
DEPENDS ${in_file} ${fq_data_files} ${td_includes}
260-
${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td
261-
${hdrgen_deps}
262-
)
263230
endif()
264231

265232
if(ADD_GEN_HDR_DEPENDS)

libc/config/baremetal/api.td

Lines changed: 0 additions & 59 deletions
This file was deleted.

libc/config/gpu/api.td

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)