Skip to content

Commit ef8c989

Browse files
[build] Upgrade rules_rs to 0.0.90 and build Rust against @llvm on macOS (#17683)
rules_rs 0.0.90 bundles a newer rules_rust and pulls llvm 0.8.3, which breaks the Selenium Manager build in three ways: 1. The cargo build-script runner now rejects libtool as the archiver (AR). macOS C++ toolchains (autodetected and apple_support alike) use libtool by default, breaking every Rust crate with a build script. Fix: register the hermetic @llvm toolchain for macOS exec (mirroring Windows) and, on macOS, disable C++ toolchain autodetection and switch the rules_cc archiver from libtool to llvm-ar. 2. The selenium-manager binary fails to compile because clap's #[clap(about)] derives the description from CARGO_PKG_DESCRIPTION, which rules_rust no longer sets. Fix: set it via rustc_env, kept in sync with rust/Cargo.toml. 3. On Windows, no Rust toolchain matches //:local_windows_gnullvm: the gnullvm toolchain now requires crt:msvcrt, but the crt constraint defaults to ucrt. Fix: select msvcrt explicitly on the platform. Also pins llvm to 0.8.3 to match the resolved version. Linux is unaffected.
1 parent cd6a3cd commit ef8c989

4 files changed

Lines changed: 28 additions & 2 deletions

File tree

.bazelrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ build:windows --host_per_file_copt=external/protobuf\\+.*@/w
9090
common --enable_platform_specific_config
9191
common:linux --host_platform=//:local_linux_gnu
9292
common:windows --host_platform=//:local_windows_gnullvm
93+
94+
# rules_rs 0.0.90 bundles a newer rules_rust whose cargo build-script runner
95+
# rejects libtool as the archiver (AR). macOS toolchains use libtool by default,
96+
# so build Rust against the hermetic @llvm toolchain (registered for macOS exec
97+
# in MODULE.bazel) with the rules_cc archiver switched from libtool to llvm-ar.
98+
common:macos --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
99+
common:macos --@rules_cc//cc/toolchains/args/archiver_flags:use_libtool_on_macos=False
93100
build:linux --workspace_status_command=scripts/build-info.sh
94101
build:macos --workspace_status_command=scripts/build-info.sh
95102
build:windows --workspace_status_command="powershell.exe scripts/build-info.ps1"

BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,12 @@ platform(
129129
platform(
130130
name = "local_windows_gnullvm",
131131
constraint_values = [
132+
# alias -> @llvm//constraints/windows/abi:gnullvm
132133
"@rules_rs//rs/platforms/constraints:windows_gnullvm",
134+
# rules_rs 0.0.90 (via llvm 0.8.3) requires the CRT to be selected
135+
# explicitly; the gnullvm Rust toolchain targets msvcrt, while the crt
136+
# constraint otherwise defaults to ucrt and no toolchain would match.
137+
"@llvm//constraints/windows/crt:msvcrt",
133138
],
134139
parents = ["@platforms//host"],
135140
)

MODULE.bazel

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ bazel_dep(name = "bazel_features", version = "1.47.1")
1010
bazel_dep(name = "bazel_skylib", version = "1.9.0")
1111
bazel_dep(name = "buildifier_prebuilt", version = "8.5.1.2")
1212
bazel_dep(name = "contrib_rules_jvm", version = "0.33.0")
13-
bazel_dep(name = "llvm", version = "0.7.9")
13+
bazel_dep(name = "llvm", version = "0.8.3")
1414
bazel_dep(name = "package_metadata", version = "0.0.10")
1515
bazel_dep(name = "platforms", version = "1.1.0")
1616

@@ -39,7 +39,7 @@ bazel_dep(name = "rules_pkg", version = "1.2.0")
3939
bazel_dep(name = "rules_python", version = "1.9.0")
4040
bazel_dep(name = "rules_proto", version = "7.1.0")
4141
bazel_dep(name = "rules_ruby", version = "0.26.0")
42-
bazel_dep(name = "rules_rs", version = "0.0.61")
42+
bazel_dep(name = "rules_rs", version = "0.0.90")
4343

4444
single_version_override(
4545
module_name = "rules_jvm_external",
@@ -399,6 +399,14 @@ llvm_toolchains.exec(
399399
arch = "aarch64",
400400
os = "windows",
401401
)
402+
llvm_toolchains.exec(
403+
arch = "aarch64",
404+
os = "macos",
405+
)
406+
llvm_toolchains.exec(
407+
arch = "x86_64",
408+
os = "macos",
409+
)
402410
use_repo(llvm_toolchains, "llvm_toolchains")
403411

404412
register_toolchains("@llvm_toolchains//:all")

rust/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ rust_binary(
7878
srcs = ["src/main.rs"],
7979
aliases = aliases(),
8080
edition = "2024",
81+
# clap's `#[clap(about)]` derives the CLI description from
82+
# CARGO_PKG_DESCRIPTION. Cargo sets this from Cargo.toml automatically, but
83+
# the Bazel build must supply it explicitly. Keep in sync with rust/Cargo.toml.
84+
rustc_env = {
85+
"CARGO_PKG_DESCRIPTION": "Selenium Manager is a CLI tool that automatically manages the browser/driver resources required by Selenium.",
86+
},
8187
version = "0.4.45",
8288
visibility = ["//visibility:public"],
8389
deps = [

0 commit comments

Comments
 (0)