Skip to content

Commit ebcdc24

Browse files
Use native CC toolchains on Windows and macOS; restrict LLVM exec to 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.
1 parent 2c7c1c0 commit ebcdc24

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

.bazelrc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ common --lockfile_mode=off
1616
# resolution on developer hosts or CI runners.
1717
common --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
1818
common --repo_env=BAZEL_NO_APPLE_CPP_TOOLCHAIN=1
19-
# On Windows re-enable MSVC CC detection so the Visual Studio toolchain
20-
# (link.exe) is available for Rust MSVC targets. The hermetic LLVM package
21-
# for Windows only provides a GNU-mode clang++ which cannot handle the
22-
# MSVC-style linker flags that rustc emits for x86_64-pc-windows-msvc.
19+
# Re-enable native CC toolchain detection on Windows and macOS. The hermetic
20+
# LLVM exec toolchain is only registered for Linux (see MODULE.bazel).
21+
# Windows: needs MSVC link.exe; the LLVM minimal package ships only a
22+
# GNU-mode clang++ that rejects /NOLOGO and backslash paths.
23+
# macOS: needs Xcode clang for compiler-rt builtins and system frameworks
24+
# (e.g. CoreServices) required by aws-lc-sys.
2325
common:windows --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=0
26+
common:macos --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=0
27+
common:macos --repo_env=BAZEL_NO_APPLE_CPP_TOOLCHAIN=0
2428

2529
# Bazel 8 compatibility flags. We should find ways to avoid needing these
2630
common --legacy_external_runfiles

MODULE.bazel

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -423,18 +423,14 @@ use_repo(rust_toolchains, "default_rust_toolchains")
423423
register_toolchains("@default_rust_toolchains//:all")
424424

425425
llvm_toolchains = use_extension("@llvm//extensions:toolchain.bzl", "toolchain")
426-
llvm_toolchains.exec(
427-
arch = "x86_64",
428-
os = "windows",
429-
)
430-
llvm_toolchains.exec(
431-
arch = "aarch64",
432-
os = "windows",
433-
)
434-
llvm_toolchains.exec(
435-
arch = "aarch64",
436-
os = "macos",
437-
)
426+
# Windows and macOS use their native toolchains (MSVC / Xcode) so that:
427+
# - Windows: link.exe handles the MSVC-ABI linker flags rustc generates for
428+
# x86_64-pc-windows-msvc (the hermetic LLVM minimal package only ships a
429+
# GNU-mode clang++ that rejects /NOLOGO and backslash paths).
430+
# - macOS: Xcode clang has access to compiler-rt builtins and system
431+
# frameworks (CoreServices etc.) that aws-lc-sys needs; the hermetic LLVM
432+
# sysroot cannot satisfy those at compile time.
433+
# LLVM exec toolchains are registered only for Linux where they work correctly.
438434
llvm_toolchains.exec(
439435
arch = "x86_64",
440436
os = "linux",

0 commit comments

Comments
 (0)