Skip to content

[libc] delete hdrgen #117220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 3, 2024
Merged

[libc] delete hdrgen #117220

merged 7 commits into from
Dec 3, 2024

Conversation

nickdesaulniers
Copy link
Member

@nickdesaulniers nickdesaulniers commented Nov 21, 2024

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:

  • 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
Link: #117254
Fixes: #117208

@llvmbot
Copy link
Member

llvmbot commented Nov 21, 2024

@llvm/pr-subscribers-libc

Author: Nick Desaulniers (nickdesaulniers)

Changes

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


Patch is 243.67 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/117220.diff

36 Files Affected:

  • (modified) libc/CMakeLists.txt (+1-17)
  • (modified) libc/cmake/modules/LLVMLibCHeaderRules.cmake (-33)
  • (removed) libc/config/baremetal/api.td (-59)
  • (removed) libc/config/gpu/api.td (-50)
  • (removed) libc/config/linux/api.td (-276)
  • (removed) libc/config/public_api.td (-26)
  • (modified) libc/docs/dev/header_generation.rst (-3)
  • (modified) libc/docs/gpu/building.rst (+4-9)
  • (modified) libc/include/CMakeLists.txt (+8-18)
  • (removed) libc/spec/bsd_ext.td (-87)
  • (removed) libc/spec/gnu_ext.td (-316)
  • (removed) libc/spec/gpu_ext.td (-18)
  • (removed) libc/spec/linux.td (-328)
  • (removed) libc/spec/llvm_libc_ext.td (-116)
  • (removed) libc/spec/llvm_libc_stdfix_ext.td (-27)
  • (removed) libc/spec/posix.td (-1867)
  • (removed) libc/spec/spec.td (-253)
  • (removed) libc/spec/stdc.td (-1819)
  • (removed) libc/spec/stdc_ext.td (-82)
  • (modified) libc/test/src/CMakeLists.txt (-78)
  • (removed) libc/utils/HdrGen/CMakeLists.txt (-22)
  • (removed) libc/utils/HdrGen/Command.cpp (-15)
  • (removed) libc/utils/HdrGen/Command.h (-54)
  • (removed) libc/utils/HdrGen/Generator.cpp (-203)
  • (removed) libc/utils/HdrGen/Generator.h (-60)
  • (removed) libc/utils/HdrGen/IncludeFileCommand.cpp (-50)
  • (removed) libc/utils/HdrGen/IncludeFileCommand.h (-32)
  • (removed) libc/utils/HdrGen/Main.cpp (-62)
  • (removed) libc/utils/HdrGen/PrototypeTestGen/CMakeLists.txt (-5)
  • (removed) libc/utils/HdrGen/PrototypeTestGen/PrototypeTestGen.cpp (-106)
  • (removed) libc/utils/HdrGen/PublicAPICommand.cpp (-331)
  • (removed) libc/utils/HdrGen/PublicAPICommand.h (-48)
  • (removed) libc/utils/HdrGen/README.md (-5)
  • (removed) libc/utils/LibcTableGenUtil/APIIndexer.cpp (-173)
  • (removed) libc/utils/LibcTableGenUtil/APIIndexer.h (-86)
  • (removed) libc/utils/LibcTableGenUtil/CMakeLists.txt (-13)
diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index 77b659b2ef2322..d00888b8801dc5 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -54,27 +54,12 @@ set(LIBC_NAMESPACE ${default_namespace}
 add_subdirectory(newhdrgen)
 
 
-if(LLVM_LIBC_FULL_BUILD OR LLVM_LIBC_GPU_BUILD)
-  if(NOT LIBC_HDRGEN_EXE)
-    # We need to set up hdrgen first since other targets depend on it.
-    add_subdirectory(utils/LibcTableGenUtil)
-    add_subdirectory(utils/HdrGen)
-    # Calling add_tablegen sets variables like LIBC_TABLEGEN_EXE in
-    # PARENT_SCOPE which get lost until saved in the cache.
-    set(LIBC_TABLEGEN_EXE "${LIBC_TABLEGEN_EXE}" CACHE INTERNAL "")
-    set(LIBC_TABLEGEN_TARGET "${LIBC_TABLEGEN_TARGET}" CACHE INTERNAL "")
-  else()
-    message(STATUS "Will use ${LIBC_HDRGEN_EXE} for libc header generation.")
-  endif()
-endif()
 # We will build the GPU utilities if we are not doing a runtimes build.
 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" ON)
-
 set(NEED_LIBC_HDRGEN FALSE)
 if(NOT LLVM_RUNTIMES_BUILD)
   if("libc" IN_LIST LLVM_ENABLE_RUNTIMES)
@@ -88,8 +73,7 @@ if(NOT LLVM_RUNTIMES_BUILD)
     endforeach()
   endif()
 endif()
-option(LIBC_HDRGEN_ONLY "Only build the 'libc-hdrgen' executable" OFF)
-if(LIBC_HDRGEN_ONLY OR NEED_LIBC_HDRGEN)
+if(NEED_LIBC_HDRGEN)
   # When libc is build as part of the runtimes/bootstrap build's CMake run, we
   # only need to build the host tools to build the libc. So, we just do enough
   # to build libc-hdrgen and return.
diff --git a/libc/cmake/modules/LLVMLibCHeaderRules.cmake b/libc/cmake/modules/LLVMLibCHeaderRules.cmake
index 76c4e1f2d3244c..766225cbeab404 100644
--- a/libc/cmake/modules/LLVMLibCHeaderRules.cmake
+++ b/libc/cmake/modules/LLVMLibCHeaderRules.cmake
@@ -220,46 +220,13 @@ function(add_gen_header target_name)
 
   set(gen_hdr_script "${LIBC_BUILD_SCRIPTS_DIR}/gen_hdr.py")
 
-  file(GLOB td_includes ${LIBC_SOURCE_DIR}/spec/*.td)
-
   set(ENTRYPOINT_NAME_LIST_ARG ${TARGET_ENTRYPOINT_NAME_LIST})
   list(TRANSFORM ENTRYPOINT_NAME_LIST_ARG PREPEND "--e=")
 
-  if(LIBC_HDRGEN_EXE)
-    set(hdrgen_exe ${LIBC_HDRGEN_EXE})
-  else()
-    set(hdrgen_exe ${LIBC_TABLEGEN_EXE})
-    set(hdrgen_deps "${LIBC_TABLEGEN_EXE};${LIBC_TABLEGEN_TARGET}")
-  endif()
-  add_custom_command(
-    OUTPUT ${out_file}
-    COMMAND ${hdrgen_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
-            ${hdrgen_deps}
-  )
-
   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 ${hdrgen_exe} -o ${decl_out_file}
-              --header ${ADD_GEN_HDR_GEN_HDR} --def ${in_file} --export-decls
-              ${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
-              ${hdrgen_deps}
-    )
   endif()
 
   if(ADD_GEN_HDR_DEPENDS)
diff --git a/libc/config/baremetal/api.td b/libc/config/baremetal/api.td
deleted file mode 100644
index 7421d86fabeb08..00000000000000
--- a/libc/config/baremetal/api.td
+++ /dev/null
@@ -1,59 +0,0 @@
-include "config/public_api.td"
-
-include "spec/stdc.td"
-include "spec/stdc_ext.td"
-include "spec/bsd_ext.td"
-include "spec/llvm_libc_stdfix_ext.td"
-
-
-def CTypeAPI : PublicAPI<"ctype.h"> {
-}
-
-def FEnvAPI : PublicAPI<"fenv.h"> {
-  let Types = ["fenv_t", "fexcept_t"];
-}
-
-def IntTypesAPI : PublicAPI<"inttypes.h"> {
-  let Types = ["imaxdiv_t"];
-}
-
-def MathAPI : PublicAPI<"math.h"> {
-  let Types = ["double_t", "float_t"];
-}
-
-def StdIOAPI : PublicAPI<"stdio.h"> {
-  let Types = ["size_t"];
-}
-
-def StdlibAPI : PublicAPI<"stdlib.h"> {
-  let Types = [
-    "div_t",
-    "ldiv_t",
-    "lldiv_t",
-    "size_t",
-    "__bsearchcompare_t",
-    "__qsortcompare_t",
-  ];
-}
-
-def StringAPI : PublicAPI<"string.h"> {
-  let Types = ["size_t"];
-}
-
-def TimeAPI : PublicAPI<"time.h"> {
-  let Types = [
-    "clock_t",
-    "time_t",
-    "struct tm",
-    "struct timespec",
-  ];
-}
-
-def UCharAPI : PublicAPI<"uchar.h"> {
-  let Types = [
-    "mbstate_t",
-    "char8_t",
-    "char16_t",
-    "char32_t",
-  ];
-}
diff --git a/libc/config/gpu/api.td b/libc/config/gpu/api.td
deleted file mode 100644
index 995ff31c4ac9e9..00000000000000
--- a/libc/config/gpu/api.td
+++ /dev/null
@@ -1,50 +0,0 @@
-include "config/public_api.td"
-
-include "spec/stdc.td"
-include "spec/posix.td"
-include "spec/gpu_ext.td"
-include "spec/gnu_ext.td"
-include "spec/stdc_ext.td"
-include "spec/llvm_libc_ext.td"
-
-
-def StringAPI : PublicAPI<"string.h"> {
-  let Types = ["size_t"];
-}
-
-def StdlibAPI : PublicAPI<"stdlib.h"> {
-  let Types = [
-    "div_t",
-    "ldiv_t",
-    "lldiv_t",
-    "size_t",
-    "__bsearchcompare_t",
-    "__qsortcompare_t",
-    "__qsortrcompare_t",
-    "__atexithandler_t",
-  ];
-}
-
-def FenvAPI: PublicAPI<"fenv.h"> {
-  let Types = ["fenv_t"];
-}
-
-def StdIOAPI : PublicAPI<"stdio.h"> {
-  let Types = [
-    "FILE",
-    "off_t",
-    "size_t",
-  ];
-}
-
-def IntTypesAPI : PublicAPI<"inttypes.h"> {
-  let Types = ["imaxdiv_t"];
-}
-
-def TimeAPI : PublicAPI<"time.h"> {
-  let Types = [
-    "clock_t",
-    "time_t",
-    "struct timespec",
-  ];
-}
diff --git a/libc/config/linux/api.td b/libc/config/linux/api.td
deleted file mode 100644
index a00e0f61b90df7..00000000000000
--- a/libc/config/linux/api.td
+++ /dev/null
@@ -1,276 +0,0 @@
-include "config/public_api.td"
-
-include "spec/stdc.td"
-include "spec/posix.td"
-include "spec/linux.td"
-include "spec/gnu_ext.td"
-include "spec/bsd_ext.td"
-include "spec/stdc_ext.td"
-include "spec/llvm_libc_ext.td"
-include "spec/llvm_libc_stdfix_ext.td"
-
-def CTypeAPI : PublicAPI<"ctype.h"> {
-}
-
-def FCntlAPI : PublicAPI<"fcntl.h"> {
-  let Types = [
-    "mode_t",
-    "off_t",
-  ];
-}
-
-def IntTypesAPI : PublicAPI<"inttypes.h"> {
-  let Types = ["imaxdiv_t"];
-}
-
-def MathAPI : PublicAPI<"math.h"> {
-  let Types = ["double_t", "float_t", "float128"];
-}
-
-def FenvAPI: PublicAPI<"fenv.h"> {
-  let Types = ["fenv_t", "fexcept_t"];
-}
-
-def StringAPI : PublicAPI<"string.h"> {
-  let Types = ["size_t"];
-}
-
-def StdIOAPI : PublicAPI<"stdio.h"> {
-  let Macros = [
-    SimpleMacroDef<"stderr", "stderr">,
-    SimpleMacroDef<"stdin", "stdin">,
-    SimpleMacroDef<"stdout", "stdout">,
-  ];
-  let Types = [
-    "FILE",
-    "cookie_io_functions_t",
-    "off_t",
-    "size_t",
-  ];
-}
-
-def StdlibAPI : PublicAPI<"stdlib.h"> {
-  let Types = [
-    "div_t",
-    "ldiv_t",
-    "lldiv_t",
-    "size_t",
-    "__bsearchcompare_t",
-    "__qsortcompare_t",
-    "__qsortrcompare_t",
-    "__atexithandler_t",
-  ];
-}
-
-def TimeAPI : PublicAPI<"time.h"> {
-  let Types = [
-    "clock_t",
-    "time_t",
-    "struct tm",
-    "struct timespec",
-    "struct timeval",
-    "clockid_t",
-  ];
-}
-
-def SchedAPI : PublicAPI<"sched.h"> {
-  let Types = [
-    "pid_t",
-    "size_t",
-    "cpu_set_t",
-    "struct sched_param",
-    // Needed according to posix standard
-    "time_t",
-    "struct timespec",
-  ];
-}
-
-def SysMManAPI : PublicAPI<"sys/mman.h"> {
-  let Types = ["off_t", "size_t", "mode_t"];
-}
-
-def SignalAPI : PublicAPI<"signal.h"> {
-  let Types = [
-    "sig_atomic_t",
-    "sigset_t",
-    "struct sigaction",
-    "union sigval",
-    "siginfo_t",
-    "stack_t",
-    "pid_t",
-  ];
-}
-
-def ThreadsAPI : PublicAPI<"threads.h"> {
-  let Macros = [
-    SimpleMacroDef<"ONCE_FLAG_INIT", "{0}">,
-  ];
-
-  let Types = [
-    "__call_once_func_t",
-    "once_flag",
-    "cnd_t",
-    "mtx_t",
-    "thrd_t",
-    "thrd_start_t",
-    "tss_t",
-    "tss_dtor_t",
-  ];
-
-  let Enumerations = [
-    "mtx_plain",
-    "mtx_recursive",
-    "mtx_timed",
-    "thrd_timedout",
-    "thrd_success",
-    "thrd_busy",
-    "thrd_error",
-    "thrd_nomem",
-  ];
-}
-
-def PThreadAPI : PublicAPI<"pthread.h"> {
-  let Types = [
-      "__atfork_callback_t",
-      "__pthread_once_func_t",
-      "__pthread_start_t",
-      "__pthread_tss_dtor_t",
-      "pthread_attr_t",
-      "pthread_condattr_t",
-      "pthread_key_t",
-      "pthread_mutex_t",
-      "pthread_mutexattr_t",
-      "pthread_once_t",
-      "pthread_rwlockattr_t",
-      "pthread_rwlock_t",
-      "pthread_spinlock_t",
-      "pthread_t",
-  ];
-}
-
-def DirentAPI : PublicAPI<"dirent.h"> {
-  let Types = [
-    "ino_t",
-    "DIR",
-    "struct dirent",
-  ];
-}
-
-def UniStdAPI : PublicAPI<"unistd.h"> {
-  let Types = ["__exec_argv_t", "__exec_envp_t", "off_t", "pid_t", "size_t",
-               "ssize_t", "uid_t", "__getoptargv_t"];
-}
-
-def WCharAPI : PublicAPI<"wchar.h"> {
-  let Types = [
-    "wchar_t",
-    "wint_t",
-    "size_t",
-  ];
-}
-
-def UCharAPI : PublicAPI<"uchar.h"> {
-  let Types = [
-    "mbstate_t",
-    "char8_t",
-    "char16_t",
-    "char32_t",
-  ];
-}
-
-def SysRandomAPI : PublicAPI<"sys/random.h"> {
-  let Types = ["size_t", "ssize_t"];
-}
-
-def SysSelectAPI : PublicAPI<"sys/select.h"> {
-  let Types = ["fd_set", "sigset_t", "suseconds_t", "time_t", "struct timespec",
-               "struct timeval"];
-}
-
-def SysSocketAPI : PublicAPI<"sys/socket.h"> {
-  let Types = [
-    "sa_family_t",
-    "socklen_t",
-    "struct sockaddr",
-    "struct sockaddr_un",
-    "struct msghdr",
-    "struct iovec",
-    "size_t",
-    "ssize_t",
-  ];
-}
-
-def SysResourceAPI : PublicAPI<"sys/resource.h"> {
-  let Types = ["rlim_t", "struct rlimit"];
-}
-
-def SysStatAPI : PublicAPI<"sys/stat.h"> {
-  let Types = ["mode_t", "dev_t", "ino_t", "nlink_t", "uid_t", "gid_t", "off_t",
-               "struct timespec", "struct timeval", "blksize_t", "blkcnt_t",
-               "struct stat"];
-}
-
-def SysWaitAPI : PublicAPI<"sys/wait.h"> {
-  let Types = ["pid_t", "struct rusage", "siginfo_t"];
-}
-
-def SysSendfileAPI : PublicAPI<"sys/sendfile.h"> {
-  let Types = ["off_t", "size_t", "ssize_t"];
-}
-
-def SysTypesAPI : PublicAPI<"sys/types.h"> {
-  let Types = [
-    "blkcnt_t",
-    "blksize_t",
-    "clockid_t",
-    "dev_t",
-    "gid_t",
-    "ino_t",
-    "mode_t",
-    "nlink_t",
-    "off_t",
-    "pid_t",
-    "pthread_attr_t",
-    "pthread_condattr_t",
-    "pthread_key_t",
-    "pthread_mutex_t",
-    "pthread_mutexattr_t",
-    "pthread_once_t",
-    "pthread_rwlockattr_t",
-    "pthread_rwlock_t",
-    "pthread_t",
-    "size_t",
-    "ssize_t",
-    "suseconds_t",
-    "time_t",
-    "uid_t"
-  ];
-}
-
-def SysUtsNameAPI : PublicAPI<"sys/utsname.h"> {
-  let Types = ["struct utsname"];
-}
-
-def SysEpollAPI : PublicAPI<"sys/epoll.h"> {
-  let Types = ["struct epoll_event", "struct epoll_data", "sigset_t", "struct timespec"];
-}
-
-def SpawnAPI : PublicAPI<"spawn.h"> {
-  let Types = ["mode_t", "pid_t", "posix_spawnattr_t", "posix_spawn_file_actions_t"];
-}
-
-def TermiosAPI : PublicAPI<"termios.h"> {
-  let Types = ["cc_t", "pid_t", "speed_t", "struct termios", "tcflag_t"];
-}
-
-def SetJmpAPI : PublicAPI<"setjmp.h"> {
-  let Types = ["jmp_buf"];
-}
-
-def SearchAPI : PublicAPI<"search.h"> {
-  let Types = ["ACTION", "ENTRY", "struct hsearch_data", "__lsearchcompare_t"];
-}
-
-def SysStatvfsAPI : PublicAPI<"sys/statvfs.h"> {
-  let Types = ["struct statvfs"];
-}
diff --git a/libc/config/public_api.td b/libc/config/public_api.td
deleted file mode 100644
index 1b34506c643c32..00000000000000
--- a/libc/config/public_api.td
+++ /dev/null
@@ -1,26 +0,0 @@
-include "spec/spec.td"
-
-class MacroDef<string name> {
-  string Name = name;
-  string Defn = "";
-}
-
-class SimpleMacroDef<string name, string value> : MacroDef<name> {
-  let Defn = !strconcat("#define ", name, " ", value);
-}
-
-class MacroDefineIfNot<string name, string value> : MacroDef<name> {
-  let Defn = !strconcat("#ifndef ", name, "\n",
-                        "#define " , name, " ", value, "\n",
-                        "#endif // ", name);
-}
-
-class PublicAPI<string name> {
-  string HeaderName = name;
-  list<MacroDef> Macros = [];
-  list<string> Types = [];
-  list<string> Enumerations = [];
-  list<string> Structs = [];
-  list<string> Functions = [];
-  list<string> Objects = [];
-}
diff --git a/libc/docs/dev/header_generation.rst b/libc/docs/dev/header_generation.rst
index ec4206217ca777..0730b9a40c26a1 100644
--- a/libc/docs/dev/header_generation.rst
+++ b/libc/docs/dev/header_generation.rst
@@ -38,9 +38,6 @@ Required Versions:
    ``build/projects/libc/include/sys``.
 
 
-New Headergen is turned on by default, but if you want to use old Headergen,
-you can include this statement when building: ``-DLIBC_USE_NEW_HEADER_GEN=OFF``
-
 To add a function to the YAML files, you can either manually enter it in the
 YAML file corresponding to the header it belongs to or add it through the
 command line.
diff --git a/libc/docs/gpu/building.rst b/libc/docs/gpu/building.rst
index 37dccdab6dc340..6a2d1f23c0bcdf 100644
--- a/libc/docs/gpu/building.rst
+++ b/libc/docs/gpu/building.rst
@@ -86,16 +86,13 @@ compiler. These tools must all be up-to-date with the libc source.
      -DCMAKE_C_COMPILER=$HOST_C_COMPILER      \
      -DCMAKE_CXX_COMPILER=$HOST_CXX_COMPILER  \
      -DLLVM_LIBC_FULL_BUILD=ON                \
-     -DLIBC_HDRGEN_ONLY=ON    \ # Only build the 'libc-hdrgen' tool
      -DCMAKE_BUILD_TYPE=Release # Release suggested to make "clang" fast
   $> ninja # Build the 'clang' compiler
-  $> ninja libc-hdrgen # Build the 'libc-hdrgen' tool
 
-Once this has finished the build directory should contain the ``clang`` compiler
-and the ``libc-hdrgen`` executable. We will use the ``clang`` compiler to build
-the GPU code and the ``libc-hdrgen`` tool to create the necessary headers. We
-use these tools to bootstrap the build out of the runtimes directory targeting a
-GPU architecture.
+Once this has finished the build directory should contain the ``clang``
+compiler executable. We will use the ``clang`` compiler to build the GPU code.
+We use these tools to bootstrap the build out of the runtimes directory
+targeting a GPU architecture.
 
 .. code-block:: sh
 
@@ -105,7 +102,6 @@ GPU architecture.
   $> TARGET_TRIPLE=<amdgcn-amd-amdhsa or nvptx64-nvidia-cuda>
   $> TARGET_C_COMPILER=</path/to/clang>
   $> TARGET_CXX_COMPILER=</path/to/clang++>
-  $> HDRGEN=</path/to/libc-hdrgen>
   $> cmake ../runtimes \ # Point to the runtimes build
      -G Ninja                                  \
      -DLLVM_ENABLE_RUNTIMES=libc               \
@@ -113,7 +109,6 @@ GPU architecture.
      -DCMAKE_CXX_COMPILER=$TARGET_CXX_COMPILER \
      -DLLVM_LIBC_FULL_BUILD=ON                 \
      -DLLVM_RUNTIMES_TARGET=$TARGET_TRIPLE     \
-     -DLIBC_HDRGEN_EXE=$HDRGEN                 \
      -DCMAKE_BUILD_TYPE=Release
   $> ninja install
 
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 91611026df105c..483e63da48deae 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -18,24 +18,14 @@ add_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()
+  add_gen_header2(
+    ${TARGET_NAME}
+    YAML_FILE ${YAML_FILE}
+    DEF_FILE ${DEF_FILE}
+    GEN_HDR ${GEN_HDR}
+    ${DEPENDS}
+    ${ARGN}
+  )
 endmacro()
 
 add_header_macro(
diff --git a/libc/spec/bsd_ext.td b/libc/spec/bsd_ext.td
deleted file mode 100644
index 2b91324e36db9a..00000000000000
--- a/libc/spec/bsd_ext.td
+++ /dev/null
@@ -1,87 +0,0 @@
-def BsdExtensions : StandardSpec<"BSDExtensions"> {
-  HeaderSpec Math = HeaderSpec<
-      "math.h",
-      [], // Macros
-      [], // Types
-      [], // Enumerations
-      [
-          FunctionSpec<"isnan", RetValSpec<IntType>, [ArgSpec<DoubleType>]>,
-          FunctionSpec<"isnanf", RetValSpec<IntType>, [ArgSpec<FloatType>]>,
-          FunctionSpec<"isnanl", RetValSpec<IntType>, [ArgSpec<LongDoubleType>]>,
-      ]
-  >;
-
-  HeaderSpec String = HeaderSpec<
-      "string.h",
-      [], // Macros
-      [], // Types
-      [], // Enumerations
-      [
-        FunctionSpec<
-            "strlcat",
-            RetValSpec<SizeTType>,
-            [ArgSpec<CharRestrictedPtr>, ArgSpec<ConstCharRestrictedPtr>, ArgSpec<SizeTType>]
-        >,
-        FunctionSpec<
-            "strlcpy",
-            RetValSpec<SizeTType>,
-            [ArgSpec<CharRestrictedPtr>, ArgSpec<ConstCharRestrictedPtr>, ArgSpec<SizeTType>]
-        >,
-        FunctionSpec<
-            "strsep",
-            RetValSpec<CharPtr>,
-            [ArgSpec<CharRestrictedPtrPtr>, ArgSpec<ConstCharRestrictedPtr>]
-        >,
-      ]
-  >;
-
-  HeaderSpec Strings = HeaderSpec<
-      "strings.h",
-      [], // Macros
-      [], // Types
-      [], // Enumerations
-      [
-        FunctionSpec<
-            "strcasecmp",
-            RetValSpec<IntType>,
-            [ArgSpec<ConstCharPtr>, ArgSpec<ConstCharPtr>]
-        >,
-        FunctionSpec<
-            "strncasecmp",
-            RetValSpec<IntType>,
-            [ArgSpec<ConstCharPtr>, ArgSpec<ConstCharPtr>, ArgSpec<SizeTType>]
-        >,
-        FunctionSpec<
-            "index",
-            RetValSpec<CharPtr>,
-            [ArgSpec<ConstCharPtr>, ArgSpec<IntType>]
-        >,
-        FunctionSpec<
-            "rindex",
-            RetValSpec<CharPtr>,
-            [ArgSpec<ConstCharPtr>, ArgSpec<IntType>]
-        >,
-      ]
-  >;
-
-  HeaderSpec SysWait = HeaderSpec<
-      "sys/wait.h",
-      [], // Macros
-      [StructRUsage], // Types
-      [], // Enumerations
-      [
-        FunctionSpec<
-            "wait4",
-            RetValSpec<PidT>,
-            [ArgSpec<PidT>, ArgSpec<IntPtr>, ArgSpec<IntType>, ArgSpec<StructRUsagePtr>]
-        >
-      ]
-  >;
-
-  let Headers = [
-    Math,
-    String,
-    Strings,
-    SysWait,
-  ];
-}
diff --git a/libc/spec/gnu_ext.td b/libc/spec/gnu_ext.td
deleted file mode 100644
index 64121aed9574f2..00000000000000
--- a/libc/spec/gnu_ext.td
+++ /dev/null
@@ -1,316 +0,0 @@
-def CpuSetT : NamedType<"cpu_set_t">;
-def CpuSetPtr : PtrType<CpuSetT>;
-def ConstCpuSetPtr : ConstType<CpuSetPtr>;
-
-def QSortRCompareT : NamedType<"__qsortrcompare_t">;
-def StructHsearchData : NamedType<"struct hsearch_data">;
-def StructHsearchDataPtr : PtrType<StructHsearchData>;
-
-def GnuExtensions : StandardSpec<"GNUExtensions"> {
-  NamedType CookieIOFunctionsT = NamedType<"cookie_io_functions_t">;
-  HeaderSpec CType = HeaderSpec<
-    "ctype.h",
-    [], // Macros
-    [], // Types
-    [], // Enumerations
-    [
-        FunctionSpec<
-            "toascii",
-            RetValSpec<IntType>,
-            [ArgSpec<IntType>]
-        >,
-    ]
-  >;
-
-  HeaderSpec Malloc = HeaderSpec<
-      "malloc.h",
-      [], // Macros
-      [], // Types
-      [], // Enumerations
-      [
-          FunctionSpec<"mallopt", RetValSpec<IntType>, [ArgSpec<IntType>, ArgSpec<IntType>]>,
-      ]
-  >;
-
-  HeaderSpec Math = HeaderSpec<
-      "math.h",
-      [], // Macros
-      [], // Types
-      [], // Enumerations
-      [
-        FunctionSpec<
-            "sincosf",
-            RetValSpec<VoidType>,
-            [ArgSpec<FloatType>, ArgSpec<FloatPtr>, ArgSpec<FloatPtr>]
-        >,
-        FunctionSpec<
-            "lgamma_r",
-            RetValSpec<DoubleType>,
-            [ArgSpec<DoubleType>, ArgSpec<IntPtr>]
-        >,
-     ...
[truncated]

# We will build the GPU utilities if we are not doing a runtimes build.
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" ON)

set(NEED_LIBC_HDRGEN FALSE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be deleted?

Suggested change
set(NEED_LIBC_HDRGEN FALSE)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure. Let me check the original context under which it was added.
9dbedca

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also related c4f236e

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI the GPU build still uses that logic to make the amdhsa-loader and nvptx-loader utilities.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, I think I left the important bits intact in 46251c628e4e4aee38f15419fcc67cc8b6c4d827, PTAL.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed everything, in 1c11706f1181. But looking at 5274a46, I'm not sure if we should be returning early if(LLVM_ENABLE_RUNTIMES AND NOT LLVM_RUNTIMES_BUILD). PTAL

Comment on lines 76 to 79
if(NEED_LIBC_HDRGEN)
# When libc is build as part of the runtimes/bootstrap build's CMake run, we
# only need to build the host tools to build the libc. So, we just do enough
# to build libc-hdrgen and return.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't NEED_LIBC_HDRGEN be renamed to something else and the comment below be updated? Might want to add a TODO comment here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1c11706f1181

Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM from what I can see. I'd like to run the tests locally to double check nothing broke, but I'm very excited to see this land.

@@ -18,24 +18,14 @@ add_header(
)

macro(add_header_macro TARGET_NAME YAML_FILE DEF_FILE GEN_HDR DEPENDS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Add a TODO to clean this up

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ae75b6b1c9b90bdc1335cfdd96b38accc47f248e

I tried replacing invocations of add_header_macro with just add_gen_header, but this seemed to run into issues. Not sure if every function invocation of add_gen_header would need explicit DEF_FILE and GEN_HDR spelled out?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe they will need explicit DEF_FILE and GEN_HDR. The macro for add_gen_header2 (lines22-29) should be used, but can be renamed to add_gen_header

@michaelrj-google
Copy link
Contributor

Tests passed, LGTM once the buildbots are ready

@nickdesaulniers
Copy link
Member Author

nickdesaulniers commented Nov 21, 2024

The post submit buildbots with the libc tag are all moved to newhdrgen now. I'll wait for explicit acks from @petrhosek and @jhuber6 before attempting to [crash] land this.

Copy link
Member

@petrhosek petrhosek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer depend on old hdrgen.

@nickdesaulniers
Copy link
Member Author

"Test documentation build" looks new to me in presubmit.

cp: cannot stat 'libc-build/docs/*': No such file or directory

Pretty sure -DLIBC_INCLUDE_DOCS=ON needs to be set. The cmake invocation was:

cmake -B libc-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES="libc" -DLLVM_ENABLE_SPHINX=ON ./runtimes

ugh, I forget where the presubmit testing stuff is located...

@nickdesaulniers
Copy link
Member Author

ugh, I forget where the presubmit testing stuff is located...

https://github.com/llvm/llvm-project/blob/main/.github/workflows/docs.yml#L159-L165

Copy link
Contributor

@jhuber6 jhuber6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GPU loader utilities still need this weird "forced projects" thing.

diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index 73ab38227768..fd82359022cf 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -50,16 +50,28 @@ set(LIBC_NAMESPACE ${default_namespace}
   CACHE STRING "The namespace to use to enclose internal implementations. Must start with '__llvm_libc'."
 )
 
-
-add_subdirectory(newhdrgen)
-
-
 # We will build the GPU utilities if we are not doing a runtimes build.
 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)
+if(LIBC_BUILD_GPU_LOADER OR NOT LLVM_RUNTIMES_BUILD)
+  foreach(_name ${LLVM_RUNTIME_TARGETS})
+    if("libc" IN_LIST RUNTIMES_${_name}_LLVM_ENABLE_RUNTIMES)
+      if("${_name}" STREQUAL "amdgcn-amd-amdhsa" OR "${_name}" STREQUAL "nvptx64-nvidia-cuda")
+        set(LIBC_NEED_LOADER_UTILS TRUE)
+      endif()
+    endif()
+  endforeach()
+  if("${LIBC_TARGET_TRIPLE}" STREQUAL "amdgcn-amd-amdhsa" OR
+     "${LIBC_TARGET_TRIPLE}" STREQUAL "nvptx64-nvidia-cuda")
+    set(LIBC_NEED_LOADER_UTILS TRUE)
+  endif()
+  if(LIBC_NEED_LOADER_UTILS)
+    add_subdirectory(utils/gpu)
+    return()
+  endif()
 endif()
 
+add_subdirectory(newhdrgen)
+
 option(LIBC_CMAKE_VERBOSE_LOGGING
   "Log details warnings and notifications during CMake configuration." OFF)
 
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 03c1486c45ee..cb7a8bf6cbf8 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -190,6 +190,10 @@ if("${LIBC_TARGET_TRIPLE}" STREQUAL "amdgcn-amd-amdhsa" OR
    "${LIBC_TARGET_TRIPLE}" STREQUAL "nvptx64-nvidia-cuda")
   set(LLVM_LIBC_GPU_BUILD ON)
 endif()
+if (NOT "libc" IN_LIST LLVM_ENABLE_PROJECTS AND LLVM_LIBC_GPU_BUILD)
+  message(STATUS "Enabling libc project to build libc testing tools")
+  list(APPEND LLVM_ENABLE_PROJECTS "libc")
+endif()
 
 # LLVM_ENABLE_PROJECTS_USED is `ON` if the user has ever used the
 # `LLVM_ENABLE_PROJECTS` CMake cache variable.  This exists for

This seemed to work for me.

@nickdesaulniers
Copy link
Member Author

The GPU loader utilities still need this weird "forced projects" thing.

Wait, that should be orthogonal to old vs new hdrgen. If anything, we probably need to rethink #117265.

@jhuber6
Copy link
Contributor

jhuber6 commented Dec 3, 2024

The GPU loader utilities still need this weird "forced projects" thing.

Wait, that should be orthogonal to old vs new hdrgen. If anything, we probably need to rethink #117265.

It's fine, it doesn't build anything libc related, just a handful of utilities. The only libc thing they depend on is the printf converter stuff, if we moved that to a shared location we could just make it an LLVM utility or something.

@nickdesaulniers nickdesaulniers deleted the excise_hdrgen branch December 3, 2024 20:34
@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 3, 2024

LLVM Buildbot has detected a new failure on builder libc-aarch64-ubuntu-fullbuild-dbg running on libc-aarch64-ubuntu while building libc,llvm at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/71/builds/11780

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
  File "../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 139, in main
    run_command(['ninja', 'libc-api-test'])
  File "../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 177, in run_command
    util.report_run_cmd(cmd, cwd=directory)
  File "/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-zorg/zorg/buildbot/builders/annotated/util.py", line 49, in report_run_cmd
    subprocess.check_call(cmd, shell=shell, *args, **kwargs)
  File "/usr/lib/python2.7/subprocess.py", line 190, in check_call
    raise CalledProcessError(retcode, cmd)
CalledProcessError: Command '['ninja', 'libc-api-test']' returned non-zero exit status 1
@@@STEP_FAILURE@@@
@@@BUILD_STEP libc-integration-tests@@@
Running: ninja libc-integration-tests
[1/33] Running integration test libc.test.integration.src.spawn.posix_spawn_test
[2/33] Running integration test libc.test.integration.src.pthread.pthread_tss_test
[3/33] Running integration test libc.test.integration.startup.linux.startup_tls_test
[4/33] Running integration test libc.test.integration.startup.linux.startup_no_envp_test
[5/33] Running integration test libc.test.integration.startup.linux.startup_no_args_test
[6/33] Running integration test libc.test.integration.startup.linux.startup_args_test
[7/33] Running integration test libc.test.integration.startup.linux.init_fini_array_test
[8/33] Running integration test libc.test.integration.src.__support.threads.thread_detach_test
[9/33] Running integration test libc.test.integration.src.__support.threads.thread_tls_test
[10/33] Running integration test libc.test.integration.src.pthread.pthread_equal_test
[11/33] Running integration test libc.test.integration.src.pthread.pthread_join_test
[12/33] Running integration test libc.test.integration.src.pthread.pthread_name_test
[13/33] Running integration test libc.test.integration.src.pthread.pthread_exit_test
[14/33] Running integration test libc.test.integration.src.pthread.pthread_once_test
[15/33] Running integration test libc.test.integration.src.stdio.sprintf_size_test
[16/33] Running integration test libc.test.integration.src.stdio.sprintf_size_test_no_sprintf
[17/33] Running integration test libc.test.integration.src.stdlib.getenv_test
[18/33] Running integration test libc.test.integration.src.threads.tss_test
[19/33] Running integration test libc.test.integration.src.threads.thrd_equal_test
[20/33] Running integration test libc.test.integration.src.pthread.pthread_spinlock_test
[21/33] Running integration test libc.test.integration.src.threads.thrd_exit_test
[22/33] Running integration test libc.test.integration.src.threads.call_once_test
[23/33] Running integration test libc.test.integration.src.unistd.getcwd_test
[24/33] Running integration test libc.test.integration.src.unistd.fork_test
[25/33] Running integration test libc.test.integration.src.unistd.execve_test
[26/33] Running integration test libc.test.integration.src.unistd.execv_test
[27/33] Running integration test libc.test.integration.src.pthread.pthread_mutex_test
[28/33] Running integration test libc.test.integration.src.pthread.pthread_rwlock_test
[29/33] Running integration test libc.test.integration.src.pthread.pthread_create_test
[30/33] Running integration test libc.test.integration.src.threads.mtx_test
[31/33] Running integration test libc.test.integration.src.threads.cnd_test
[32/33] Running integration test libc.test.integration.src.threads.thrd_test
[33/33] Running integration test libc.test.integration.src.pthread.pthread_test
@@@BUILD_STEP libc-scudo-integration-test@@@
Running: ninja libc-scudo-integration-test
ninja: no work to do.
@@@BUILD_STEP Benchmark Utils Tests@@@
Running: ninja libc-benchmark-util-tests

@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 3, 2024

LLVM Buildbot has detected a new failure on builder libc-x86_64-debian-fullbuild-dbg running on libc-x86_64-debian-fullbuild while building libc,llvm at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/179/builds/11520

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
Traceback (most recent call last):
  File "/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 162, in step
    yield
  File "/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 139, in main
    run_command(['ninja', 'libc-api-test'])
  File "/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 177, in run_command
    util.report_run_cmd(cmd, cwd=directory)
  File "/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg/llvm-zorg/zorg/buildbot/builders/annotated/util.py", line 49, in report_run_cmd
    subprocess.check_call(cmd, shell=shell, *args, **kwargs)
  File "/usr/lib/python3.11/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['ninja', 'libc-api-test']' returned non-zero exit status 1.
@@@STEP_FAILURE@@@
@@@BUILD_STEP libc-integration-tests@@@
Running: ninja libc-integration-tests
[1/33] Running integration test libc.test.integration.startup.linux.startup_args_test
[2/33] Running integration test libc.test.integration.startup.linux.startup_no_envp_test
[3/33] Running integration test libc.test.integration.startup.linux.startup_no_args_test
[4/33] Running integration test libc.test.integration.startup.linux.startup_tls_test
[5/33] Running integration test libc.test.integration.startup.linux.init_fini_array_test
[6/33] Running integration test libc.test.integration.src.__support.threads.thread_detach_test
[7/33] Running integration test libc.test.integration.src.__support.threads.thread_tls_test
[8/33] Running integration test libc.test.integration.src.pthread.pthread_spinlock_test
[9/33] Running integration test libc.test.integration.src.pthread.pthread_equal_test
[10/33] Running integration test libc.test.integration.src.pthread.pthread_name_test
[11/33] Running integration test libc.test.integration.src.pthread.pthread_exit_test
[12/33] Running integration test libc.test.integration.src.pthread.pthread_tss_test
[13/33] Running integration test libc.test.integration.src.pthread.pthread_once_test
[14/33] Running integration test libc.test.integration.src.pthread.pthread_join_test
[15/33] Running integration test libc.test.integration.src.spawn.posix_spawn_test
[16/33] Running integration test libc.test.integration.src.stdio.sprintf_size_test
[17/33] Running integration test libc.test.integration.src.stdio.sprintf_size_test_no_sprintf
[18/33] Running integration test libc.test.integration.src.stdlib.getenv_test
[19/33] Running integration test libc.test.integration.src.threads.thrd_equal_test
[20/33] Running integration test libc.test.integration.src.threads.thrd_exit_test
[21/33] Running integration test libc.test.integration.src.threads.tss_test
[22/33] Running integration test libc.test.integration.src.threads.call_once_test
[23/33] Running integration test libc.test.integration.src.unistd.getcwd_test
[24/33] Running integration test libc.test.integration.src.pthread.pthread_mutex_test
[25/33] Running integration test libc.test.integration.src.unistd.execv_test
[26/33] Running integration test libc.test.integration.src.unistd.execve_test
[27/33] Running integration test libc.test.integration.src.unistd.fork_test
[28/33] Running integration test libc.test.integration.src.threads.mtx_test
[29/33] Running integration test libc.test.integration.src.pthread.pthread_rwlock_test
[30/33] Running integration test libc.test.integration.src.pthread.pthread_create_test
[31/33] Running integration test libc.test.integration.src.threads.cnd_test
[32/33] Running integration test libc.test.integration.src.pthread.pthread_test
[33/33] Running integration test libc.test.integration.src.threads.thrd_test
@@@BUILD_STEP libc-scudo-integration-test@@@
Running: ninja libc-scudo-integration-test

@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 3, 2024

LLVM Buildbot has detected a new failure on builder libc-x86_64-debian-gcc-fullbuild-dbg running on libc-x86_64-debian-fullbuild while building libc,llvm at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/131/builds/11614

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
[ RUN      ] LlvmLibcStrtouint64Test.DecodeInOtherBases
[       OK ] LlvmLibcStrtouint64Test.DecodeInOtherBases (285 ms)
[ RUN      ] LlvmLibcStrtouint64Test.CleanBaseSixteenDecode
[       OK ] LlvmLibcStrtouint64Test.CleanBaseSixteenDecode (9 us)
[ RUN      ] LlvmLibcStrtouint64Test.MessyBaseSixteenDecode
[       OK ] LlvmLibcStrtouint64Test.MessyBaseSixteenDecode (2 us)
[ RUN      ] LlvmLibcStrtouint64Test.AutomaticBaseSelection
[       OK ] LlvmLibcStrtouint64Test.AutomaticBaseSelection (4 us)
Ran 14 tests.  PASS: 14  FAIL: 0
[1101/1103] Running unit test libc.test.src.math.smoke.llrintl_test.__unit__
[==========] Running 3 tests from 1 test suite.
[ RUN      ] LlvmLibcRoundToIntegerTest.InfinityAndNaN
[       OK ] LlvmLibcRoundToIntegerTest.InfinityAndNaN (11 us)
[ RUN      ] LlvmLibcRoundToIntegerTest.RoundNumbers
[       OK ] LlvmLibcRoundToIntegerTest.RoundNumbers (9 us)
[ RUN      ] LlvmLibcRoundToIntegerTest.SubnormalRange
[       OK ] LlvmLibcRoundToIntegerTest.SubnormalRange (1290 ms)
Ran 3 tests.  PASS: 3  FAIL: 0
[1102/1103] Running unit test libc.test.src.math.smoke.lrintl_test.__unit__
[==========] Running 3 tests from 1 test suite.
[ RUN      ] LlvmLibcRoundToIntegerTest.InfinityAndNaN
[       OK ] LlvmLibcRoundToIntegerTest.InfinityAndNaN (7 us)
[ RUN      ] LlvmLibcRoundToIntegerTest.RoundNumbers
[       OK ] LlvmLibcRoundToIntegerTest.RoundNumbers (9 us)
[ RUN      ] LlvmLibcRoundToIntegerTest.SubnormalRange
[       OK ] LlvmLibcRoundToIntegerTest.SubnormalRange (1321 ms)
Ran 3 tests.  PASS: 3  FAIL: 0
[1103/1103] Running unit test libc.test.src.time.nanosleep_test.__unit__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcNanosleep.SmokeTest
[       OK ] LlvmLibcNanosleep.SmokeTest (42 us)
Ran 1 tests.  PASS: 1  FAIL: 0
@@@BUILD_STEP libc-api-test@@@
Running: ninja libc-api-test
ninja: error: unknown target 'libc-api-test', did you mean 'libc-rpc-tests'?
['ninja', 'libc-api-test'] exited with return code 1.
The build step threw an exception...
Traceback (most recent call last):
  File "/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 162, in step
    yield
  File "/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 139, in main
    run_command(['ninja', 'libc-api-test'])
  File "/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 177, in run_command
    util.report_run_cmd(cmd, cwd=directory)
  File "/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-zorg/zorg/buildbot/builders/annotated/util.py", line 49, in report_run_cmd
    subprocess.check_call(cmd, shell=shell, *args, **kwargs)
  File "/usr/lib/python3.11/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['ninja', 'libc-api-test']' returned non-zero exit status 1.
@@@STEP_FAILURE@@@

@nickdesaulniers
Copy link
Member Author

Ack, need to remove libc-api-test from the bots. Will do that now.

nickdesaulniers added a commit to nickdesaulniers/llvm-zorg that referenced this pull request Dec 3, 2024
This was removed with the removal of "old" hdrgen in
llvm/llvm-project#117220.
nickdesaulniers added a commit to llvm/llvm-zorg that referenced this pull request Dec 3, 2024
This was removed with the removal of "old" hdrgen in
llvm/llvm-project#117220.
@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 3, 2024

LLVM Buildbot has detected a new failure on builder libc-riscv32-qemu-yocto-fullbuild-dbg running on rv32gc-qemu-system while building libc,llvm at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/196/builds/1844

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
[       OK ] LlvmLibcIsZeroTest.SpecialNumbers (420 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[923/931] Running unit test libc.test.include.iszerol_test.__unit__
sh: line 1: /timer.28339: Permission denied
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcIsZeroTest.SpecialNumbers
[       OK ] LlvmLibcIsZeroTest.SpecialNumbers (571 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[924/931] Running unit test libc.test.include.isinfl_test.__unit__
sh: line 1: /timer.28342: Permission denied
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcIsInfTest.SpecialNumbers
[       OK ] LlvmLibcIsInfTest.SpecialNumbers (404 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[925/931] Running unit test libc.test.include.isnormal_c_test.__unit__
sh: line 1: /timer.28347: Permission denied
[926/931] Running unit test libc.test.include.isfinite_test.__unit__
sh: line 1: /timer.28351: Permission denied
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcIsFiniteTest.SpecialNumbers
[       OK ] LlvmLibcIsFiniteTest.SpecialNumbers (394 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[927/931] Running unit test libc.test.include.iszero_c_test.__unit__
sh: line 1: /timer.28369: Permission denied
[928/931] Running unit test libc.test.include.isfinite_c_test.__unit__
sh: line 1: /timer.28373: Permission denied
[929/931] Running unit test libc.test.include.fpclassify_c_test.__unit__
sh: line 1: /timer.28371: Permission denied
[930/931] Running unit test libc.test.include.issubnormal_c_test.__unit__
sh: line 1: /timer.28370: Permission denied
[931/931] Running unit test libc.test.include.isinf_c_test.__unit__
sh: line 1: /timer.28372: Permission denied
@@@BUILD_STEP libc-api-test@@@
Running: ninja libc-api-test
ninja: error: unknown target 'libc-api-test', did you mean 'libc-rpc-tests'?
['ninja', 'libc-api-test'] exited with return code 1.
The build step threw an exception...
Traceback (most recent call last):
  File "/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 162, in step
    yield
  File "/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 139, in main
    run_command(['ninja', 'libc-api-test'])
  File "/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 177, in run_command
    util.report_run_cmd(cmd, cwd=directory)
  File "/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-zorg/zorg/buildbot/builders/annotated/util.py", line 49, in report_run_cmd
    subprocess.check_call(cmd, shell=shell, *args, **kwargs)
  File "/usr/lib/python3.12/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['ninja', 'libc-api-test']' returned non-zero exit status 1.
@@@STEP_FAILURE@@@

nickdesaulniers added a commit to nickdesaulniers/llvm-project that referenced this pull request Dec 4, 2024
Further cleanups from old hdrgen removal. I didn't realize there were cmake
variables related to old hdrgen spread out throughout more of the source tree.

Link: llvm#117220
Link: llvm#117208
@ilovepi
Copy link
Contributor

ilovepi commented Dec 4, 2024

Hi, I think something in the Windows configs may have been missed. we're seeing the following CMake error on our Windows bot:

CMake Error at C:/b/s/w/ir/x/w/llvm-llvm-project/libc/CMakeLists.txt:359 (message):
  C:/b/s/w/ir/x/w/llvm-llvm-project/libc/config/windows/headers.txt file not
  found and fullbuild requested.


-- Configuring incomplete, errors occurred!

Bot link: https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/clang-windows-x64/b8729538683736875265/overview

Logs: https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket/8729538683736875265/+/u/clang/configure/stdout

I assume there's just some missing CMake line for windows that was missed, but I'm not super familiar w/ the libc build. Do you have an idea of where that would be?

@ilovepi
Copy link
Contributor

ilovepi commented Dec 4, 2024

oh, it looks like you added the headers.txt file for other platforms in this patch, so I guess that just needs to be handled for Windows too.

nickdesaulniers added a commit to nickdesaulniers/llvm-project that referenced this pull request Dec 4, 2024
nickdesaulniers added a commit that referenced this pull request Dec 4, 2024
Link:
#117220 (comment)

---------

Co-authored-by: Michael Jones <michaelrj@google.com>
nickdesaulniers added a commit to nickdesaulniers/llvm-project that referenced this pull request Dec 4, 2024
Further cleanups from old hdrgen removal. I didn't realize there were cmake
variables related to old hdrgen spread out throughout more of the source tree.

Link: llvm#117220
Link: llvm#117208
nickdesaulniers added a commit that referenced this pull request Dec 4, 2024
Further cleanups from old hdrgen removal. I didn't realize there were
cmake
variables related to old hdrgen spread out throughout more of the source
tree.

Link: #117220
Link: #117208
nickdesaulniers added a commit to nickdesaulniers/llvm-project that referenced this pull request Dec 10, 2024
FWICT, it was unused even before llvm#117220.

Link: llvm#117220
nickdesaulniers added a commit that referenced this pull request Dec 10, 2024
FWICT, it was unused even before #117220.

Link: #117220
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[libc] delete old hdrgen
9 participants