[libc-commits] [libc] 83fbd79 - [libc] newheadergen: configured cmake (#98828)

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


Author: aaryanshukla
Date: 2024-07-17T16:23:15-07:00
New Revision: 83fbd79319a4d997520c85ab41997692a58cd958

URL: https://github.com/llvm/llvm-project/commit/83fbd79319a4d997520c85ab41997692a58cd958
DIFF: https://github.com/llvm/llvm-project/commit/83fbd79319a4d997520c85ab41997692a58cd958.diff

LOG: [libc] newheadergen: configured cmake (#98828)

- all headers in the build system are generated by newheadergen
- tested on gpu-build

---------

Co-authored-by: Rose Zhang <rosezhang at google.com>

Added: 
    

Modified: 
    libc/CMakeLists.txt
    libc/cmake/modules/LLVMLibCHeaderRules.cmake
    libc/include/CMakeLists.txt
    libc/newhdrgen/class_implementation/classes/function.py
    libc/newhdrgen/header.py

Removed: 
    


################################################################################
diff  --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index 6ba54475d0fd1..3b8e4e6c517e9 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -72,6 +72,7 @@ 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 7fc6860f23eb2..91054810f5ec5 100644
--- a/libc/cmake/modules/LLVMLibCHeaderRules.cmake
+++ b/libc/cmake/modules/LLVMLibCHeaderRules.cmake
@@ -66,7 +66,106 @@ function(add_header target_name)
   )
 endfunction(add_header)
 
-# A rule for generated header file targets.
+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)
+
 # Usage:
 #     add_gen_header(
 #       <target name>

diff  --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 2cf7206f3a625..bbc0f7abafd55 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -17,18 +17,41 @@ add_header(
     __llvm-libc-common.h
 )
 
-add_gen_header(
+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(
   ctype
-  DEF_FILE ctype.h.def
-  GEN_HDR ctype.h
+  ../libc/newhdrgen/yaml/ctype.yaml
+  ctype.h.def
+  ctype.h
   DEPENDS
     .llvm_libc_common_h
 )
 
-add_gen_header(
+add_header_macro(
   dirent
-  DEF_FILE dirent.h.def
-  GEN_HDR dirent.h
+  ../libc/newhdrgen/yaml/dirent.yaml
+  dirent.h.def
+  dirent.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.ino_t
@@ -36,10 +59,11 @@ add_gen_header(
     .llvm-libc-types.struct_dirent
 )
 
-add_gen_header(
+add_header_macro(
   fcntl
-  DEF_FILE fcntl.h.def
-  GEN_HDR fcntl.h
+  ../libc/newhdrgen/yaml/fcntl.yaml
+  fcntl.h.def
+  fcntl.h
   DEPENDS
     .llvm-libc-macros.fcntl_macros
     .llvm-libc-types.mode_t
@@ -51,28 +75,31 @@ add_gen_header(
     .llvm_libc_common_h
 )
 
-add_gen_header(
+add_header_macro(
   dlfcn
-  DEF_FILE dlfcn.h.def
-  GEN_HDR dlfcn.h
+  ../libc/newhdrgen/yaml/dlfcn.yaml
+  dlfcn.h.def
+  dlfcn.h
   DEPENDS
     .llvm-libc-macros.dlfcn_macros
     .llvm_libc_common_h
 )
 
-add_gen_header(
+add_header_macro(
   features
-  DEF_FILE features.h.def
-  GEN_HDR features.h
+  ../libc/newhdrgen/yaml/features.yaml
+  features.h.def
+  features.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.features_macros
 )
 
-add_gen_header(
+add_header_macro(
   fenv
-  DEF_FILE fenv.h.def
-  GEN_HDR fenv.h
+  ../libc/newhdrgen/yaml/fenv.yaml
+  fenv.h.def
+  fenv.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.fenv_macros
@@ -80,58 +107,63 @@ add_gen_header(
     .llvm-libc-types.fexcept_t
 )
 
-add_gen_header(
+add_header_macro(
   inttypes
-  DEF_FILE inttypes.h.def
-  GEN_HDR inttypes.h
+  ../libc/newhdrgen/yaml/inttypes.yaml
+  inttypes.h.def
+  inttypes.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.imaxdiv_t
     .llvm-libc-macros.inttypes_macros
 )
 
-add_gen_header(
+add_header_macro(
   float
-  DEF_FILE float.h.def
-  GEN_HDR float.h
+  ../libc/newhdrgen/yaml/float.yaml
+  float.h.def
+  float.h
   DEPENDS
     .llvm-libc-macros.float_macros
 )
 
-add_gen_header(
+add_header_macro(
   stdint
-  DEF_FILE stdint.h.def
-  GEN_HDR stdint.h
+  ../libc/newhdrgen/yaml/stdint.yaml
+  stdint.h.def
+  stdint.h
   DEPENDS
     .llvm-libc-macros.stdint_macros
 )
 
-add_gen_header(
+add_header_macro(
   limits
-  DEF_FILE limits.h.def
-  GEN_HDR limits.h
+  ../libc/newhdrgen/yaml/limits.yaml
+  limits.h.def
+  limits.h
   DEPENDS
     .llvm-libc-macros.limits_macros
 )
 
-add_gen_header(
+add_header_macro(
   math
-  DEF_FILE math.h.def
-  GEN_HDR math.h
+  ../libc/newhdrgen/yaml/math.yaml
+  math.h.def
+  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_gen_header(
+add_header_macro(
   stdfix
-  DEF_FILE stdfix.h.def
-  GEN_HDR stdfix.h
+  ../libc/newhdrgen/yaml/stdfix.yaml
+  stdfix.h.def
+  stdfix.h
   DEPENDS
     .llvm-libc-macros.stdfix_macros
 )
@@ -139,55 +171,61 @@ add_gen_header(
 # TODO: This should be conditional on POSIX networking being included.
 file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/arpa)
 
-add_gen_header(
+add_header_macro(
   arpa_inet
-  DEF_FILE arpa/inet.h.def
-  GEN_HDR arpa/inet.h
+  ../libc/newhdrgen/yaml/arpa_inet.yaml
+  arpa/inet.h.def
+  arpa/inet.h
   DEPENDS
     .llvm_libc_common_h
 )
 
-add_gen_header(
+add_header_macro(
   assert
-  DEF_FILE assert.h.def
-  GEN_HDR assert.h
+  ../libc/newhdrgen/yaml/assert.yaml
+  assert.h.def
+  assert.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.assert_macros
 )
 
-add_gen_header(
+add_header_macro(
   setjmp
-  DEF_FILE setjmp.h.def
-  GEN_HDR setjmp.h
+  ../libc/newhdrgen/yaml/setjmp.yaml
+  setjmp.h.def
+  setjmp.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.jmp_buf
 )
 
-add_gen_header(
+add_header_macro(
   string
-  DEF_FILE string.h.def
-  GEN_HDR string.h
+  ../libc/newhdrgen/yaml/string.yaml
+  string.h.def
+  string.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.null_macro
     .llvm-libc-types.size_t
 )
 
-add_gen_header(
+add_header_macro(
   strings
-  DEF_FILE strings.h.def
-  GEN_HDR strings.h
+  ../libc/newhdrgen/yaml/strings.yaml
+  strings.h.def
+  strings.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.size_t
 )
 
-add_gen_header(
+add_header_macro(
   search
-  DEF_FILE search.h.def
-  GEN_HDR search.h
+  ../libc/newhdrgen/yaml/search.yaml
+  search.h.def
+  search.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.ACTION
@@ -196,10 +234,11 @@ add_gen_header(
     .llvm-libc-types.size_t
 )
 
-add_gen_header(
+add_header_macro(
   time
-  DEF_FILE time.h.def
-  GEN_HDR time.h
+  ../libc/newhdrgen/yaml/time.yaml
+  time.h.def
+  time.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.time_macros
@@ -211,10 +250,11 @@ add_gen_header(
     .llvm-libc-types.clockid_t
 )
 
-add_gen_header(
+add_header_macro(
   threads
-  DEF_FILE threads.h.def
-  GEN_HDR threads.h
+  ../libc/newhdrgen/yaml/threads.yaml
+  threads.h.def
+  threads.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.__call_once_func_t
@@ -227,19 +267,21 @@ add_gen_header(
     .llvm-libc-types.tss_dtor_t
 )
 
-add_gen_header(
+add_header_macro(
   errno
-  DEF_FILE errno.h.def
-  GEN_HDR errno.h
+  ../libc/newhdrgen/yaml/errno.yaml
+  errno.h.def
+  errno.h
   DEPENDS
     .llvm-libc-macros.generic_error_number_macros
     .llvm-libc-macros.error_number_macros
 )
 
-add_gen_header(
+add_header_macro(
   signal
-  DEF_FILE signal.h.def
-  GEN_HDR signal.h
+  ../libc/newhdrgen/yaml/signal.yaml
+  signal.h.def
+  signal.h
   DEPENDS
     .llvm-libc-macros.signal_macros
     .llvm-libc-types.sig_atomic_t
@@ -251,28 +293,31 @@ add_gen_header(
     .llvm-libc-types.pid_t
 )
 
-add_gen_header(
+add_header_macro(
   stdbit
-  DEF_FILE stdbit.h.def
-  GEN_HDR stdbit.h
+  ../libc/newhdrgen/yaml/stdbit.yaml
+  stdbit.h.def
+  stdbit.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.stdbit_macros
 )
 
-add_gen_header(
+add_header_macro(
   stdckdint
-  DEF_FILE stdckdint.h.def
-  GEN_HDR stdckdint.h
+  ../libc/newhdrgen/yaml/stdckdint.yaml
+  stdckdint.h.def
+  stdckdint.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.stdckdint_macros
 )
 
-add_gen_header(
+add_header_macro(
   stdio
-  DEF_FILE stdio.h.def
-  GEN_HDR stdio.h
+  ../libc/newhdrgen/yaml/stdio.yaml
+  stdio.h.def
+  stdio.h
   DEPENDS
     .llvm-libc-macros.file_seek_macros
     .llvm-libc-macros.stdio_macros
@@ -284,10 +329,11 @@ add_gen_header(
     .llvm_libc_common_h
 )
 
-add_gen_header(
+add_header_macro(
   stdlib
-  DEF_FILE stdlib.h.def
-  GEN_HDR stdlib.h
+  ../libc/newhdrgen/yaml/stdlib.yaml
+  stdlib.h.def
+  stdlib.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.stdlib_macros
@@ -301,10 +347,11 @@ add_gen_header(
     .llvm-libc-types.__atexithandler_t
 )
 
-add_gen_header(
+add_header_macro(
   unistd
-  DEF_FILE unistd.h.def
-  GEN_HDR unistd.h
+  ../libc/newhdrgen/yaml/unistd.yaml
+  unistd.h.def
+  unistd.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.file_seek_macros
@@ -319,10 +366,11 @@ add_gen_header(
     .llvm-libc-types.__getoptargv_t
 )
 
-add_gen_header(
+add_header_macro(
   pthread
-  DEF_FILE pthread.h.def
-  GEN_HDR pthread.h
+  ../libc/newhdrgen/yaml/pthread.yaml
+  pthread.h.def
+  pthread.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.__atfork_callback_t
@@ -340,10 +388,11 @@ add_gen_header(
     .llvm-libc-types.pthread_t
 )
 
-add_gen_header(
+add_header_macro(
   sched
-  DEF_FILE sched.h.def
-  GEN_HDR sched.h
+  ../libc/newhdrgen/yaml/sched.yaml
+  sched.h.def
+  sched.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.sched_macros
@@ -356,10 +405,11 @@ add_gen_header(
     .llvm-libc-types.struct_timespec
 )
 
-add_gen_header(
+add_header_macro(
   spawn
-  DEF_FILE spawn.h.def
-  GEN_HDR spawn.h
+  ../libc/newhdrgen/yaml/spawn.yaml
+  spawn.h.def
+  spawn.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.mode_t
@@ -373,19 +423,21 @@ add_gen_header(
 # them.
 file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/sys)
 
-add_gen_header(
+add_header_macro(
   sys_auxv
-  DEF_FILE sys/auxv.h.def
-  GEN_HDR sys/auxv.h
+  ../libc/newhdrgen/yaml/sys/sys_auxv.yaml
+  sys/auxv.h.def
+  sys/auxv.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.sys_auxv_macros
 )
 
-add_gen_header(
+add_header_macro(
   sys_epoll
-  DEF_FILE sys/epoll.h.def
-  GEN_HDR sys/epoll.h
+  ../libc/newhdrgen/yaml/sys/sys_epoll.yaml
+  sys/epoll.h.def
+  sys/epoll.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.struct_epoll_event
@@ -394,19 +446,21 @@ add_gen_header(
     .llvm-libc-macros.sys_epoll_macros
 )
 
-add_gen_header(
+add_header_macro(
   sys_ioctl
-  DEF_FILE sys/ioctl.h.def
-  GEN_HDR sys/ioctl.h
+  ../libc/newhdrgen/yaml/sys/sys_ioctl.yaml
+  sys/ioctl.h.def
+  sys/ioctl.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.sys_ioctl_macros
 )
 
-add_gen_header(
+add_header_macro(
   sys_mman
-  DEF_FILE sys/mman.h.def
-  GEN_HDR sys/mman.h
+  ../libc/newhdrgen/yaml/sys/sys_mman.yaml
+  sys/mman.h.def
+  sys/mman.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.sys_mman_macros
@@ -415,10 +469,11 @@ add_gen_header(
     .llvm-libc-types.ssize_t
 )
 
-add_gen_header(
+add_header_macro(
   sys_prctl
-  DEF_FILE sys/prctl.h.def
-  GEN_HDR sys/prctl.h
+  ../libc/newhdrgen/yaml/sys/sys_prctl.yaml
+  sys/prctl.h.def
+  sys/prctl.h
   DEPENDS
     .llvm_libc_common_h
 )
@@ -431,10 +486,11 @@ add_header(
     .llvm-libc-macros.sys_queue_macros
 )
 
-add_gen_header(
+add_header_macro(
   sys_random
-  DEF_FILE sys/random.h.def
-  GEN_HDR sys/random.h
+  ../libc/newhdrgen/yaml/sys/sys_random.yaml
+  sys/random.h.def
+  sys/random.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.sys_random_macros
@@ -442,10 +498,11 @@ add_gen_header(
     .llvm-libc-types.ssize_t
 )
 
-add_gen_header(
+add_header_macro(
   sys_resource
-  DEF_FILE sys/resource.h.def
-  GEN_HDR sys/resource.h
+  ../libc/newhdrgen/yaml/sys/sys_resource.yaml
+  sys/resource.h.def
+  sys/resource.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.sys_resource_macros
@@ -453,10 +510,11 @@ add_gen_header(
     .llvm-libc-types.struct_rlimit
 )
 
-add_gen_header(
+add_header_macro(
   sys_stat
-  DEF_FILE sys/stat.h.def
-  GEN_HDR sys/stat.h
+  ../libc/newhdrgen/yaml/sys/sys_stat.yaml
+  sys/stat.h.def
+  sys/stat.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.sys_stat_macros
@@ -474,10 +532,11 @@ add_gen_header(
     .llvm-libc-types.struct_stat
 )
 
-add_gen_header(
+add_header_macro(
   sys_select
-  DEF_FILE sys/select.h.def
-  GEN_HDR sys/select.h
+  ../libc/newhdrgen/yaml/sys/sys_select.yaml
+  sys/select.h.def
+  sys/select.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.sys_select_macros
@@ -489,10 +548,11 @@ add_gen_header(
     .llvm-libc-types.struct_timeval
 )
 
-add_gen_header(
+add_header_macro(
   sys_sendfile
-  DEF_FILE sys/sendfile.h.def
-  GEN_HDR sys/sendfile.h
+  ../libc/newhdrgen/yaml/sys/sys_sendfile.yaml
+  sys/sendfile.h.def
+  sys/sendfile.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.off_t
@@ -500,10 +560,11 @@ add_gen_header(
     .llvm-libc-types.ssize_t
 )
 
-add_gen_header(
+add_header_macro(
   sys_socket
-  DEF_FILE sys/socket.h.def
-  GEN_HDR sys/socket.h
+  ../libc/newhdrgen/yaml/sys/sys_socket.yaml
+  sys/socket.h.def
+  sys/socket.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.sys_socket_macros
@@ -513,35 +574,40 @@ add_gen_header(
     .llvm-libc-types.struct_sockaddr_un
 )
 
-add_gen_header(
+add_header_macro(
   sys_statvfs
-  DEF_FILE sys/statvfs.h.def
-  GEN_HDR sys/statvfs.h
+  ../libc/newhdrgen/yaml/sys/sys_statvfs.yaml
+  sys/statvfs.h.def
+  sys/statvfs.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.struct_statvfs
 )
 
-add_gen_header(
+add_header_macro(
   sys_syscall
-  DEF_FILE sys/syscall.h.def
-  GEN_HDR sys/syscall.h
+  ../libc/newhdrgen/yaml/sys/sys_syscall.yaml
+  sys/syscall.h.def
+  sys/syscall.h
+  DEPENDS
 )
 
-add_gen_header(
+add_header_macro(
   sys_time
-  DEF_FILE sys/time.h.def
-  GEN_HDR sys/time.h
+  ../libc/newhdrgen/yaml/sys/sys_time.yaml
+  sys/time.h.def
+  sys/time.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.struct_timeval
     .llvm-libc-macros.sys_time_macros
 )
 
-add_gen_header(
+add_header_macro(
   sys_types
-  DEF_FILE sys/types.h.def
-  GEN_HDR sys/types.h
+  ../libc/newhdrgen/yaml/sys/sys_types.yaml
+  sys/types.h.def
+  sys/types.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.blkcnt_t
@@ -567,19 +633,21 @@ add_gen_header(
     .llvm-libc-types.uid_t
 )
 
-add_gen_header(
+add_header_macro(
   sys_utsname
-  DEF_FILE sys/utsname.h.def
-  GEN_HDR sys/utsname.h
+  ../libc/newhdrgen/yaml/sys/sys_utsname.yaml
+  sys/utsname.h.def
+  sys/utsname.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.struct_utsname
 )
 
-add_gen_header(
+add_header_macro(
   sys_wait
-  DEF_FILE sys/wait.h.def
-  GEN_HDR sys/wait.h
+  ../libc/newhdrgen/yaml/sys/sys_wait.yaml
+  sys/wait.h.def
+  sys/wait.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.sys_wait_macros
@@ -588,10 +656,11 @@ add_gen_header(
     .llvm-libc-types.siginfo_t
 )
 
-add_gen_header(
+add_header_macro(
   termios
-  DEF_FILE termios.h.def
-  GEN_HDR termios.h
+  ../libc/newhdrgen/yaml/termios.yaml
+  termios.h.def
+  termios.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.termios_macros
@@ -602,10 +671,11 @@ add_gen_header(
     .llvm-libc-types.tcflag_t
 )
 
-add_gen_header(
+add_header_macro(
   uchar
-  DEF_FILE uchar.h.def
-  GEN_HDR uchar.h
+  ../libc/newhdrgen/yaml/uchar.yaml
+  uchar.h.def
+  uchar.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-types.mbstate_t
@@ -614,10 +684,11 @@ add_gen_header(
     .llvm-libc-types.char32_t
 )
 
-add_gen_header(
+add_header_macro(
   wchar
-  DEF_FILE wchar.h.def
-  GEN_HDR wchar.h
+  ../libc/newhdrgen/yaml/wchar.yaml
+  wchar.h.def
+  wchar.h
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.wchar_macros
@@ -630,10 +701,11 @@ add_gen_header(
 if(LIBC_TARGET_OS_IS_GPU)
   file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/gpu)
 
-  add_gen_header(
+  add_header_macro(
     gpu_rpc
-    DEF_FILE gpu/rpc.h.def
-    GEN_HDR gpu/rpc.h
+    ../libc/newhdrgen/yaml/rpc.yaml
+    gpu/rpc.h.def
+    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 ccfd93547c1d8..845ef1aebf54b 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 69de81eebb719..d1f0fe96dbc60 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