@@ -26,6 +26,24 @@ single_version_override(
2626 version = "33.5" ,
2727)
2828
29+ # We set `--@llvm//config:experimental_stub_libgcc_s=True` in .bazelrc so the
30+ # LLVM cc toolchain doesn't try to resolve a `-lgcc_s` it doesn't ship. In
31+ # v0.8.0 the `experimental_stub_libgcc_s` bool_flag isn't marked
32+ # `scope = "universal"`, so the flag value on the target config doesn't
33+ # propagate to exec config and tool builds (process_wrapper,
34+ # //rust:_selenium-manager-bin) still fail to link. The patch adds
35+ # `scope = "universal"` so the flag does propagate; can be dropped once
36+ # hermeticbuild/hermetic-llvm#544 lands.
37+ single_version_override (
38+ module_name = "llvm" ,
39+ patch_strip = 1 ,
40+ patches = [
41+ "//third_party/bazel:llvm_libgcc_s_universal_scope.patch" ,
42+ ],
43+ version = "0.8.3" ,
44+ )
45+
46+ bazel_dep (name = "rules_android" , version = "0.7.2" )
2947bazel_dep (name = "rules_closure" , version = "0.16.0" )
3048bazel_dep (name = "rules_dotnet" , version = "0.21.5" )
3149
@@ -41,6 +59,16 @@ bazel_dep(name = "rules_proto", version = "7.1.0")
4159bazel_dep (name = "rules_ruby" , version = "0.26.0" )
4260bazel_dep (name = "rules_rs" , version = "0.0.90" )
4361
62+ # Native C libraries pulled in by the `*-sys` crates that the Selenium
63+ # Manager Rust binary depends on. Pointing each `*-sys` crate at its
64+ # BCR-hosted cc_library (per rules_rs's `bazel mod tidy` suggestion) lets
65+ # the C source build with the LLVM cc toolchain — which is target-libc
66+ # aware, so the same crate compiles correctly for both the host and the
67+ # musl cross-compile targets.
68+ bazel_dep (name = "bzip2" , version = "1.0.8.bcr.3" )
69+ bazel_dep (name = "xz" , version = "5.4.5.bcr.8" )
70+ bazel_dep (name = "zstd" , version = "1.5.7.bcr.1" )
71+
4472single_version_override (
4573 module_name = "rules_jvm_external" ,
4674 patch_strip = 1 ,
@@ -389,23 +417,42 @@ use_repo(rust_toolchains, "default_rust_toolchains")
389417
390418register_toolchains ("@default_rust_toolchains//:all" )
391419
392- # TODO: Register only Windows exec for now, full @llvm migration can be done as followup.
393420llvm_toolchains = use_extension ("@llvm//extensions:toolchain.bzl" , "toolchain" )
421+
422+ # Register the hermetic LLVM exec toolchain for every platform we build on so
423+ # that the C/C++ toolchain used for exec-config targets (process_wrapper, cargo
424+ # build scripts, etc.) is fully version-pinned and reproducible.
425+ #
426+ # macOS is now viable because the Rust TLS stack uses `ring` (pure Rust + light
427+ # C, no system-framework deps) instead of `aws-lc-rs` / `aws-lc-sys`, which
428+ # previously required CoreServices and compiler-rt from the Xcode sysroot.
429+ #
430+ # Windows uses the gnullvm ABI (PE binary, MSVCRT runtime) rather than MSVC
431+ # because the hermetic LLVM toolchain ships everything needed for gnullvm
432+ # targets without a separately-provisioned Visual Studio installation.
394433llvm_toolchains .exec (
395434 arch = "x86_64" ,
396- os = "windows " ,
435+ os = "linux " ,
397436)
398437llvm_toolchains .exec (
399438 arch = "aarch64" ,
400- os = "windows" ,
439+ os = "linux" ,
440+ )
441+ llvm_toolchains .exec (
442+ arch = "x86_64" ,
443+ os = "macos" ,
401444)
402445llvm_toolchains .exec (
403446 arch = "aarch64" ,
404447 os = "macos" ,
405448)
406449llvm_toolchains .exec (
407450 arch = "x86_64" ,
408- os = "macos" ,
451+ os = "windows" ,
452+ )
453+ llvm_toolchains .exec (
454+ arch = "aarch64" ,
455+ os = "windows" ,
409456)
410457use_repo (llvm_toolchains , "llvm_toolchains" )
411458
@@ -418,25 +465,60 @@ crate.from_cargo(
418465 cargo_toml = "//rust:Cargo.toml" ,
419466 platform_triples = [
420467 "aarch64-apple-darwin" ,
468+ "aarch64-pc-windows-gnullvm" ,
421469 "aarch64-pc-windows-msvc" ,
422470 "aarch64-unknown-linux-gnu" ,
471+ "aarch64-unknown-linux-musl" ,
423472 "x86_64-apple-darwin" ,
473+ "x86_64-pc-windows-gnullvm" ,
424474 "x86_64-pc-windows-msvc" ,
425475 "x86_64-unknown-linux-gnu" ,
476+ "x86_64-unknown-linux-musl" ,
426477 ],
427478)
479+
480+ # Both crates ship `readme.md` but their source uses `include_str!("../readme.md")`.
481+ # Bazel's Rust sandbox only includes `.rs` source files — not auxiliary data files
482+ # like README — so the include_str! fails at compile time regardless of case. We
483+ # patch out the doc attribute entirely; no documentation needed in a Bazel build.
484+ crate .annotation (
485+ crate = "windows-link" ,
486+ patch_args = ["-p1" ],
487+ patches = ["//third_party/bazel:windows_link_readme_case.patch" ],
488+ )
489+ crate .annotation (
490+ crate = "windows-targets" ,
491+ patch_args = ["-p1" ],
492+ patches = ["//third_party/bazel:windows_targets_readme_case.patch" ],
493+ version = "0.53.4" ,
494+ )
495+
496+ # Point the `*-sys` crates at the BCR cc_library packages so their cargo
497+ # build scripts don't run. The `inject_repo` calls below make the
498+ # corresponding repos visible to the crate extension. (Auto-suggested by
499+ # `bazel mod tidy` against rules_rs's well-known annotations.)
428500crate .annotation (
429501 crate = "bzip2-sys" ,
430- gen_build_script = "on" ,
502+ gen_build_script = "off" ,
503+ deps = ["@bzip2//:bz2" ],
431504)
432505crate .annotation (
433506 crate = "lzma-sys" ,
434- gen_build_script = "on" ,
507+ gen_build_script = "off" ,
508+ deps = ["@xz//:lzma" ],
435509)
436510crate .annotation (
437511 crate = "zstd-sys" ,
438- gen_build_script = "on" ,
512+ gen_build_script = "off" ,
513+ deps = ["@zstd" ],
439514)
515+
516+ inject_repo (crate , "bzip2" )
517+
518+ inject_repo (crate , "xz" )
519+
520+ inject_repo (crate , "zstd" )
521+
440522use_repo (crate , "crates" )
441523
442524selenium_manager_artifacts = use_extension ("//common:selenium_manager.bzl" , "selenium_manager_artifacts" )
0 commit comments