Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
4274927
bazel: switch C++ toolchain to hermetic-llvm
oharboe Jul 4, 2026
6b35dd4
bazel: add etc/bazel-hermetic pruned-environment launcher
oharboe Jul 4, 2026
e7fa947
bazel-hermetic: address review findings
oharboe Jul 4, 2026
544c3c0
bazel: raise macOS deployment floor to 10.15
oharboe Jul 4, 2026
f9052d0
bazel: buildifier formatting; export RUNFILES_DIR in lint scripts
oharboe Jul 4, 2026
4325f7d
bazel: add macOS SDK frameworks Qt needs
oharboe Jul 4, 2026
1157d4d
bazel: include FontServices private framework in macOS SDK subset
oharboe Jul 4, 2026
ae46bf2
bazel: name PrintCore so the macOS SDK subset keeps usr/include/cups
oharboe Jul 4, 2026
36f55f9
bazel: add CoreImage to the macOS SDK subset
oharboe Jul 4, 2026
370e255
bazel: move hermetic launcher to tools/bazel; wrapper refinements
oharboe Jul 4, 2026
993b9f1
bazel: add Symbols, CloudKit, UIFoundation to the macOS SDK subset
oharboe Jul 4, 2026
3fe0376
tools/bazel: scope pruning to repository rules; fix wrapper reentry
oharboe Jul 4, 2026
cbd092d
bazel: carry upstream boost.icl strict-weak-ordering fix
oharboe Jul 4, 2026
3173310
bazel: give libc headers sysroot-like include precedence
oharboe Jul 4, 2026
a8f0560
bazel: make the hermetic wrapper opt-in as etc/bazel
oharboe Jul 4, 2026
01a5264
bazel: raise macOS deployment floor to 13.3
oharboe Jul 4, 2026
ded89f5
bazel: add MetalKit to the macOS SDK subset
oharboe Jul 4, 2026
fd8ace3
bazel: add ModelIO to the macOS SDK subset
oharboe Jul 5, 2026
0cba112
bazel: fixed toolbox path so --repo_env=PATH keeps the analysis cache
oharboe Jul 5, 2026
cc2b5b0
bazel: drop -idirafter toolchain patch; fix gnulib deps at the source
oharboe Jul 6, 2026
161aea4
bazel: buildifier-format MODULE.bazel (fix fmt/lint tests)
oharboe Jul 6, 2026
473d4b3
Merge branch 'master' into hermetic-llvm-toolchain
oharboe Jul 6, 2026
5627d9e
bazel: rename etc/bazel to etc/bazel-hermetic; mark as local diagnostic
oharboe Jul 7, 2026
c7b4bb5
bazel-hermetic: fail loud on unrecognized command (Codex P2)
oharboe Jul 7, 2026
35e34af
bazel-hermetic: portable env preservation and symlink resolution
oharboe Jul 7, 2026
a7569b6
bazel-hermetic: guard empty-array/unset expansion under set -u (bash …
oharboe Jul 7, 2026
ad51f2a
bazel: mirror macOS SDK framework selection in downstream test module
oharboe Jul 7, 2026
83e3846
bazel-hermetic: drop realpath from shebang check; macOS-safe LANG
oharboe Jul 7, 2026
8616be0
bazel: resolve runfiles root without hardcoding the workspace name
oharboe Jul 7, 2026
1c303c7
bazel-hermetic: tolerate custom bazel wrappers; pure-bash env lookup;…
oharboe Jul 7, 2026
3d795c8
bazel-hermetic: preserve bazelisk/token env; robust id -un fallback
oharboe Jul 7, 2026
5f9a5d5
bazel: bison patch resolves repo name with repo_name(), not hardcoded
oharboe Jul 7, 2026
b61f9d3
bazel-hermetic: read builtin for signature; indirect env lookup
oharboe Jul 7, 2026
74eca7d
bazel-hermetic: preserve cloud credential env for remote cache auth
oharboe Jul 7, 2026
2d533a6
Merge remote-tracking branch 'origin/master' into hermetic-llvm-toolc…
maliberty Jul 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,13 @@ common --enable_platform_specific_config
# macOS: boost.stacktrace needs this since backtrace() doesn't require GNU source
build:macos --copt=-DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED
build:macos --host_copt=-DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED
# Aligned allocation/deallocation for abseil is only available since 10.13
build:macos --macos_minimum_os=10.13
build:macos --host_macos_minimum_os=10.13
# Floating-point std::to_chars (behind std::format, used by OpenSTA)
# needs macOS 13.3; std::filesystem (src/tcl_readline_setup.cc) needs
# 10.15; abseil's aligned allocation needs 10.13. The historical 10.13
# floor was never enforced: toolchains_llvm ignored it and compiled
# against the host SDK's default. hermetic-llvm honors it.
build:macos --macos_minimum_os=13.3
build:macos --host_macos_minimum_os=13.3

# Settings for --config=asan address sanitizer build
build:asan --strip=never
Expand All @@ -123,6 +127,9 @@ build:profile --copt -fno-omit-frame-pointer --host_copt -fno-omit-frame-pointer
# Improve hermeticity by disallowing user envars and network access
build --incompatible_strict_action_env
build --nosandbox_default_allow_network
# Refuse to autodetect a local C++ toolchain (/usr/bin/gcc); the hermetic
# toolchain must win resolution, with or without the etc/bazel-hermetic wrapper.
common --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1

test --build_tests_only

Expand All @@ -142,6 +149,11 @@ build:ci --disk_cache=
# Tell the 'ci' config to include 'opt'
build:ci --config=opt

# Launch py_binary via a shell stub instead of rules_python's legacy python
# stub, whose '#!/usr/bin/env python3' shebang needs a host python3 before
# the hermetic interpreter takes over (found by etc/bazel-hermetic).
common --@rules_python//python/config_settings:bootstrap_impl=script

# Setup remote cache
# Anon: HTTPS read-only cache
build --remote_cache=https://bazel.precisioninno.com
Expand Down
138 changes: 109 additions & 29 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,35 @@ bazel_dep(name = "rules_python", version = "1.8.5")
bazel_dep(name = "rules_shell", version = "0.6.1")
bazel_dep(name = "swig", version = "4.3.0.bcr.2")

# bison is transitive (rules_bison -> bison). Its vendored gnulib headers
# deliberately shadow libc headers; under toolchains that inject libc
# headers as leading -isystem entries (hermetic-llvm, #10812) the shadowing
# breaks and bison@3.8.2.bcr.5 fails to compile (O_BINARY, BCR #7642).
# 3.8.2.bcr.7 fixes most of it (a small remainder is patched in #10812
# pending a proposed 3.8.2.bcr.8).
# bison is transitive (rules_bison -> bison). Same gnulib libc-header
# shadowing class as sed/gawk/m4 under hermetic-llvm (BCR #7642).
# 3.8.2.bcr.7 fixes lib/ but src/ still picks up raw libc headers; the
# patch restores gnulib wrapper-header precedence via -I (to be proposed
# upstream as 3.8.2.bcr.8, then drop).
single_version_override(
module_name = "bison",
patch_strip = 1,
patches = [
"//bazel/bison-patches:0001-gnulib-wrapper-headers-use-I-not-isystem.patch",
],
version = "3.8.2.bcr.7",
)

BOOST_VERSION = "1.89.0.bcr.2"

# boost::icl's exclusive_less_than comparator violates strict weak ordering
# (boostorg/icl#51); libc++'s std::map exposes it, leaving phantom intervals
# after interval_set subtraction (boostorg/icl#55) — pad IO fillers were
# placed on top of pads. Upstream fix boostorg/icl@7de3f55655 (#54), merged
# after boost 1.90. Drop when a boost.icl release containing it lands in BCR.
single_version_override(
module_name = "boost.icl",
patch_strip = 1,
patches = [
"//bazel/boost-icl-patches:0001-refactor-interval-lookup-operations-icl-54.patch",
],
)

bazel_dep(name = "boost.algorithm", version = BOOST_VERSION)
bazel_dep(name = "boost.asio", version = BOOST_VERSION)
bazel_dep(name = "boost.beast", version = BOOST_VERSION)
Expand Down Expand Up @@ -88,11 +104,10 @@ bazel_dep(name = "cudd", version = "3.0.0.bcr.2")
bazel_dep(name = "eigen", version = "3.4.0.bcr.3")
bazel_dep(name = "fmt", version = "11.2.0.bcr.1")

# gawk is transitive (abc -> ncurses -> gawk; yosys -> gawk). Its vendored
# gnulib headers deliberately shadow libc headers; under toolchains that
# inject libc headers as leading -isystem entries (hermetic-llvm, #10812)
# the shadowing breaks and gawk fails to compile (BCR #7642).
# 5.3.2.bcr.7 carries the upstream BCR fix (BCR #7989).
# gawk is transitive (abc -> ncurses -> gawk; yosys -> gawk). Same gnulib
# libc-header shadowing as sed: gawk@5.3.2.bcr.2 fails to compile against
# hermetic-llvm's explicit libc -isystem entries (BCR #7642). 5.3.2.bcr.7
# carries the upstream fix (BCR #7989).
single_version_override(
module_name = "gawk",
version = "5.3.2.bcr.7",
Expand All @@ -101,21 +116,41 @@ single_version_override(
bazel_dep(name = "git", version = "2.54.0")
bazel_dep(name = "googletest", version = "1.17.0.bcr.2")

# m4 is transitive (rules_bison/rules_flex -> m4). Its vendored gnulib
# headers deliberately shadow libc headers; under toolchains that inject
# libc headers as leading -isystem entries (hermetic-llvm, #10812) the
# shadowing breaks and m4@1.4.21 fails to compile (O_SEARCH, BCR #7642).
# 1.4.21.bcr.4 carries the upstream fix.
# m4 is transitive (rules_bison/rules_flex -> m4). Same gnulib libc-header
# shadowing class as sed/gawk under hermetic-llvm (BCR #7642).
single_version_override(
module_name = "m4",
version = "1.4.21.bcr.4",
)

bazel_dep(name = "openmp", version = "21.1.5.bcr.2")
bazel_dep(name = "or-tools", version = "9.15")

# sed is transitive (abc -> ncurses -> sed). Its vendored gnulib headers
# deliberately shadow libc headers (stdio.h, error.h); hermetic-llvm's
# explicit libc -isystem entries outrank them and sed@4.9.bcr.3 fails to
# compile (BCR #7642). 4.9.bcr.5 carries the upstream fix (BCR #7915).
single_version_override(
module_name = "sed",
version = "4.9.bcr.5",
)

bazel_dep(name = "spdlog", version = "1.15.1")
bazel_dep(name = "sv-lang", version = "10.0.1-20260316-f04e8156")
bazel_dep(name = "tcl_lang", version = "9.0.2.bcr.1")

# tclZipfs.c's '#include "crypt.h"' picks up glibc's crypt.h instead of the
# vendored minizip one when glibc headers are explicit -isystem directories
# (hermetic-llvm zero-sysroot toolchain). Drop when fixed in a tcl_lang
# BCR release.
Comment thread
oharboe marked this conversation as resolved.
single_version_override(
module_name = "tcl_lang",
patch_strip = 1,
patches = [
"//bazel/tcl-patches:0001-tclZipfs-include-vendored-minizip-crypt.h-by-path.patch",
],
)

bazel_dep(name = "tcmalloc", version = "0.0.0-20250927-12f2552")
bazel_dep(name = "yaml-cpp", version = "0.9.0")
bazel_dep(name = "zlib", version = "1.3.1.bcr.8")
Expand All @@ -134,7 +169,12 @@ git_override(

## Lock the compiler version and avoid any local compiler.
## Downstream consumers must configure their own C++ toolchain.
bazel_dep(name = "toolchains_llvm", version = "1.5.0", dev_dependency = True)
##
## hermetic-llvm (BCR module "llvm") provides statically linked LLVM
## binaries and a zero-sysroot cc_toolchain: no host compiler, linker,
## libxml2 or /usr/include involved, and it runs unmodified on distros
## without FHS paths (e.g. NixOS).
bazel_dep(name = "llvm", version = "0.8.11", dev_dependency = True)

# --- Dev dependencies (not propagated to downstream consumers) ---

Expand Down Expand Up @@ -201,23 +241,63 @@ archive_override(

# --- Extensions ---

llvm = use_extension(
"@toolchains_llvm//toolchain/extensions:llvm.bzl",
"llvm",
dev_dependency = True,
)
llvm.toolchain(
llvm_version = "20.1.8",
)
use_repo(llvm, "llvm_toolchain", "llvm_toolchain_llvm")

# FYI: Comment out @llvm_toolchain//:all on NixOS and use the local clang toolchain instead.
register_toolchains(
"@llvm_toolchain//:all",
"@llvm//toolchain:all",
"@rules_verilator//verilator:verilator_toolchain",
dev_dependency = True,
)

# hermetic-llvm ships a minimal macOS SDK subset (frameworks are opt-in).
# Qt (qt-bazel) needs the desktop frameworks; the first six entries are
# hermetic-llvm's defaults, which listing any framework replaces.
osx = use_extension("@llvm//extensions:osx.bzl", "osx", dev_dependency = True)
osx.frameworks(names = [
"CoreFoundation",
"Foundation",
"Kernel",
"OSLog",
"Security",
"SystemConfiguration",
"AppKit",
"ApplicationServices",
"CFNetwork",
"Carbon",
"Cocoa",
"ColorSync",
"CoreData",
"CoreGraphics",
"CoreImage",
"CoreServices",
"CoreText",
"CoreVideo",
"DiskArbitration",
# ATS (inside the ApplicationServices umbrella) has .tbd symlinks into
# the FontServices private framework; without it they dangle and bazel
# rejects the sysroot ("file type is not supported").
"FontServices",
"GSS",
"IOKit",
"IOSurface",
"ImageIO",
"Metal",
# MetalKit's MTKModel.h includes ModelIO/ModelIO.h.
"MetalKit",
"ModelIO",
"OpenGL",
# PrintCore is inside the ApplicationServices umbrella, but must be
# named for the SDK subset to keep usr/include/cups (its ObjC headers
# import <cups/ppd.h>).
"PrintCore",
"QuartzCore",
# AppKit reaches these on macOS: NSImageView.h includes Symbols
# unconditionally; NSText*.h take the non-UIKit branch into the
# UIFoundation private framework; NSSharingService pulls CloudKit.
"CloudKit",
"Symbols",
"UIFoundation",
"UniformTypeIdentifiers",
])

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
ignore_root_user_error = True,
Expand Down
Loading
Loading