Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ build --compilation_mode opt
common --override_module=semmle_code=%workspace%/misc/bazel/semmle_code_stub

build --repo_env=CC=clang --repo_env=CXX=clang++
# The standalone Linux toolchain uses gold, which does not support the
# LLD-specific -z nostart-stop-gc workaround enabled by rules_swift.
build:linux --features=-swift.lld_gc_workaround
Comment thread
redsun82 marked this conversation as resolved.
# Disable Android SDK auto-detection (we don't use it, and rules_android has Bazel 9 compatibility issues)
build --repo_env=ANDROID_HOME=

Expand Down
8 changes: 4 additions & 4 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ local_path_override(
# see https://registry.bazel.build/ for a list of available packages

bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "rules_cc", version = "0.2.17")
bazel_dep(name = "rules_cc", version = "0.2.20")
bazel_dep(name = "rules_go", version = "0.60.0")
bazel_dep(name = "rules_java", version = "9.6.1")
bazel_dep(name = "rules_pkg", version = "1.2.0")
Expand All @@ -31,13 +31,13 @@ bazel_dep(name = "gazelle", version = "0.50.0")
bazel_dep(name = "rules_dotnet", version = "0.21.5-codeql.1")
bazel_dep(name = "googletest", version = "1.17.0.bcr.2")
bazel_dep(name = "rules_rust", version = "0.69.0")
bazel_dep(name = "rules_swift", version = "4.0.0-rc4")
bazel_dep(name = "rules_swift", version = "4.0.0-rc5")
bazel_dep(name = "swift-syntax", version = "603.0.2")

# Needed so we can `use_repo` `local_config_xcode` and
# `local_config_apple_cc_toolchains` below (referenced by the per-target
# Xcode-config transition in `unified/swift-syntax-rs/xcode_transition.bzl`).
bazel_dep(name = "apple_support", version = "2.6.1")
bazel_dep(name = "apple_support", version = "2.8.0")
bazel_dep(name = "zstd", version = "1.5.7.bcr.1")

bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)
Expand Down Expand Up @@ -238,7 +238,7 @@ use_repo(
swift = use_extension("@rules_swift//swift:extensions.bzl", "swift")
swift.toolchain(
name = "swift_toolchain",
swift_version = "6.3.2",
swift_version = "6.3.3",
)
use_repo(
swift,
Expand Down
2 changes: 1 addition & 1 deletion unified/swift-syntax-rs/.swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.3.2
6.3.3
19 changes: 15 additions & 4 deletions unified/swift-syntax-rs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test")
load("//unified:platforms.bzl", "UNIFIED_SUPPORTED_PLATFORMS")
load(":swift_runtime.bzl", "swift_runtime_libs")
load(":swift_runtime_linking.bzl", "swift_runtime_linking")
load(":xcode_transition.bzl", "xcode_transition_swift_library")

package(default_visibility = ["//visibility:public"])
Expand All @@ -11,15 +12,25 @@ swift_runtime_libs(
toolchain = "@swift_toolchain_ubuntu22.04//:files",
)

# The `$ORIGIN` runpath makes an executable look beside itself instead, so
# we find the Swift runtime libraries we bundle with the extractor.
swift_runtime_linking(
name = "_swift_runtime_cc_info",
target_compatible_with = ["@platforms//os:linux"],
visibility = ["//visibility:private"],
)

# On Linux, provide the downloaded Swift runtime at link time and look beside
# the executable for the copies bundled with the extractor at runtime.
cc_library(
name = "swift_runtime_rpath",
name = "swift_runtime_linking",
linkopts = select({
"@platforms//os:linux": ["-Wl,-rpath,$$ORIGIN"],
"//conditions:default": [],
}),
target_compatible_with = UNIFIED_SUPPORTED_PLATFORMS,
deps = select({
"@platforms//os:linux": [":_swift_runtime_cc_info"],
"//conditions:default": [],
}),
)

# Swift FFI shim: wraps swift-syntax and exposes a small C ABI.
Expand All @@ -46,7 +57,7 @@ rust_library(
edition = "2024",
target_compatible_with = UNIFIED_SUPPORTED_PLATFORMS,
deps = [
":swift_runtime_rpath",
":swift_runtime_linking",
":swift_syntax_ffi",
],
)
Expand Down
2 changes: 1 addition & 1 deletion unified/swift-syntax-rs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ The build does not depend on any particular version manager. You need:
- **Rust** — pinned to `1.88` by the repo-root [`rust-toolchain.toml`](../../rust-toolchain.toml),
which `rustup` picks up automatically.
- **Swift** — pinned to the version in [`.swift-version`](.swift-version)
(currently `6.3.2`), used to build `swift-syntax` `603.0.2`. Install it any way
(currently `6.3.3`), used to build `swift-syntax` `603.0.2`. Install it any way
you like — [swift.org](https://www.swift.org/install/) or
[swiftly](https://www.swift.org/swiftly/) (which reads `.swift-version`), or a
system package. Just make sure `swift` (and `swiftc`) are on your `PATH` —
Expand Down
11 changes: 11 additions & 0 deletions unified/swift-syntax-rs/swift_runtime_linking.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""Expose the selected Swift toolchain's dynamic runtime to native dependents."""

load("@rules_swift//swift:swift.bzl", "swift_common")

def _swift_runtime_linking_impl(ctx):
return [swift_common.get_toolchain(ctx).dynamic_runtime_cc_info]

swift_runtime_linking = rule(
implementation = _swift_runtime_linking_impl,
toolchains = swift_common.use_toolchain(),
)
Loading