Skip to content

[rust] Allow cross-compilation of selenium-manager on all platforms#17586

Open
AutomatedTester wants to merge 18 commits into
trunkfrom
worktree-pr-17427-cross-compile
Open

[rust] Allow cross-compilation of selenium-manager on all platforms#17586
AutomatedTester wants to merge 18 commits into
trunkfrom
worktree-pr-17427-cross-compile

Conversation

@AutomatedTester
Copy link
Copy Markdown
Member

Summary

Taking over #17427 from @shs96c who was unable to complete it.

This PR enables cross-compilation of selenium-manager from any host platform to all target platforms (Linux x86_64/aarch64, macOS aarch64, Windows x86_64/aarch64) using the hermetic LLVM toolchain.

Key changes (from Simon's original work)

  • Upgrades rules_rs 0.0.61 → 0.0.76 and llvm 0.7.9 → 0.8.0
  • Registers LLVM exec toolchains for Linux (x86_64, aarch64) and macOS (aarch64)
  • Adds cross-compile targets for all five platforms in rust/BUILD.bazel
  • Restructures language binding (py, rb, dotnet, java) BUILD files to consume a per-arch bundle
  • On Windows, uses native MSVC build for the host arch and stubs the rest (cross-compile from Linux for releases)
  • Adds musl targets for Linux (no glibc dependency) and gnullvm targets for Windows

Fixes applied in this PR (on top of Simon's work)

  • windows-link/windows-targets patches: The original patches changed include_str!("../readme.md")include_str!("../README.md") but the crate only ships readme.md and Bazel's Rust sandbox doesn't include non-source files anyway. Fixed by removing the doc attribute entirely.
  • Windows MSVC linker: The hermetic LLVM package for Windows provides only a GNU-mode clang++.exe which can't handle MSVC-style linker flags (/NOLOGO, .lib files). Re-enabled MSVC CC auto-detection on Windows so Visual Studio's link.exe is used for MSVC targets.

Known remaining issues

  • macOS Rust tests: aws-lc-sys (pulled in transitively through reqwestrustlsrustls-platform-verifier) requires CoreServices.framework which is not in the hermetic LLVM macOS SDK sysroot. Adding the aarch64 macOS exec LLVM toolchain (new in this PR) causes this to surface. Fixing requires either a different TLS cert backend or a richer macOS sysroot — tracked as a follow-up.

Closes #17427

shs96c and others added 17 commits May 8, 2026 12:39
* origin/trunk: (97 commits)
  [py] update python dependencies (#17490)
  [build] fix renovate reported issues with configuration
  [build] remove base-ref from renovate workflows it does not work for the use case I had for them
  [build] add renovate dependency workflow (#17504)
  [build] simplify commit-changes workflow (#17503)
  [build] clarify dependency pin and update tasks (#17463)
  [build] do not rerun or attempt to upload logs unless workflow failure is from the Bazel step
  [build] fix renovate ignore rules_python to v2 until upstream fixed
  [build] renovate ignore rules_python until upstream fixed
  [build] bump rules_closure version (#17500)
  [build] bump rules_jvm_external (#17501)
  [js] remove npm dependency by using bazel for everything (#17499)
  [build] bump ruby versions to latest patch releases (#17496)
  [dotnet] [build] Support deterministic build output (#17497)
  [build] remove renovate update requests pending work done in #17427 (#17498)
  [dotnet] [build] Fix remote linkage in SourceLink (#17495)
  [rust] update reqwest to 0.13 (#17488)
  [build] bump low-risk Bazel module dependencies (#17494)
  [dotnet] run format against slnx instead of looping csproj (#17483)
  [build] ignore renovate.json references in renovate recommendations
  ...

# Conflicts:
#	MODULE.bazel
#	rust/BUILD.bazel
The windows-link/windows-targets patches were changing include_str! from
lowercase readme.md to uppercase README.md, but:
1. The crate only ships readme.md (lowercase), and
2. Bazel's Rust sandbox does not include non-source files like README
   regardless of case, so include_str! always fails.

Fix: patch out the doc attribute entirely.

On Windows, the LLVM toolchain package only provides a GNU-mode clang++
(-target x86_64-w64-windows-gnu) which cannot handle the MSVC-style linker
flags (/NOLOGO, .lib files) that rustc emits for x86_64-pc-windows-msvc
targets. Re-enable MSVC auto-detection on Windows so Visual Studio's
link.exe is available for rustc when building native Windows targets.
@selenium-ci selenium-ci added C-py Python Bindings C-rb Ruby Bindings C-dotnet .NET Bindings C-java Java Bindings C-nodejs JavaScript Bindings B-build Includes scripting, bazel and CI integrations C-rust Rust code is mostly Selenium Manager B-manager Selenium Manager labels May 28, 2026
…Linux

The hermetic LLVM exec toolchains for Windows and macOS cause build failures:

- Windows: the minimal LLVM package ships only a GNU-mode clang++ that
  rejects MSVC-style linker flags (/NOLOGO, backslash paths, .lib files)
  generated by rustc for x86_64-pc-windows-msvc targets. Removing the
  Windows LLVM exec toolchain registrations and keeping the existing
  BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=0 override allows Bazel to detect
  Visual Studio's link.exe on Windows runners.

- macOS: the hermetic LLVM sysroot lacks compiler-rt builtins at the path
  aws-lc-sys's build script expects (configuration hash mismatch between the
  build-script exec config and the main build config). It also lacks system
  frameworks like CoreServices required by aws-lc-sys. Removing the macOS
  LLVM exec toolchain registration and re-enabling Xcode CC detection
  (BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=0, BAZEL_NO_APPLE_CPP_TOOLCHAIN=0)
  lets macOS runners use Xcode clang which has full system access.

LLVM exec toolchains are kept only for Linux where they work correctly and
are required for the musl cross-compilation targets.
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-dotnet .NET Bindings C-java Java Bindings C-nodejs JavaScript Bindings C-py Python Bindings C-rb Ruby Bindings C-rust Rust code is mostly Selenium Manager

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants