diff --git a/.bazelrc b/.bazelrc index 7bf16241..9958913d 100644 --- a/.bazelrc +++ b/.bazelrc @@ -37,6 +37,12 @@ build --tool_java_runtime_version=remotejdk_25 # Platform-specific C++ standard flags build:macos --cxxopt=-std=c++20 build:macos --host_cxxopt=-std=c++20 +# Apple's ld (MODULE.bazel extra_link_flags --ld-path=/usr/bin/ld) does not +# accept lld's --start-lib/--end-lib. Disabling this feature is a no-op for +# toolchains that never advertised it (wasm/emscripten) and only skips an +# lld grouping optimization elsewhere. Do not put --ld-path here: it would +# leak into wasm transitions via enable_platform_specific_config. +build:macos --features=-supports_start_end_lib build:linux --cxxopt=-std=c++20 build:linux --host_cxxopt=-std=c++20 # Windows MSVC C++20 comes from the patched rules_cc default_cpp_std feature diff --git a/MODULE.bazel b/MODULE.bazel index 0ca9fd02..2b23e877 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -76,6 +76,16 @@ llvm.toolchain( # When bumping these versions, also update .bazelrc build:tsan_macos rpath # (clang/N) and confirm Xcode ships the same major; see docs/BUILD_SYSTEM.md. # Keep MSAN_LLVM_VERSION / MSAN_DISTRIBUTION below on the same LLVM release. + # LLVM 21 ld64.lld cannot parse MacOSX 27 SDK TBD files that list + # arm64e.x1. Apple's ld can; last --ld-path wins over the toolchain default + # --ld-path=ld64.lld. Pair with .bazelrc --features=-supports_start_end_lib + # because Apple ld rejects lld's --start-lib/--end-lib. Scoped to this + # toolchain so wasm/emscripten keeps wasm-ld (do not put --ld-path in + # build:macos --linkopt). See docs/BUILD_SYSTEM.md (macOS SDK section). + extra_link_flags = { + "darwin-aarch64": ["--ld-path=/usr/bin/ld"], + "darwin-x86_64": ["--ld-path=/usr/bin/ld"], + }, llvm_versions = { "darwin-aarch64": "21.1.8", "linux-x86_64": "21.1.8", diff --git a/docs/BUILD_SYSTEM.md b/docs/BUILD_SYSTEM.md index f098906e..6121852d 100644 --- a/docs/BUILD_SYSTEM.md +++ b/docs/BUILD_SYSTEM.md @@ -64,6 +64,17 @@ If you see runtime loader failures after a toolchain or OS change: 2. Re-resolve Bazel toolchains (`bazelisk shutdown`, then `bazelisk clean --expunge`). 3. Re-run `bazelisk test //...` to confirm runtime compatibility. +**Xcode 27 / MacOSX 27 SDK TBD files.** The macOS 27 SDK lists `arm64e.x1` in +system `.tbd` stubs. LLVM 21's `ld64.lld` rejects those files (`unknown +architecture arm64e.x1`) and then reports a cascade of missing libc++ / +libSystem symbols. Native Darwin links therefore use Apple's `/usr/bin/ld` +via `llvm.toolchain.extra_link_flags` in `MODULE.bazel`, and `.bazelrc` +disables Bazel's `supports_start_end_lib` feature (Apple ld does not accept +`--start-lib` / `--end-lib`). That `--ld-path` override is toolchain-scoped +on purpose: putting it in `build:macos --linkopt` would leak into wasm +transitions and replace `wasm-ld`. Drop both workarounds when LLVM's Mach-O +linker can parse `arm64e.x1` TBD targets. + ### AddressSanitizer, ThreadSanitizer, UndefinedBehaviorSanitizer, and MemorySanitizer Sanitizer builds use `--config=asan`, `--config=tsan`, `--config=ubsan`, or