[libc-commits] [libc] Revert "[libc] newheadergen: configured cmake" (PR #99414)

via libc-commits libc-commits at lists.llvm.org
Wed Jul 17 17:16:52 PDT 2024


https://github.com/aaryanshukla created https://github.com/llvm/llvm-project/pull/99414

Reverts llvm/llvm-project#98828

>From 472dfe7d8af66a2a0c9d9a83ffb26b4aacff17fd Mon Sep 17 00:00:00 2001
From: aaryanshukla <53713108+aaryanshukla at users.noreply.github.com>
Date: Wed, 17 Jul 2024 17:16:43 -0700
Subject: [PATCH] Revert "[libc] newheadergen: configured cmake (#98828)"

This reverts commit 83fbd79319a4d997520c85ab41997692a58cd958.
---
 libc/CMakeLists.txt                           |   1 -
 libc/cmake/modules/LLVMLibCHeaderRules.cmake  | 101 +----
 libc/include/CMakeLists.txt                   | 380 +++++++-----------
 .../class_implementation/classes/function.py  |   2 +-
 libc/newhdrgen/header.py                      |   8 +-
 5 files changed, 160 insertions(+), 332 deletions(-)

diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index 3b8e4e6c517e9..6ba54475d0fd1 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -72,7 +72,6 @@ option(LIBC_BUILD_GPU_LOADER "Always build the GPU loader utilities" OFF)
 if(LIBC_BUILD_GPU_LOADER OR (LLVM_LIBC_GPU_BUILD AND NOT LLVM_RUNTIMES_BUILD))
   add_subdirectory(utils/gpu)
 endif()
-option(LIBC_USE_NEW_HEADER_GEN "Generate header files using new headergen instead of the old one" OFF)
 
 set(NEED_LIBC_HDRGEN FALSE)
 if(NOT LLVM_RUNTIMES_BUILD)
diff --git a/libc/cmake/modules/LLVMLibCHeaderRules.cmake b/libc/cmake/modules/LLVMLibCHeaderRules.cmake
index 91054810f5ec5..7fc6860f23eb2 100644
--- a/libc/cmake/modules/LLVMLibCHeaderRules.cmake
+++ b/libc/cmake/modules/LLVMLibCHeaderRules.cmake
@@ -66,106 +66,7 @@ function(add_header target_name)
   )
 endfunction(add_header)
 
-function(add_gen_header2 target_name)
-  cmake_parse_arguments(
-    "ADD_GEN_HDR2"
-    "PUBLIC" # No optional arguments
-    "YAML_FILE;DEF_FILE;GEN_HDR" # Single value arguments
-    "DEPENDS"     # Multi value arguments
-    ${ARGN}
-  )
-  get_fq_target_name(${target_name} fq_target_name)
-  if(NOT LLVM_LIBC_FULL_BUILD)
-    add_library(${fq_target_name} INTERFACE)
-    return()
-  endif()
-  if(NOT ADD_GEN_HDR2_DEF_FILE)
-    message(FATAL_ERROR "`add_gen_hdr2` rule requires DEF_FILE to be specified.")
-  endif()
-  if(NOT ADD_GEN_HDR2_GEN_HDR)
-    message(FATAL_ERROR "`add_gen_hdr2` rule requires GEN_HDR to be specified.")
-  endif()
-  if(NOT ADD_GEN_HDR2_YAML_FILE)
-    message(FATAL_ERROR "`add_gen_hdr2` rule requires YAML_FILE to be specified.")
-  endif()
-
-  set(absolute_path ${CMAKE_CURRENT_SOURCE_DIR}/${ADD_GEN_HDR2_GEN_HDR})
-  file(RELATIVE_PATH relative_path ${LIBC_INCLUDE_SOURCE_DIR} ${absolute_path})
-  set(out_file ${LIBC_INCLUDE_DIR}/${relative_path})
-  set(yaml_file ${CMAKE_SOURCE_DIR}/${ADD_GEN_HDR2_YAML_FILE})
-  set(def_file ${CMAKE_CURRENT_SOURCE_DIR}/${ADD_GEN_HDR2_DEF_FILE})
-
-  set(fq_data_files "")
-  if(ADD_GEN_HDR2_DATA_FILES)
-    foreach(data_file IN LISTS ADD_GEN_HDR2_DATA_FILES)
-      list(APPEND fq_data_files "${CMAKE_CURRENT_SOURCE_DIR}/${data_file}")
-    endforeach(data_file)
-  endif()
-
-  set(entry_points "${TARGET_ENTRYPOINT_NAME_LIST}")
-  list(TRANSFORM entry_points PREPEND "--e=")
-
-  add_custom_command(
-    OUTPUT ${out_file}
-    COMMAND ${Python3_EXECUTABLE} ${LIBC_SOURCE_DIR}/newhdrgen/yaml_to_classes.py
-            ${yaml_file}
-            --h_def_file ${def_file}
-            ${entry_points}
-            --output_dir ${out_file}
-    DEPENDS ${yaml_file} ${def_file} ${fq_data_files}
-    COMMENT "Generating header ${ADD_GEN_HDR2_GE2N_HDR} from ${yaml_file} and ${def_file}"
-  )
-  if(LIBC_TARGET_OS_IS_GPU)
-    file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/llvm-libc-decls)
-    file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/llvm-libc-decls/gpu)
-    set(decl_out_file ${LIBC_INCLUDE_DIR}/llvm-libc-decls/${relative_path})
-    add_custom_command(
-      OUTPUT ${decl_out_file}
-      COMMAND ${Python3_EXECUTABLE} ${LIBC_SOURCE_DIR}/newhdrgen/yaml_to_classes.py
-              ${yaml_file}
-              --export-decls
-              ${entry_points}
-              --output_dir ${decl_out_file}
-      WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-      DEPENDS ${yaml_file} ${fq_data_files}
-    )
-  endif()
-  
-  if(ADD_GEN_HDR2_DEPENDS)
-    get_fq_deps_list(fq_deps_list ${ADD_GEN_HDR2_DEPENDS})
-    # Dependencies of a add_header target can only be another add_gen_header target
-    # or an add_header target.
-    foreach(dep IN LISTS fq_deps_list)
-      get_target_property(header_file ${dep} HEADER_FILE_PATH)
-      if(NOT header_file)
-        message(FATAL_ERROR "Invalid dependency '${dep}' for '${fq_target_name}'.")
-      endif()
-    endforeach()
-  endif()
-  set(generated_hdr_target ${fq_target_name}.__generated_hdr__)
-  add_custom_target(
-    ${generated_hdr_target}
-    DEPENDS ${out_file} ${fq_deps_list} ${decl_out_file}
-  )
-
-  add_header_library(
-    ${target_name}
-    HDRS
-      ${out_file}
-  )
-
-  add_dependencies(${fq_target_name} ${generated_hdr_target})
-
-  set_target_properties(
-    ${fq_target_name}
-    PROPERTIES
-      HEADER_FILE_PATH ${out_file}
-      DEPS "${fq_deps_list}"
-  )
-
-
-endfunction(add_gen_header2)
-
+# A rule for generated header file targets.
 # Usage:
 #     add_gen_header(
 #       <target name>
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index bbc0f7abafd55..2cf7206f3a625 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -17,41 +17,18 @@ add_header(
     __llvm-libc-common.h
 )
 
-macro(add_header_macro TARGET_NAME YAML_FILE DEF_FILE GEN_HDR DEPENDS)
-  if (LIBC_USE_NEW_HEADER_GEN)
-    add_gen_header2(
-      ${TARGET_NAME}
-      YAML_FILE ${YAML_FILE}
-      DEF_FILE ${DEF_FILE}
-      GEN_HDR ${GEN_HDR}
-      ${DEPENDS}
-      ${ARGN}
-    )
-  else()
-    add_gen_header(
-      ${TARGET_NAME}
-      DEF_FILE ${DEF_FILE}
-      GEN_HDR ${GEN_HDR}
-      ${DEPENDS}
-      ${ARGN}
-    )
-  endif()
-endmacro()
-
-add_header_macro(
+add_gen_header(
   ctype
-  ../libc/newhdrgen/yaml/ctype.yaml
-  ctype.h.def
-  ctype.h
+  DEF_FILE ctype.h.def
+  GEN_HDR ctype.h
   DEPENDS
     .llvm_libc_common_h
 )
 
-add_header_macro(
+add_gen_header(
   dirent
-  ../libc/newhdrgen/yaml/dirent.yaml
-  dirent.h.def
-  dirent.h
+  DEF_FILE dirent.h.def
+  GEN_HDR dirent.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.ino_t
@@ -59,11 +36,10 @@ add_header_macro(
     .llvm-libc-types.struct_dirent
 )
 
-add_header_macro(
+add_gen_header(
   fcntl
-  ../libc/newhdrgen/yaml/fcntl.yaml
-  fcntl.h.def
-  fcntl.h
+  DEF_FILE fcntl.h.def
+  GEN_HDR fcntl.h
   DEPENDS
     .llvm-libc-macros.fcntl_macros
     .llvm-libc-types.mode_t
@@ -75,31 +51,28 @@ add_header_macro(
     .llvm_libc_common_h
 )
 
-add_header_macro(
+add_gen_header(
   dlfcn
-  ../libc/newhdrgen/yaml/dlfcn.yaml
-  dlfcn.h.def
-  dlfcn.h
+  DEF_FILE dlfcn.h.def
+  GEN_HDR dlfcn.h
   DEPENDS
     .llvm-libc-macros.dlfcn_macros
     .llvm_libc_common_h
 )
 
-add_header_macro(
+add_gen_header(
   features
-  ../libc/newhdrgen/yaml/features.yaml
-  features.h.def
-  features.h
+  DEF_FILE features.h.def
+  GEN_HDR features.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.features_macros
 )
 
-add_header_macro(
+add_gen_header(
   fenv
-  ../libc/newhdrgen/yaml/fenv.yaml
-  fenv.h.def
-  fenv.h
+  DEF_FILE fenv.h.def
+  GEN_HDR fenv.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.fenv_macros
@@ -107,63 +80,58 @@ add_header_macro(
     .llvm-libc-types.fexcept_t
 )
 
-add_header_macro(
+add_gen_header(
   inttypes
-  ../libc/newhdrgen/yaml/inttypes.yaml
-  inttypes.h.def
-  inttypes.h
+  DEF_FILE inttypes.h.def
+  GEN_HDR inttypes.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.imaxdiv_t
     .llvm-libc-macros.inttypes_macros
 )
 
-add_header_macro(
+add_gen_header(
   float
-  ../libc/newhdrgen/yaml/float.yaml
-  float.h.def
-  float.h
+  DEF_FILE float.h.def
+  GEN_HDR float.h
   DEPENDS
     .llvm-libc-macros.float_macros
 )
 
-add_header_macro(
+add_gen_header(
   stdint
-  ../libc/newhdrgen/yaml/stdint.yaml
-  stdint.h.def
-  stdint.h
+  DEF_FILE stdint.h.def
+  GEN_HDR stdint.h
   DEPENDS
     .llvm-libc-macros.stdint_macros
 )
 
-add_header_macro(
+add_gen_header(
   limits
-  ../libc/newhdrgen/yaml/limits.yaml
-  limits.h.def
-  limits.h
+  DEF_FILE limits.h.def
+  GEN_HDR limits.h
   DEPENDS
     .llvm-libc-macros.limits_macros
 )
 
-add_header_macro(
+add_gen_header(
   math
-  ../libc/newhdrgen/yaml/math.yaml
-  math.h.def
-  math.h
+  DEF_FILE math.h.def
+  GEN_HDR math.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.float16_macros
     .llvm-libc-macros.math_macros
+    .llvm-libc-macros.math_function_macros
     .llvm-libc-types.double_t
     .llvm-libc-types.float_t
     .llvm-libc-types.float128
 )
 
-add_header_macro(
+add_gen_header(
   stdfix
-  ../libc/newhdrgen/yaml/stdfix.yaml
-  stdfix.h.def
-  stdfix.h
+  DEF_FILE stdfix.h.def
+  GEN_HDR stdfix.h
   DEPENDS
     .llvm-libc-macros.stdfix_macros
 )
@@ -171,61 +139,55 @@ add_header_macro(
 # TODO: This should be conditional on POSIX networking being included.
 file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/arpa)
 
-add_header_macro(
+add_gen_header(
   arpa_inet
-  ../libc/newhdrgen/yaml/arpa_inet.yaml
-  arpa/inet.h.def
-  arpa/inet.h
+  DEF_FILE arpa/inet.h.def
+  GEN_HDR arpa/inet.h
   DEPENDS
     .llvm_libc_common_h
 )
 
-add_header_macro(
+add_gen_header(
   assert
-  ../libc/newhdrgen/yaml/assert.yaml
-  assert.h.def
-  assert.h
+  DEF_FILE assert.h.def
+  GEN_HDR assert.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.assert_macros
 )
 
-add_header_macro(
+add_gen_header(
   setjmp
-  ../libc/newhdrgen/yaml/setjmp.yaml
-  setjmp.h.def
-  setjmp.h
+  DEF_FILE setjmp.h.def
+  GEN_HDR setjmp.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.jmp_buf
 )
 
-add_header_macro(
+add_gen_header(
   string
-  ../libc/newhdrgen/yaml/string.yaml
-  string.h.def
-  string.h
+  DEF_FILE string.h.def
+  GEN_HDR string.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.null_macro
     .llvm-libc-types.size_t
 )
 
-add_header_macro(
+add_gen_header(
   strings
-  ../libc/newhdrgen/yaml/strings.yaml
-  strings.h.def
-  strings.h
+  DEF_FILE strings.h.def
+  GEN_HDR strings.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.size_t
 )
 
-add_header_macro(
+add_gen_header(
   search
-  ../libc/newhdrgen/yaml/search.yaml
-  search.h.def
-  search.h
+  DEF_FILE search.h.def
+  GEN_HDR search.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.ACTION
@@ -234,11 +196,10 @@ add_header_macro(
     .llvm-libc-types.size_t
 )
 
-add_header_macro(
+add_gen_header(
   time
-  ../libc/newhdrgen/yaml/time.yaml
-  time.h.def
-  time.h
+  DEF_FILE time.h.def
+  GEN_HDR time.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.time_macros
@@ -250,11 +211,10 @@ add_header_macro(
     .llvm-libc-types.clockid_t
 )
 
-add_header_macro(
+add_gen_header(
   threads
-  ../libc/newhdrgen/yaml/threads.yaml
-  threads.h.def
-  threads.h
+  DEF_FILE threads.h.def
+  GEN_HDR threads.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.__call_once_func_t
@@ -267,21 +227,19 @@ add_header_macro(
     .llvm-libc-types.tss_dtor_t
 )
 
-add_header_macro(
+add_gen_header(
   errno
-  ../libc/newhdrgen/yaml/errno.yaml
-  errno.h.def
-  errno.h
+  DEF_FILE errno.h.def
+  GEN_HDR errno.h
   DEPENDS
     .llvm-libc-macros.generic_error_number_macros
     .llvm-libc-macros.error_number_macros
 )
 
-add_header_macro(
+add_gen_header(
   signal
-  ../libc/newhdrgen/yaml/signal.yaml
-  signal.h.def
-  signal.h
+  DEF_FILE signal.h.def
+  GEN_HDR signal.h
   DEPENDS
     .llvm-libc-macros.signal_macros
     .llvm-libc-types.sig_atomic_t
@@ -293,31 +251,28 @@ add_header_macro(
     .llvm-libc-types.pid_t
 )
 
-add_header_macro(
+add_gen_header(
   stdbit
-  ../libc/newhdrgen/yaml/stdbit.yaml
-  stdbit.h.def
-  stdbit.h
+  DEF_FILE stdbit.h.def
+  GEN_HDR stdbit.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.stdbit_macros
 )
 
-add_header_macro(
+add_gen_header(
   stdckdint
-  ../libc/newhdrgen/yaml/stdckdint.yaml
-  stdckdint.h.def
-  stdckdint.h
+  DEF_FILE stdckdint.h.def
+  GEN_HDR stdckdint.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.stdckdint_macros
 )
 
-add_header_macro(
+add_gen_header(
   stdio
-  ../libc/newhdrgen/yaml/stdio.yaml
-  stdio.h.def
-  stdio.h
+  DEF_FILE stdio.h.def
+  GEN_HDR stdio.h
   DEPENDS
     .llvm-libc-macros.file_seek_macros
     .llvm-libc-macros.stdio_macros
@@ -329,11 +284,10 @@ add_header_macro(
     .llvm_libc_common_h
 )
 
-add_header_macro(
+add_gen_header(
   stdlib
-  ../libc/newhdrgen/yaml/stdlib.yaml
-  stdlib.h.def
-  stdlib.h
+  DEF_FILE stdlib.h.def
+  GEN_HDR stdlib.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.stdlib_macros
@@ -347,11 +301,10 @@ add_header_macro(
     .llvm-libc-types.__atexithandler_t
 )
 
-add_header_macro(
+add_gen_header(
   unistd
-  ../libc/newhdrgen/yaml/unistd.yaml
-  unistd.h.def
-  unistd.h
+  DEF_FILE unistd.h.def
+  GEN_HDR unistd.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.file_seek_macros
@@ -366,11 +319,10 @@ add_header_macro(
     .llvm-libc-types.__getoptargv_t
 )
 
-add_header_macro(
+add_gen_header(
   pthread
-  ../libc/newhdrgen/yaml/pthread.yaml
-  pthread.h.def
-  pthread.h
+  DEF_FILE pthread.h.def
+  GEN_HDR pthread.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.__atfork_callback_t
@@ -388,11 +340,10 @@ add_header_macro(
     .llvm-libc-types.pthread_t
 )
 
-add_header_macro(
+add_gen_header(
   sched
-  ../libc/newhdrgen/yaml/sched.yaml
-  sched.h.def
-  sched.h
+  DEF_FILE sched.h.def
+  GEN_HDR sched.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.sched_macros
@@ -405,11 +356,10 @@ add_header_macro(
     .llvm-libc-types.struct_timespec
 )
 
-add_header_macro(
+add_gen_header(
   spawn
-  ../libc/newhdrgen/yaml/spawn.yaml
-  spawn.h.def
-  spawn.h
+  DEF_FILE spawn.h.def
+  GEN_HDR spawn.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.mode_t
@@ -423,21 +373,19 @@ add_header_macro(
 # them.
 file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/sys)
 
-add_header_macro(
+add_gen_header(
   sys_auxv
-  ../libc/newhdrgen/yaml/sys/sys_auxv.yaml
-  sys/auxv.h.def
-  sys/auxv.h
+  DEF_FILE sys/auxv.h.def
+  GEN_HDR sys/auxv.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.sys_auxv_macros
 )
 
-add_header_macro(
+add_gen_header(
   sys_epoll
-  ../libc/newhdrgen/yaml/sys/sys_epoll.yaml
-  sys/epoll.h.def
-  sys/epoll.h
+  DEF_FILE sys/epoll.h.def
+  GEN_HDR sys/epoll.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.struct_epoll_event
@@ -446,21 +394,19 @@ add_header_macro(
     .llvm-libc-macros.sys_epoll_macros
 )
 
-add_header_macro(
+add_gen_header(
   sys_ioctl
-  ../libc/newhdrgen/yaml/sys/sys_ioctl.yaml
-  sys/ioctl.h.def
-  sys/ioctl.h
+  DEF_FILE sys/ioctl.h.def
+  GEN_HDR sys/ioctl.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.sys_ioctl_macros
 )
 
-add_header_macro(
+add_gen_header(
   sys_mman
-  ../libc/newhdrgen/yaml/sys/sys_mman.yaml
-  sys/mman.h.def
-  sys/mman.h
+  DEF_FILE sys/mman.h.def
+  GEN_HDR sys/mman.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.sys_mman_macros
@@ -469,11 +415,10 @@ add_header_macro(
     .llvm-libc-types.ssize_t
 )
 
-add_header_macro(
+add_gen_header(
   sys_prctl
-  ../libc/newhdrgen/yaml/sys/sys_prctl.yaml
-  sys/prctl.h.def
-  sys/prctl.h
+  DEF_FILE sys/prctl.h.def
+  GEN_HDR sys/prctl.h
   DEPENDS
     .llvm_libc_common_h
 )
@@ -486,11 +431,10 @@ add_header(
     .llvm-libc-macros.sys_queue_macros
 )
 
-add_header_macro(
+add_gen_header(
   sys_random
-  ../libc/newhdrgen/yaml/sys/sys_random.yaml
-  sys/random.h.def
-  sys/random.h
+  DEF_FILE sys/random.h.def
+  GEN_HDR sys/random.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.sys_random_macros
@@ -498,11 +442,10 @@ add_header_macro(
     .llvm-libc-types.ssize_t
 )
 
-add_header_macro(
+add_gen_header(
   sys_resource
-  ../libc/newhdrgen/yaml/sys/sys_resource.yaml
-  sys/resource.h.def
-  sys/resource.h
+  DEF_FILE sys/resource.h.def
+  GEN_HDR sys/resource.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.sys_resource_macros
@@ -510,11 +453,10 @@ add_header_macro(
     .llvm-libc-types.struct_rlimit
 )
 
-add_header_macro(
+add_gen_header(
   sys_stat
-  ../libc/newhdrgen/yaml/sys/sys_stat.yaml
-  sys/stat.h.def
-  sys/stat.h
+  DEF_FILE sys/stat.h.def
+  GEN_HDR sys/stat.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.sys_stat_macros
@@ -532,11 +474,10 @@ add_header_macro(
     .llvm-libc-types.struct_stat
 )
 
-add_header_macro(
+add_gen_header(
   sys_select
-  ../libc/newhdrgen/yaml/sys/sys_select.yaml
-  sys/select.h.def
-  sys/select.h
+  DEF_FILE sys/select.h.def
+  GEN_HDR sys/select.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.sys_select_macros
@@ -548,11 +489,10 @@ add_header_macro(
     .llvm-libc-types.struct_timeval
 )
 
-add_header_macro(
+add_gen_header(
   sys_sendfile
-  ../libc/newhdrgen/yaml/sys/sys_sendfile.yaml
-  sys/sendfile.h.def
-  sys/sendfile.h
+  DEF_FILE sys/sendfile.h.def
+  GEN_HDR sys/sendfile.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.off_t
@@ -560,11 +500,10 @@ add_header_macro(
     .llvm-libc-types.ssize_t
 )
 
-add_header_macro(
+add_gen_header(
   sys_socket
-  ../libc/newhdrgen/yaml/sys/sys_socket.yaml
-  sys/socket.h.def
-  sys/socket.h
+  DEF_FILE sys/socket.h.def
+  GEN_HDR sys/socket.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.sys_socket_macros
@@ -574,40 +513,35 @@ add_header_macro(
     .llvm-libc-types.struct_sockaddr_un
 )
 
-add_header_macro(
+add_gen_header(
   sys_statvfs
-  ../libc/newhdrgen/yaml/sys/sys_statvfs.yaml
-  sys/statvfs.h.def
-  sys/statvfs.h
+  DEF_FILE sys/statvfs.h.def
+  GEN_HDR sys/statvfs.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.struct_statvfs
 )
 
-add_header_macro(
+add_gen_header(
   sys_syscall
-  ../libc/newhdrgen/yaml/sys/sys_syscall.yaml
-  sys/syscall.h.def
-  sys/syscall.h
-  DEPENDS
+  DEF_FILE sys/syscall.h.def
+  GEN_HDR sys/syscall.h
 )
 
-add_header_macro(
+add_gen_header(
   sys_time
-  ../libc/newhdrgen/yaml/sys/sys_time.yaml
-  sys/time.h.def
-  sys/time.h
+  DEF_FILE sys/time.h.def
+  GEN_HDR sys/time.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.struct_timeval
     .llvm-libc-macros.sys_time_macros
 )
 
-add_header_macro(
+add_gen_header(
   sys_types
-  ../libc/newhdrgen/yaml/sys/sys_types.yaml
-  sys/types.h.def
-  sys/types.h
+  DEF_FILE sys/types.h.def
+  GEN_HDR sys/types.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.blkcnt_t
@@ -633,21 +567,19 @@ add_header_macro(
     .llvm-libc-types.uid_t
 )
 
-add_header_macro(
+add_gen_header(
   sys_utsname
-  ../libc/newhdrgen/yaml/sys/sys_utsname.yaml
-  sys/utsname.h.def
-  sys/utsname.h
+  DEF_FILE sys/utsname.h.def
+  GEN_HDR sys/utsname.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.struct_utsname
 )
 
-add_header_macro(
+add_gen_header(
   sys_wait
-  ../libc/newhdrgen/yaml/sys/sys_wait.yaml
-  sys/wait.h.def
-  sys/wait.h
+  DEF_FILE sys/wait.h.def
+  GEN_HDR sys/wait.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.sys_wait_macros
@@ -656,11 +588,10 @@ add_header_macro(
     .llvm-libc-types.siginfo_t
 )
 
-add_header_macro(
+add_gen_header(
   termios
-  ../libc/newhdrgen/yaml/termios.yaml
-  termios.h.def
-  termios.h
+  DEF_FILE termios.h.def
+  GEN_HDR termios.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.termios_macros
@@ -671,11 +602,10 @@ add_header_macro(
     .llvm-libc-types.tcflag_t
 )
 
-add_header_macro(
+add_gen_header(
   uchar
-  ../libc/newhdrgen/yaml/uchar.yaml
-  uchar.h.def
-  uchar.h
+  DEF_FILE uchar.h.def
+  GEN_HDR uchar.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.mbstate_t
@@ -684,11 +614,10 @@ add_header_macro(
     .llvm-libc-types.char32_t
 )
 
-add_header_macro(
+add_gen_header(
   wchar
-  ../libc/newhdrgen/yaml/wchar.yaml
-  wchar.h.def
-  wchar.h
+  DEF_FILE wchar.h.def
+  GEN_HDR wchar.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.wchar_macros
@@ -701,11 +630,10 @@ add_header_macro(
 if(LIBC_TARGET_OS_IS_GPU)
   file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/gpu)
 
-  add_header_macro(
+  add_gen_header(
     gpu_rpc
-    ../libc/newhdrgen/yaml/rpc.yaml
-    gpu/rpc.h.def
-    gpu/rpc.h
+    DEF_FILE gpu/rpc.h.def
+    GEN_HDR gpu/rpc.h
     DEPENDS
       .llvm_libc_common_h
       .llvm-libc-types.rpc_opcodes_t
diff --git a/libc/newhdrgen/class_implementation/classes/function.py b/libc/newhdrgen/class_implementation/classes/function.py
index 845ef1aebf54b..ccfd93547c1d8 100644
--- a/libc/newhdrgen/class_implementation/classes/function.py
+++ b/libc/newhdrgen/class_implementation/classes/function.py
@@ -26,7 +26,7 @@ def __str__(self):
         attributes_str = " ".join(self.attributes)
         arguments_str = ", ".join(self.arguments)
         if attributes_str == "":
-            result = f"{self.return_type} {self.name}({arguments_str})"
+            result = f"{self.return_type} {self.name}({arguments_str});"
         else:
             result = f"{attributes_str} {self.return_type} {self.name}({arguments_str})"
         return result
diff --git a/libc/newhdrgen/header.py b/libc/newhdrgen/header.py
index d1f0fe96dbc60..69de81eebb719 100644
--- a/libc/newhdrgen/header.py
+++ b/libc/newhdrgen/header.py
@@ -60,16 +60,16 @@ def __str__(self):
         current_guard = None
         for function in self.functions:
             if function.guard == None:
-                content.append(str(function) + "__NOEXCEPT;")
+                content.append(str(function) + "__NOEXCEPT")
                 content.append("")
             else:
                 if current_guard == None:
                     current_guard = function.guard
                     content.append(f"#ifdef {current_guard}")
-                    content.append(str(function) + "__NOEXCEPT;")
+                    content.append(str(function) + "__NOEXCEPT")
                     content.append("")
                 elif current_guard == function.guard:
-                    content.append(str(function) + "__NOEXCEPT;")
+                    content.append(str(function) + "__NOEXCEPT")
                     content.append("")
                 else:
                     content.pop()
@@ -77,7 +77,7 @@ def __str__(self):
                     content.append("")
                     current_guard = function.guard
                     content.append(f"#ifdef {current_guard}")
-                    content.append(str(function) + "__NOEXCEPT;")
+                    content.append(str(function) + "__NOEXCEPT")
                     content.append("")
         if current_guard != None:
             content.pop()



More information about the libc-commits mailing list