Skip to content

Commit aeabc36

Browse files
hermetic llvm
1 parent 25f0d99 commit aeabc36

4 files changed

Lines changed: 26 additions & 1 deletion

File tree

.bazelrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ common --@rules_python//python/config_settings:py_linux_libc=musl
3434
# Don't leak PATH and LD_LIBRARY_PATH into the build.
3535
build --incompatible_strict_action_env
3636

37+
# hermetic-llvm <-> rules_rs interop. These are harmless when LRE-CC is the
38+
# active CC toolchain (Nix path) and required when hermetic-llvm provides it
39+
# (non-Nix path):
40+
# - Rust passes -lgcc_s when linking, so libgcc_s must be stubbed.
41+
# - cc-rs doesn't honor $AR/$ARFLAGS, so disable llvm-libtool-darwin as the
42+
# default macOS archiver.
43+
# Musl + PIE harmonization (Rust forces -no-pie; hermetic-llvm defaults to
44+
# -static-pie) is a follow-up: it requires adding @llvm//constraints/pie:off
45+
# to the lre-rs musl platforms, which are @generated and need a generator-side
46+
# change.
47+
build --@llvm//config:experimental_stub_libgcc_s=True
48+
build --@rules_cc//cc/toolchains/args/archiver_flags:use_libtool_on_macos=False
49+
3750
# Don't use legacy repository rules.
3851
build --incompatible_disable_native_repo_rules
3952

MODULE.bazel

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ bazel_dep(name = "bazel_skylib", version = "1.8.2")
1010
bazel_dep(name = "rules_python", version = "2.0.0")
1111
bazel_dep(name = "rules_shell", version = "0.6.1")
1212

13+
# hermetic-llvm: zero-sysroot, fully hermetic LLVM cross-compilation toolchain.
14+
# Inside Nix, lre.bazelrc registers @local-remote-execution//generated-cc/...
15+
# via --extra_toolchains, which outranks the MODULE.bazel registration below,
16+
# so Nix users keep getting LRE-CC unchanged. Outside Nix (no lre.bazelrc),
17+
# these hermetic toolchains replace the host autodetect path.
18+
bazel_dep(name = "llvm", version = "0.7.7")
19+
20+
register_toolchains("@llvm//toolchain:all")
21+
1322
# We use the Nix Python install, as per https://rules-python.readthedocs.io/en/latest/toolchains.html#local-toolchain
1423
# Can't use the rules_python download versions as it breaks with the genrule stuff in nativelink-proto
1524
# Also, this way around we get a Nix-locked Python binary

local-remote-execution/flake-module.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@
151151
# Explicitly duplicate the host as an execution platform. This way
152152
# local execution is treated the same as remote execution.
153153
"@local-remote-execution//rust/platforms:${nixExecToRustExec pkgs}"
154+
"@local-remote-execution//rust/platforms:${nixExecToDefaultRustTarget pkgs}"
154155
]
155156
++ lib.optionals pkgs.stdenv.isLinux [
156157
# TODO(palfrey): Reimplement rbe-configs-gen for C++ so that we

toolchain-examples/MODULE.bazel

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ archive_override(
4545
urls = ["https://github.com/bazel-contrib/rules_go/archive/74199c92e20399b6ef46684b2c6fdd94b50a7892.zip"],
4646
)
4747

48+
# TODO(marcussorealheis): remove this comment once fully observed and released
4849
# Rust — see the parent MODULE.bazel for the archive_override that pins
4950
# rules_rust to the hermeticbuild fork.
50-
bazel_dep(name = "rules_rust", version = "0.68.1")
51+
# was bazel_dep(name = "rules_rust", version = "0.68.1"), is:
52+
bazel_dep(name = "rules_rs", version = "0.0.76")
5153

5254
# C++ toolchain via zig-cc.
5355
#

0 commit comments

Comments
 (0)