Skip to content

[build] add bazel flag to support cross-compiling all Selenium Manager binaries from Linux or Mac - #18029

Merged
titusfortner merged 1 commit into
SeleniumHQ:trunkfrom
titusfortner:sm-cross-compile-build
Sep 15, 2026
Merged

titusfortner merged 1 commit into
SeleniumHQ:trunkfrom
titusfortner:sm-cross-compile-build

Conversation

@titusfortner

@titusfortner titusfortner commented Sep 12, 2026

Copy link
Copy Markdown
Member

🔗 Related Issues

Implements a subset of #17586
Builds on #18024 (adds all to --manager)

💥 What does this PR do?

  • Adds --manager=all, which makes every binding resolve a Selenium Manager binary cross-compiled from the current source instead of the pinned download. Note that nothing yet uses this new flag in our build/release process (see Additional Considerations)
  • Running bazel with --config=release now uses the same optimizations as cargo build --release

🔧 Implementation Notes

  • Linux binaries are fully static (musl) and Windows uses the LLVM MinGW target, because those are what the hermetic LLVM toolchain can link without a system SDK
  • The C libraries some crates depend on (bzip2, xz, zstd) now come from Bazel modules instead of cargo build scripts, so they cross-compile too
  • all is marked incompatible on Windows hosts until the upstream fixes ship (see Additional Considerations)
  • The binaries built from --manager=all are slightly different from what is built (and published) from Cargo
    • The macOS binary is kept as a fat binary, but the minimum version for Intel rises from 10.12 to 11.0 since one deployment target covers both architectures and arm64 can't go lower
    • The Windows binary is 64-bit instead of 32-bit, which increases its size from 3.5 to about 4.4 MB

🤖 AI assistance

  • AI assisted (complete below)
    • Tool(s): Claude Code (Opus 5)
    • What was generated: the Bazel cross-compile wiring, the verification runs, and this description
    • I reviewed all AI output and can explain the change

💡 Additional Considerations

🔄 Types of changes

  • New feature (build infrastructure; no user-facing change)

@selenium-ci selenium-ci added B-build Includes scripting, bazel and CI integrations C-rust Rust code is mostly Selenium Manager B-manager Selenium Manager labels Sep 12, 2026
@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Cross-compile all Selenium Manager binaries with Bazel

✨ Enhancement ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Adds --manager=all to build every Selenium Manager platform artifact from source.
• Uses hermetic LLVM targets and Bazel-provided C libraries for cross-compilation.
• Aligns Bazel release optimization settings with Cargo release builds.
Diagram

graph TD
  A["Manager all mode"] --> B["Artifact resolver"] --> C["Platform transitions"] --> D["LLVM toolchains"] --> E["Platform binaries"] --> H["Language bindings"]
  F["Bazel C libraries"] --> C
  E --> G["macOS lipo"] --> H
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Native CI build matrix
  • ➕ Uses each platform's system SDK and canonical Cargo targets
  • ➕ Allows platform-specific execution and validation
  • ➖ Cannot produce every binary from one host
  • ➖ Requires artifact aggregation and duplicates setup across runners
2. RBE-backed cross-compilation
  • ➕ Preserves hermetic builds while distributing expensive platform compilation
  • ➕ Better fits release jobs that otherwise rebuild every binary locally
  • ➖ Requires additional remote-execution and release-pipeline integration
  • ➖ Does not remove current upstream limitations on Windows hosts

Recommendation: The PR's hermetic platform-transition approach is the best foundation for one-host, reproducible cross-compilation and avoids reliance on system SDKs. Retain this implementation, then move these same targets to RBE before release integration to reduce duplicated build time; a native CI matrix should remain useful for platform validation rather than artifact production.

Files changed (5) +103 / -3

Enhancement (2) +12 / -0
BUILD.bazelAdd the manager all build mode +8/-0

Add the manager all build mode

• Extends the Selenium Manager build flag with an 'all' value and exposes a matching configuration selector.

common/BUILD.bazel

BUILD.bazelResolve every Manager artifact from cross-compiled targets +4/-0

Resolve every Manager artifact from cross-compiled targets

• Routes Linux, macOS, and Windows Manager aliases to Bazel cross-compiled outputs whenever '--manager=all' is active. Existing host-build and pinned-download behavior remains unchanged.

common/manager/BUILD.bazel

Other (3) +91 / -3
.bazelrcAlign Bazel release builds with Cargo optimizations +6/-0

Align Bazel release builds with Cargo optimizations

• Sets the macOS deployment target to 11.0 for universal binaries. Adds fat LTO, size optimization, single codegen unit, abort-on-panic, and symbol stripping to match Cargo's release profile.

.bazelrc

MODULE.bazelConfigure hermetic native dependencies and cross-target toolchains +29/-3

Configure hermetic native dependencies and cross-target toolchains

• Adds Bazel modules for bzip2, xz, and zstd and injects them into Rust crates instead of running crate build scripts. Registers Linux LLVM execution toolchains and adds musl and LLVM-MinGW Rust target triples.

MODULE.bazel

BUILD.bazelBuild Selenium Manager for all supported target platforms +56/-0

Build Selenium Manager for all supported target platforms

• Defines Rust platform transitions for musl Linux, Intel and ARM macOS, and 64-bit LLVM-MinGW Windows targets. Extracts transitioned outputs, marks them incompatible on Windows hosts, and combines macOS executables into a universal binary with LLVM lipo.

rust/BUILD.bazel

@qodo-code-review

qodo-code-review Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. New cross-build routing is untested ✗ Dismissed 📘 Rule violation ☼ Reliability
Description
The new manager_all selections redirect packaged manager aliases to cross-compiled artifacts, but
the PR adds no test that exercises the flag or verifies those resolutions. An incorrect platform
label, output path, or compatibility condition would surface only during a real --manager=all
build and could reach every language package consuming these aliases.
Code

common/manager/BUILD.bazel[15]

+        "//common:manager_all": "//rust:_xc_file-linux-x86_64",
Evidence
Compliance rule 5 requires focused regression coverage for behavioral changes. The cited files
introduce the new flag-driven routing and cross-compilation outputs, while repository search shows
manager_all only in these production build definitions and no test exercising the new selection.

AGENTS.md: Add Focused Tests for Behavioral Changes and Prefer Reliable Unit Tests
common/manager/BUILD.bazel[12-45]
rust/BUILD.bazel[24-76]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new `--manager=all` behavior routes every packaged Selenium Manager binary through cross-compilation without automated regression coverage for the selected artifacts.

## Fix Focus Areas
- common/manager/BUILD.bazel[12-45]
- rust/BUILD.bazel[24-76]

## Recommended Fix
Add focused Bazel tests that build or analyze each manager alias with `--manager=all`, verify that every alias resolves to its expected cross-compiled output, verify the macOS combined binary, and cover the declared Windows-host incompatibility.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
Review mode: ⚖️ Balanced: Downgraded extended -> standard: change is below the extended eligibility bar (hunks 12/18, lines 106/200; both must reach the floor). Router rationale: This build-system change introduces cross-compilation across multiple targets, toolchains, C dependencies, platform transitions, and release optimizations, creating many independent, easy-to-miss correctness risks.

Grey Divider

Tip of the day
💡 Did you know, you can reply 'qodo' on any finding to push back, ask questions, or dig deeper

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread common/manager/BUILD.bazel
@titusfortner titusfortner changed the title [build] add --manager=all to cross-compile every Selenium Manager binary from one host [build] add bazel flag to support cross-compiling all Selenium Manager binaries from Linux or Mac Sep 15, 2026
@titusfortner
titusfortner merged commit da30f92 into SeleniumHQ:trunk Sep 15, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-build Includes scripting, bazel and CI integrations B-manager Selenium Manager C-rust Rust code is mostly Selenium Manager

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants