[llvm] [Github] Add LLVM-libc's full-build to Bazel Checks workflow (PR #224749)
Jackson Stogel via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 27 17:18:59 PDT 2026
https://github.com/jtstogel updated https://github.com/llvm/llvm-project/pull/224749
>From 842e152d652efee801d399461320eec56799b20f Mon Sep 17 00:00:00 2001
From: jtstogel <jtstogel at gmail.com>
Date: Sun, 27 Sep 2026 13:53:29 -0700
Subject: [PATCH 1/3] [bazel][libc] Refactor to allow copts under full-build
mode
This PR moves away from having sets of predefined groups of copts and allows just directly using them. This lets the Bazel rules more directly parallel CMake.
---
.../llvm-project-overlay/libc/BUILD.bazel | 65 +++++++++----------
.../libc/libc_build_rules.bzl | 53 +++++++--------
2 files changed, 57 insertions(+), 61 deletions(-)
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 33fc35455fef3..53953e041f76d 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -1106,10 +1106,7 @@ libc_support_library(
name = "types_atexithandler_t",
hdrs = ["hdr/types/atexithandler_t.h"],
# Only compatible with full build mode. atexit is not available in overlay mode.
- target_compatible_with = select({
- ":full_build": [],
- "//conditions:default": ["@platforms//:incompatible"],
- }),
+ full_build_only = True,
)
libc_support_library(
@@ -1450,8 +1447,9 @@ libc_support_library(
libc_support_library(
name = "types_struct___pthread_cleanup_frame",
hdrs = ["hdr/types/struct___pthread_cleanup_frame.h"],
+ full_build_only = True,
target_compatible_with = select({
- ":full_build_linux": [],
+ "@platforms//os:linux": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
deps = [":llvm_libc_types_struct___pthread_cleanup_frame"],
@@ -4246,8 +4244,9 @@ libc_support_library(
libc_support_library(
name = "__support_threads_thread_attributes",
hdrs = ["src/__support/threads/thread_attributes.h"],
+ full_build_only = True,
target_compatible_with = select({
- ":full_build_linux": [],
+ "@platforms//os:linux": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
deps = [
@@ -4402,8 +4401,9 @@ libc_support_library(
libc_support_library(
name = "__support_threads_tcb",
hdrs = ["src/__support/threads/tcb.h"],
+ full_build_only = True,
target_compatible_with = select({
- ":full_build_linux": [],
+ "@platforms//os:linux": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
textual_hdrs = select({
@@ -4429,8 +4429,9 @@ libc_support_library(
libc_support_library(
name = "__support_threads_thread_headers",
hdrs = ["src/__support/threads/thread.h"],
+ full_build_only = True,
target_compatible_with = select({
- ":full_build_linux": [],
+ "@platforms//os:linux": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
deps = [
@@ -4452,8 +4453,9 @@ libc_support_library(
libc_support_library(
name = "__support_threads_thread",
srcs = ["src/__support/threads/thread.cpp"],
+ full_build_only = True,
target_compatible_with = select({
- ":full_build_linux": [],
+ "@platforms//os:linux": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
deps = [
@@ -4474,9 +4476,13 @@ libc_support_library(
libc_support_library(
name = "__support_threads_linux_thread",
srcs = ["src/__support/threads/linux/thread.cpp"],
- copt_sets = ["threading"],
+ copts = [
+ "-fno-omit-frame-pointer",
+ "-Wno-frame-address",
+ ],
+ full_build_only = True,
target_compatible_with = select({
- ":full_build_linux": [],
+ "@platforms//os:linux": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
deps = [
@@ -15258,10 +15264,7 @@ libc_support_library(
name = "stdlib_exit_handler",
hdrs = ["src/stdlib/exit_handler.h"],
# Full-build only, as overlay mode must use the host libc's cleanup.
- target_compatible_with = select({
- ":full_build": [],
- "//conditions:default": ["@platforms//:incompatible"],
- }),
+ full_build_only = True,
deps = [
":__support_blockstore",
":__support_common",
@@ -15278,10 +15281,7 @@ libc_function(
srcs = ["src/stdlib/_Exit.cpp"],
hdrs = ["src/stdlib/_Exit.h"],
# Full-build only, as overlay mode must use the host libc's cleanup.
- target_compatible_with = select({
- ":full_build": [],
- "//conditions:default": ["@platforms//:incompatible"],
- }),
+ full_build_only = True,
deps = [
":__support_common",
":__support_macros_config",
@@ -15294,10 +15294,7 @@ libc_function(
srcs = ["src/stdlib/atexit.cpp"],
hdrs = ["src/stdlib/atexit.h"],
# Full-build only, as overlay mode must use the host libc's cleanup.
- target_compatible_with = select({
- ":full_build": [],
- "//conditions:default": ["@platforms//:incompatible"],
- }),
+ full_build_only = True,
deps = [
":__support_common",
":__support_macros_attributes",
@@ -15312,10 +15309,7 @@ libc_function(
srcs = ["src/stdlib/exit.cpp"],
hdrs = ["src/stdlib/exit.h"],
# Full-build only, as overlay mode must use the host libc's cleanup.
- target_compatible_with = select({
- ":full_build": [],
- "//conditions:default": ["@platforms//:incompatible"],
- }),
+ full_build_only = True,
deps = [
":__support_common",
":__support_macros_config",
@@ -15472,9 +15466,10 @@ libc_support_library(
libc_support_library(
name = "stdlib_linux_abort_utils",
hdrs = ["src/stdlib/linux/abort_utils.h"],
+ full_build_only = True,
# Full-build only, as overlay mode must use the host libc's cleanup.
target_compatible_with = select({
- ":full_build_linux": [],
+ "@platforms//os:linux": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
deps = [
@@ -15493,10 +15488,7 @@ libc_function(
srcs = ["src/stdlib/abort.cpp"],
hdrs = ["src/stdlib/abort.h"],
# Full-build only, as overlay mode must use the host libc's abort.
- target_compatible_with = select({
- ":full_build": [],
- "//conditions:default": ["@platforms//:incompatible"],
- }),
+ full_build_only = True,
deps = [
":__support_macros_config",
":stdlib_abort_utils",
@@ -16722,8 +16714,9 @@ libc_function(
name = "fork",
srcs = ["src/unistd/linux/fork.cpp"],
hdrs = ["src/unistd/fork.h"],
+ full_build_only = True,
target_compatible_with = select({
- ":full_build_linux": [],
+ "@platforms//os:linux": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
deps = [
@@ -16773,10 +16766,11 @@ libc_support_library(
libc_support_library(
name = "__signal_utils",
hdrs = ["src/signal/linux/signal_utils.h"],
+ full_build_only = True,
# Only compatible with full build mode on Linux. Overlay mode has header
# conflicts with system headers (e.g. sa_handler macro in glibc).
target_compatible_with = select({
- ":full_build_linux": [],
+ "@platforms//os:linux": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
deps = [
@@ -17174,8 +17168,9 @@ libc_function(
name = "sysconf",
srcs = ["src/unistd/linux/sysconf.cpp"],
hdrs = ["src/unistd/sysconf.h"],
+ full_build_only = True,
target_compatible_with = select({
- ":full_build_linux": [],
+ "@platforms//os:linux": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
deps = [
diff --git a/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl b/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
index 4412ccc81dfed..07cb2b04a5dfd 100644
--- a/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
+++ b/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
@@ -75,42 +75,40 @@ def libc_release_copts():
})
return copts + platform_copts
-# Allowlisted sets of copts that may be used for a single libc library target.
-# Adding copts here is discouraged, as it complicates the build.
-_LIBC_LIBRARY_COPT_SETS = {
- "startup_object": [
- "-ffreestanding",
- "-fno-builtin",
- "-fno-omit-frame-pointer",
- "-fno-stack-protector",
- ],
- "threading": [
- "-fno-omit-frame-pointer",
- "-Wno-frame-address",
- ],
-}
-
def _libc_library(
name,
deps = [],
- copt_sets = [],
+ copts = [],
+ target_compatible_with = [],
+ full_build_only = False,
**kwargs):
"""Internal macro to serve as a base for all other libc library rules.
Args:
name: Target name.
deps: cc_library deps.
- copt_sets: Which sets of allow-listed copts to include.
+ copts: copts for cc_library, only allowed if full_build_only is True.
+ target_compatible_with: target_compatible_with for the cc_library rule.
+ full_build_only: Whether this target is only used in full-build mode.
**kwargs: All other attributes relevant for the cc_library rule.
"""
- for attr in ["copts", "local_defines"]:
+ for attr in ["local_defines"]:
if attr in kwargs:
fail("disallowed attribute: '{}' in rule: '{}'".format(attr, name))
- copts = []
- for feature in copt_sets:
- copts.extend(_LIBC_LIBRARY_COPT_SETS[feature])
+ # Allow copts if the target is only for full-builds. Startup or threading
+ # code necessitate copts, but LLVM-libc's build rules should prefer to
+ # avoid copts when possible as per-file-copts are not compatible with
+ # libc_release_library's method of aggregating sources into one cc_library.
+ if copts and not full_build_only:
+ fail("copts disallowed in overlay-compatible rule: '{}'".format(name))
+
+ if full_build_only:
+ target_compatible_with = target_compatible_with + select({
+ Label(":full_build"): [],
+ "//conditions:default": ["@platforms//:incompatible"],
+ })
cc_library(
name = name,
@@ -118,6 +116,7 @@ def _libc_library(
local_defines = LIBC_CONFIGURE_OPTIONS,
deps = deps + libc_common_deps(),
linkstatic = 1,
+ target_compatible_with = target_compatible_with,
**kwargs
)
@@ -137,11 +136,13 @@ def libc_startup_library(name, **kwargs):
_libc_library(
name = name,
- copt_sets = ["startup_object"],
- target_compatible_with = select({
- Label("//libc:full_build_linux"): [],
- "//conditions:default": ["@platforms//:incompatible"],
- }),
+ full_build_only = True,
+ copts = [
+ "-ffreestanding",
+ "-fno-builtin",
+ "-fno-omit-frame-pointer",
+ "-fno-stack-protector",
+ ],
**kwargs
)
>From 6e671d17e5cc3324ff0fa10c8cca9ba53f63b2e1 Mon Sep 17 00:00:00 2001
From: jtstogel <jtstogel at gmail.com>
Date: Thu, 24 Sep 2026 21:42:11 -0700
Subject: [PATCH 2/3] [bazel] Port 4faf0ae, 15cff90, 9028ff14, 4057f8e4
---
.../llvm-project-overlay/libc/BUILD.bazel | 80 ++++++++++++++++++-
.../libc/startup/linux/BUILD.bazel | 4 +-
.../libc/startup/linux/x86_64/BUILD.bazel | 15 ----
3 files changed, 78 insertions(+), 21 deletions(-)
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 53953e041f76d..72a3e709e4af4 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -3684,6 +3684,29 @@ libc_support_library(
],
)
+libc_support_library(
+ name = "__support_osutil_linux_syscall_wrappers_clone",
+ hdrs = ["src/__support/OSUtil/linux/syscall_wrappers/clone.h"],
+ target_compatible_with = select({
+ "@platforms//os:linux": [],
+ "//conditions:default": ["@platforms//:incompatible"],
+ }),
+ textual_hdrs = [
+ "src/__support/OSUtil/linux/syscall_wrappers/aarch64/clone.h",
+ "src/__support/OSUtil/linux/syscall_wrappers/riscv/clone.h",
+ "src/__support/OSUtil/linux/syscall_wrappers/x86_64/clone.h",
+ ],
+ deps = [
+ ":__support_common",
+ ":__support_error_or",
+ ":__support_libc_assert",
+ ":__support_macros_config",
+ ":__support_macros_properties_architectures",
+ ":hdr_stdint_proxy",
+ ":types_pid_t",
+ ],
+)
+
libc_support_library(
name = "__support_osutil_linux_syscall_wrappers_close",
hdrs = ["src/__support/OSUtil/linux/syscall_wrappers/close.h"],
@@ -4227,6 +4250,21 @@ libc_support_library(
],
)
+libc_support_library(
+ name = "__support_threads_cleanup_stack",
+ hdrs = ["src/__support/threads/cleanup_stack.h"],
+ full_build_only = True,
+ target_compatible_with = select({
+ "@platforms//os:linux": [],
+ "//conditions:default": ["@platforms//:incompatible"],
+ }),
+ deps = [
+ ":__support_macros_attributes",
+ ":__support_macros_config",
+ ":types_struct___pthread_cleanup_frame",
+ ],
+)
+
libc_support_library(
name = "__support_threads_linux_futex_word_type",
hdrs = ["src/__support/threads/linux/futex_word.h"],
@@ -4255,6 +4293,7 @@ libc_support_library(
":__support_macros_attributes",
":__support_macros_config",
":__support_macros_properties_architectures",
+ ":__support_threads_cleanup_stack",
":hdr_stdint_proxy",
":types_size_t",
":types_struct___pthread_cleanup_frame",
@@ -4465,8 +4504,10 @@ libc_support_library(
":__support_fixedvector",
":__support_macros_attributes",
":__support_macros_config",
+ ":__support_threads_cleanup_stack",
":__support_threads_mutex",
":__support_threads_thread_headers",
+ ":types_struct___pthread_cleanup_frame",
] + select({
"@platforms//os:linux": [":__support_threads_linux_thread"],
"//conditions:default": [],
@@ -4476,10 +4517,6 @@ libc_support_library(
libc_support_library(
name = "__support_threads_linux_thread",
srcs = ["src/__support/threads/linux/thread.cpp"],
- copts = [
- "-fno-omit-frame-pointer",
- "-Wno-frame-address",
- ],
full_build_only = True,
target_compatible_with = select({
"@platforms//os:linux": [],
@@ -4498,6 +4535,7 @@ libc_support_library(
":__support_libc_errno",
":__support_macros_attributes",
":__support_macros_config",
+ ":__support_osutil_linux_syscall_wrappers_clone",
":__support_osutil_linux_syscall_wrappers_close",
":__support_osutil_linux_syscall_wrappers_getpid",
":__support_osutil_linux_syscall_wrappers_mmap",
@@ -4514,6 +4552,7 @@ libc_support_library(
":__support_threads_futex_utils",
":__support_threads_linux_futex_utils",
":__support_threads_linux_futex_word_type",
+ ":__support_threads_linux_tls",
":__support_threads_mutex",
":__support_threads_thread_attributes",
":__support_threads_thread_headers",
@@ -4527,6 +4566,39 @@ libc_support_library(
],
)
+libc_support_library(
+ name = "__support_threads_linux_tls",
+ srcs = selects.with_or({
+ PLATFORM_CPU_X86_64: ["src/__support/threads/linux/x86_64/tls.cpp"],
+ PLATFORM_CPU_ARM64: ["src/__support/threads/linux/aarch64/tls.cpp"],
+ PLATFORM_CPU_RISCV64: ["src/__support/threads/linux/riscv/tls.cpp"],
+ "//conditions:default": [],
+ }),
+ copts = [
+ "-ffreestanding",
+ "-fno-builtin",
+ "-fno-omit-frame-pointer",
+ "-fno-stack-protector",
+ "-O3",
+ ],
+ full_build_only = True,
+ target_compatible_with = select({
+ "@platforms//os:linux": [],
+ "//conditions:default": ["@platforms//:incompatible"],
+ }),
+ deps = [
+ ":__support_macros_config",
+ ":__support_osutil_linux_syscall_wrappers_getrandom",
+ ":__support_osutil_linux_syscall_wrappers_mmap",
+ ":__support_osutil_linux_syscall_wrappers_munmap",
+ ":__support_osutil_syscall",
+ ":__support_threads_tcb",
+ ":config_app_h",
+ ":hdr_sys_mman_macros",
+ ":string_memory_utils",
+ ],
+)
+
libc_support_library(
name = "__support_threads_callonce",
hdrs = ["src/__support/threads/callonce.h"],
diff --git a/utils/bazel/llvm-project-overlay/libc/startup/linux/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/startup/linux/BUILD.bazel
index e8f76f330f49b..e80f253ecb88a 100644
--- a/utils/bazel/llvm-project-overlay/libc/startup/linux/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/startup/linux/BUILD.bazel
@@ -54,6 +54,8 @@ libc_startup_library(
"//libc:__support_macros_config",
"//libc:__support_osutil_linux_auxv",
"//libc:__support_osutil_syscall",
+ "//libc:__support_threads_linux_futex_utils",
+ "//libc:__support_threads_linux_tls",
"//libc:__support_threads_tcb",
"//libc:__support_threads_thread",
"//libc:__support_threads_thread_headers",
@@ -76,7 +78,6 @@ libc_startup_library(
] + selects.with_or({
PLATFORM_CPU_X86_64: [
"//libc/startup/linux/x86_64:irelative",
- "//libc/startup/linux/x86_64:tls",
],
"//conditions:default": [],
}),
@@ -91,7 +92,6 @@ merge_relocatable_object(
PLATFORM_CPU_X86_64: [
"//libc/startup/linux/x86_64:irelative",
"//libc/startup/linux/x86_64:start",
- "//libc/startup/linux/x86_64:tls",
],
"//conditions:default": [],
}),
diff --git a/utils/bazel/llvm-project-overlay/libc/startup/linux/x86_64/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/startup/linux/x86_64/BUILD.bazel
index db07f7b62a2e7..4ecc22e92072c 100644
--- a/utils/bazel/llvm-project-overlay/libc/startup/linux/x86_64/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/startup/linux/x86_64/BUILD.bazel
@@ -13,21 +13,6 @@ package(
],
)
-libc_startup_library(
- name = "tls",
- srcs = ["tls.cpp"],
- deps = [
- "//libc:__support_macros_config",
- "//libc:__support_osutil_linux_syscall_wrappers_getrandom",
- "//libc:__support_osutil_linux_syscall_wrappers_mmap",
- "//libc:__support_osutil_linux_syscall_wrappers_munmap",
- "//libc:__support_threads_tcb",
- "//libc:config_app_h",
- "//libc:hdr_sys_mman_macros",
- "//libc:string_memory_utils",
- ],
-)
-
libc_startup_library(
name = "start",
srcs = ["start.cpp"],
>From 0b5277acc8f126f355ba25efee64a73817b0cc64 Mon Sep 17 00:00:00 2001
From: jtstogel <jtstogel at gmail.com>
Date: Fri, 18 Sep 2026 13:10:58 -0700
Subject: [PATCH 3/3] [Github] Add LLVM-libc's full-build to Bazel Checks
workflow
This PR adds a job to run `bazelisk test -- at llvm-project//libc:build_mode=full @llvm-project//libc/...`. It is part of an effort to support LLVM-libc's full build functionality in Bazel.
---
.github/workflows/bazel-checks.yml | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/bazel-checks.yml b/.github/workflows/bazel-checks.yml
index f2dd3ab35da9d..91bbfbbac5952 100644
--- a/.github/workflows/bazel-checks.yml
+++ b/.github/workflows/bazel-checks.yml
@@ -44,13 +44,23 @@ jobs:
fi
bazel-build:
- name: "Bazel Build/Test"
+ name: "Bazel ${{ matrix.name }}"
# Only run on US Central workers so we only have to keep one cache warm as
# the cache buckets are per cluster.
runs-on:
group: llvm-premerge-cluster-us-central
labels: llvm-premerge-linux-runners
if: github.repository == 'llvm/llvm-project'
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - name: "Build/Test"
+ flags: ""
+ targets: "@llvm-project//... //..."
+ - name: "LLVM-libc Fullbuild Tests"
+ flags: "-- at llvm-project//libc:build_mode=full"
+ targets: "@llvm-project//libc/..."
steps:
- name: Fetch LLVM sources
uses: actions/checkout at df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
@@ -74,4 +84,5 @@ jobs:
--remote_cache=https://storage.googleapis.com/$CACHE_GCS_BUCKET-bazel \
--google_default_credentials \
--remote_download_outputs=minimal \
- @llvm-project//... //...
+ ${{ matrix.flags }} \
+ ${{ matrix.targets }}
More information about the llvm-commits
mailing list