@@ -34,18 +34,6 @@ bazel_dep(name = "rules_rust", version = "0.69.0")
3434bazel_dep (name = "rules_swift" , version = "4.0.0-rc4" )
3535bazel_dep (name = "swift-syntax" , version = "602.0.0.bcr.2" )
3636
37- # rules_swift 4.0.0-rc4's standalone toolchain extension unconditionally
38- # emits Linux/ELF-only linker flags (swiftrt.o, -lstdc++, -lrt, -ldl,
39- # -static-libgcc) for its macOS toolchain, which breaks any binary linked
40- # via `swift_library` on macOS. Apply a local patch that skips those flags
41- # when the toolchain OS is macos. See the patch header and
42- # `misc/bazel/patches/rules_swift/macos-linkopts.patch` for details.
43- single_version_override (
44- module_name = "rules_swift" ,
45- patch_strip = 1 ,
46- patches = ["//misc/bazel/patches/rules_swift:macos-linkopts.patch" ],
47- version = "4.0.0-rc4" ,
48- )
4937bazel_dep (name = "zstd" , version = "1.5.7.bcr.1" )
5038
5139bazel_dep (name = "buildifier_prebuilt" , version = "6.4.0" , dev_dependency = True )
@@ -239,16 +227,28 @@ use_repo(
239227# `rules_swift` standalone-toolchain extension and is independent of the
240228# patched prebuilt toolchain wired up via `swift_deps` above.
241229#
242- # Bazel cannot auto-select between Linux distributions, so the toolchain is
243- # registered explicitly for the distributions/platforms our CI runs on:
244- # - ubuntu24.04 / x86_64 (Linux CI)
245- # - xcode (macOS CI — covers both Apple Silicon and Intel)
230+ # We register the `exec` toolchain for **Linux only**. On macOS we do NOT
231+ # use this standalone toolchain: it is the Unix-shaped `swift_toolchain`
232+ # rule (`swift/toolchains/swift_toolchain.bzl`) which emits Linux/ELF
233+ # linkopts (`swiftrt.o`, `-lstdc++`, `-lrt`, `-ldl`, `-static-libgcc`) and
234+ # a Linux-shaped `-L{root}/lib/swift/{os}` search path — none of which make
235+ # sense on macOS. Instead, on macOS we rely on rules_swift's auto-registered
236+ # `@rules_swift//swift/toolchains:xcode-toolchain-*` toolchains (backed by
237+ # `xcode_swift_toolchain.bzl`, which has its own macOS-aware
238+ # `_swift_linkopts_cc_info` that uses the Apple linker's autolinking,
239+ # points at `Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx`,
240+ # and rpaths the OS-provided `/usr/lib/swift`). Those toolchains are
241+ # auto-registered by rules_swift's own MODULE.bazel via
242+ # `register_toolchains("//swift/toolchains:all")` and use the Xcode
243+ # selected on the host, so macOS contributors need a working Xcode
244+ # (or Command Line Tools) install.
246245#
247- # NOTE: The macOS toolchain is distributed as a `.pkg` archive that can only
248- # be extracted on a macOS host. Do not build the `xcode` toolchain on Linux.
246+ # NOTE: The macOS standalone toolchain is distributed as a `.pkg` archive
247+ # that can only be extracted on a macOS host. Do not build the `xcode`
248+ # standalone toolchain on Linux.
249249#
250- # We register the `exec` toolchains (normal host compilation) rather than the
251- # `embedded` ones , which target `os:none` (Embedded Swift) and would not
250+ # We register the `exec` toolchain (normal host compilation) rather than the
251+ # `embedded` one , which targets `os:none` (Embedded Swift) and would not
252252# match a normal host build. Bazel selects the toolchain matching the host
253253# platform automatically.
254254#
@@ -264,12 +264,10 @@ use_repo(
264264 swift ,
265265 "swift_toolchain" ,
266266 "swift_toolchain_ubuntu24.04" ,
267- "swift_toolchain_xcode" ,
268267)
269268
270269register_toolchains (
271270 "@swift_toolchain//:swift_toolchain_exec_ubuntu24.04" ,
272- "@swift_toolchain//:swift_toolchain_exec_xcode" ,
273271)
274272
275273node = use_extension ("@rules_nodejs//nodejs:extensions.bzl" , "node" )
0 commit comments