[llvm] [libc][bazel] Support generating public libc headers in Bazel builds. (PR #141256)

Alexey Samsonov via llvm-commits llvm-commits at lists.llvm.org
Fri May 23 16:35:00 PDT 2025


================
@@ -88,6 +89,426 @@ py_binary(
     srcs = glob(["utils/hdrgen/hdrgen/**/*.py"]),
     imports = ["utils/hdrgen"],
     main = "utils/hdrgen/hdrgen/main.py",
+    deps = ["@pyyaml//:yaml"],
+)
+
+libc_generated_header(
+    name = "ctype_public_header",
+    hdr = "include/ctype.h",
+    yaml_template = "include/ctype.yaml",
+)
+
+libc_generated_header(
+    name = "dirent_public_header",
+    hdr = "include/dirent.h",
+    other_srcs = ["include/dirent.h.def"],
+    yaml_template = "include/dirent.yaml",
+)
+
+libc_generated_header(
+    name = "fcntl_public_header",
+    hdr = "include/fcntl.h",
+    other_srcs = ["include/fcntl.h.def"],
+    yaml_template = "include/fcntl.yaml",
+)
+
+libc_generated_header(
+    name = "dlfcn_public_header",
+    hdr = "include/dlfcn.h",
+    other_srcs = ["include/dlfcn.h.def"],
+    yaml_template = "include/dlfcn.yaml",
+)
+
+libc_generated_header(
+    name = "endian_public_header",
+    hdr = "include/endian.h",
+    other_srcs = ["include/endian.h.def"],
+    yaml_template = "include/endian.yaml",
+)
+
+libc_generated_header(
+    name = "features_public_header",
+    hdr = "include/features.h",
+    other_srcs = ["include/features.h.def"],
+    yaml_template = "include/features.yaml",
+)
+
+libc_generated_header(
+    name = "fenv_public_header",
+    hdr = "include/fenv.h",
+    yaml_template = "include/fenv.yaml",
+)
+
+libc_generated_header(
+    name = "inttypes_public_header",
+    hdr = "include/inttypes.h",
+    other_srcs = ["include/inttypes.h.def"],
+    yaml_template = "include/inttypes.yaml",
+)
+
+libc_generated_header(
+    name = "float_public_header",
+    hdr = "include/float.h",
+    other_srcs = ["include/float.h.def"],
+    yaml_template = "include/float.yaml",
+)
+
+libc_generated_header(
+    name = "stdint_public_header",
+    hdr = "include/stdint.h",
+    other_srcs = ["include/stdint.h.def"],
+    yaml_template = "include/stdint.yaml",
+)
+
+libc_generated_header(
+    name = "limits_public_header",
+    hdr = "include/limits.h",
+    other_srcs = ["include/limits.h.def"],
+    yaml_template = "include/limits.yaml",
+)
+
+libc_generated_header(
+    name = "malloc_public_header",
+    hdr = "include/malloc.h",
+    other_srcs = ["include/stdlib-malloc.yaml"],
+    yaml_template = "include/malloc.yaml",
+)
+
+libc_generated_header(
+    name = "math_public_header",
+    hdr = "include/math.h",
+    other_srcs = ["include/math.h.def"],
+    yaml_template = "include/math.yaml",
+)
+
+libc_generated_header(
+    name = "stdfix_public_header",
+    hdr = "include/stdfix.h",
+    other_srcs = ["include/stdfix.h.def"],
+    yaml_template = "include/stdfix.yaml",
+)
+
+libc_generated_header(
+    name = "sysexits_public_header",
+    hdr = "include/sysexits.h",
+    other_srcs = ["include/sysexits.h.def"],
+    yaml_template = "include/sysexits.yaml",
+)
+
+libc_generated_header(
+    name = "assert_public_header",
+    hdr = "include/assert.h",
+    other_srcs = ["include/assert.h.def"],
+    yaml_template = "include/assert.yaml",
+)
+
+libc_generated_header(
+    name = "complex_public_header",
+    hdr = "include/complex.h",
+    other_srcs = ["include/complex.h.def"],
+    yaml_template = "include/complex.yaml",
+)
+
+libc_generated_header(
+    name = "setjmp_public_header",
+    hdr = "include/setjmp.h",
+    other_srcs = ["include/setjmp.h.def"],
+    yaml_template = "include/setjmp.yaml",
+)
+
+libc_generated_header(
+    name = "string_public_header",
+    hdr = "include/string.h",
+    other_srcs = ["include/string.h.def"],
+    yaml_template = "include/string.yaml",
+)
+
+libc_generated_header(
+    name = "strings_public_header",
+    hdr = "include/strings.h",
+    other_srcs = ["include/strings.h.def"],
+    yaml_template = "include/strings.yaml",
+)
+
+libc_generated_header(
+    name = "search_public_header",
+    hdr = "include/search.h",
+    other_srcs = ["include/search.h.def"],
+    yaml_template = "include/search.yaml",
+)
+
+libc_generated_header(
+    name = "time_public_header",
+    hdr = "include/time.h",
+    other_srcs = ["include/time.h.def"],
+    yaml_template = "include/time.yaml",
+)
+
+libc_generated_header(
+    name = "threads_public_header",
+    hdr = "include/threads.h",
+    other_srcs = ["include/threads.h.def"],
+    yaml_template = "include/threads.yaml",
+)
+
+libc_generated_header(
+    name = "errno_public_header",
+    hdr = "include/errno.h",
+    other_srcs = ["include/errno.h.def"],
+    yaml_template = "include/errno.yaml",
+)
+
+libc_generated_header(
+    name = "signal_public_header",
+    hdr = "include/signal.h",
+    other_srcs = ["include/signal.h.def"],
+    yaml_template = "include/signal.yaml",
+)
+
+libc_generated_header(
+    name = "stdbit_public_header",
+    hdr = "include/stdbit.h",
+    other_srcs = ["include/stdbit.h.def"],
+    yaml_template = "include/stdbit.yaml",
+)
+
+libc_generated_header(
+    name = "stdckdint_public_header",
+    hdr = "include/stdckdint.h",
+    other_srcs = ["include/stdckdint.h.def"],
+    yaml_template = "include/stdckdint.yaml",
+)
+
+libc_generated_header(
+    name = "stdio_public_header",
+    hdr = "include/stdio.h",
+    other_srcs = ["include/stdio.h.def"],
+    yaml_template = "include/stdio.yaml",
+)
+
+libc_generated_header(
+    name = "stdlib_public_header",
+    hdr = "include/stdlib.h",
+    other_srcs = [
+        "include/stdlib.h.def",
+        "include/stdlib-malloc.yaml",
+    ],
+    yaml_template = "include/stdlib.yaml",
+)
+
+libc_generated_header(
+    name = "unistd_public_header",
+    hdr = "include/unistd.h",
+    other_srcs = ["include/unistd.h.def"],
+    yaml_template = "include/unistd.yaml",
+)
+
+libc_generated_header(
+    name = "pthread_public_header",
+    hdr = "include/pthread.h",
+    other_srcs = ["include/pthread.h.def"],
+    yaml_template = "include/pthread.yaml",
+)
+
+libc_generated_header(
+    name = "sched_public_header",
+    hdr = "include/sched.h",
+    other_srcs = ["include/sched.h.def"],
+    yaml_template = "include/sched.yaml",
+)
+
+libc_generated_header(
+    name = "spawn_public_header",
+    hdr = "include/spawn.h",
+    other_srcs = ["include/spawn.h.def"],
+    yaml_template = "include/spawn.yaml",
+)
+
+libc_generated_header(
+    name = "link_public_header",
+    hdr = "include/link.h",
+    yaml_template = "include/link.yaml",
+)
+
+libc_generated_header(
+    name = "elf_public_header",
+    hdr = "include/elf.h",
+    other_srcs = ["include/elf.h.def"],
+    yaml_template = "include/elf.yaml",
+)
+
+libc_generated_header(
+    name = "termios_public_header",
+    hdr = "include/termios.h",
+    other_srcs = ["include/termios.h.def"],
+    yaml_template = "include/termios.yaml",
+)
+
+libc_generated_header(
+    name = "uchar_public_header",
+    hdr = "include/uchar.h",
+    other_srcs = ["include/uchar.h.def"],
+    yaml_template = "include/uchar.yaml",
+)
+
+libc_generated_header(
+    name = "wchar_public_header",
+    hdr = "include/wchar.h",
+    other_srcs = ["include/wchar.h.def"],
+    yaml_template = "include/wchar.yaml",
+)
+
+libc_generated_header(
+    name = "locale_public_header",
+    hdr = "include/locale.h",
+    other_srcs = ["include/locale.h.def"],
+    yaml_template = "include/locale.yaml",
+)
+
+libc_generated_header(
+    name = "poll_public_header",
+    hdr = "include/poll.h",
+    other_srcs = ["include/poll.h.def"],
+    yaml_template = "include/poll.yaml",
+)
+
+libc_generated_header(
+    name = "uefi_public_header",
+    hdr = "include/Uefi.h",
+    yaml_template = "include/Uefi.yaml",
+)
+
+libc_generated_header(
+    name = "arpa_inet_public_header",
+    hdr = "include/arpa/inet.h",
+    other_srcs = ["include/arpa/inet.h.def"],
+    yaml_template = "include/arpa/inet.yaml",
+)
+
+libc_generated_header(
+    name = "sys_auxv_public_header",
+    hdr = "include/sys/auxv.h",
+    other_srcs = ["include/sys/auxv.h.def"],
+    yaml_template = "include/sys/auxv.yaml",
+)
+
+libc_generated_header(
+    name = "sys_epoll_public_header",
+    hdr = "include/sys/epoll.h",
+    other_srcs = ["include/sys/epoll.h.def"],
+    yaml_template = "include/sys/epoll.yaml",
+)
+
+libc_generated_header(
+    name = "sys_ioctl_public_header",
+    hdr = "include/sys/ioctl.h",
+    other_srcs = ["include/sys/ioctl.h.def"],
+    yaml_template = "include/sys/ioctl.yaml",
+)
+
+libc_generated_header(
+    name = "sys_mman_public_header",
+    hdr = "include/sys/mman.h",
+    other_srcs = ["include/sys/mman.h.def"],
+    yaml_template = "include/sys/mman.yaml",
+)
+
+libc_generated_header(
+    name = "sys_prctl_public_header",
+    hdr = "include/sys/prctl.h",
+    other_srcs = ["include/sys/prctl.h.def"],
+    yaml_template = "include/sys/prctl.yaml",
+)
+
+libc_generated_header(
+    name = "sys_random_public_header",
+    hdr = "include/sys/random.h",
+    other_srcs = ["include/sys/random.h.def"],
+    yaml_template = "include/sys/random.yaml",
+)
+
+libc_generated_header(
+    name = "sys_resource_public_header",
+    hdr = "include/sys/resource.h",
+    other_srcs = ["include/sys/resource.h.def"],
+    yaml_template = "include/sys/resource.yaml",
+)
+
+libc_generated_header(
+    name = "sys_stat_public_header",
+    hdr = "include/sys/stat.h",
+    other_srcs = ["include/sys/stat.h.def"],
+    yaml_template = "include/sys/stat.yaml",
+)
+
+libc_generated_header(
+    name = "sys_select_public_header",
+    hdr = "include/sys/select.h",
+    other_srcs = ["include/sys/select.h.def"],
+    yaml_template = "include/sys/select.yaml",
+)
+
+libc_generated_header(
+    name = "sys_sendfile_public_header",
+    hdr = "include/sys/sendfile.h",
+    other_srcs = ["include/sys/sendfile.h.def"],
+    yaml_template = "include/sys/sendfile.yaml",
+)
+
+libc_generated_header(
+    name = "sys_socket_public_header",
+    hdr = "include/sys/socket.h",
+    other_srcs = ["include/sys/socket.h.def"],
+    yaml_template = "include/sys/socket.yaml",
+)
+
+libc_generated_header(
+    name = "sys_statvfs_public_header",
+    hdr = "include/sys/statvfs.h",
+    other_srcs = ["include/sys/statvfs.h.def"],
+    yaml_template = "include/sys/statvfs.yaml",
+)
+
+libc_generated_header(
+    name = "sys_syscall_public_header",
+    hdr = "include/sys/syscall.h",
+    other_srcs = ["include/sys/syscall.h.def"],
+    yaml_template = "include/sys/syscall.yaml",
+)
+
+libc_generated_header(
+    name = "sys_time_public_header",
+    hdr = "include/sys/time.h",
+    other_srcs = ["include/sys/time.h.def"],
+    yaml_template = "include/sys/time.yaml",
+)
+
+libc_generated_header(
+    name = "sys_types_public_header",
+    hdr = "include/sys/types.h",
+    other_srcs = ["include/sys/types.h.def"],
+    yaml_template = "include/sys/types.yaml",
+)
+
+libc_generated_header(
+    name = "sys_utsname_public_header",
+    hdr = "include/sys/utsname.h",
+    other_srcs = ["include/sys/utsname.h.def"],
+    yaml_template = "include/sys/utsname.yaml",
+)
+
+libc_generated_header(
+    name = "sys_uio_public_header",
+    hdr = "include/sys/uio.h",
+    other_srcs = ["include/sys/uio.h.def"],
+    yaml_template = "include/sys/uio.yaml",
+)
+
+libc_generated_header(
+    name = "sys_wait_public_header",
----------------
vonosmas wrote:

Mostly looks good! I would suggest to have just a single public header in the first PR to minimize the diff, and split out adding generating logic vs. adding targets for all public headers into separate commits.

https://github.com/llvm/llvm-project/pull/141256


More information about the llvm-commits mailing list