Repository navigation
Description
Blocked on: bazelbuild/rules_swift#1993
Goal: open the upstream rules_swift issue and small PRs that let standalone_toolchain build against a caller's Linux sysroot, and fix the dead root-only guard. No rules_dx code changes; rules_dx already carries the working local toolchain in swift/toolchain/toolchain.bzl.
Plan (agent): size M
Decision: add two optional passthrough attrs on upstream standalone_toolchain: sysroot (label of the sysroot's files) and env (string_dict). The template derives sdkroot from the label's workspace_root. Rejected: an sdkroot string plus a separate files label (two attrs that can drift apart); having upstream always use its own @swift_ubuntu*_sysroot for -sdk (our sysroot has extra host_libs/link_libs packages, and it would give one build two sysroots); patches or git_override in rules_dx (root-only, so consumers would not get them).
Cause: upstream swift/internal/extensions/toolchain.BUILD swift_toolchain_exec has no sdkroot, so -sdk comes from the resolved cc toolchain (--sysroot=/dev/null under @llvm, via PR bazelbuild/rules_swift#1913). Upstream swift/extensions.bzl:133 tests not module_ctx.is_dev_dependency without calling it, so the check is always false.
Change:
- Open the upstream issue in bazelbuild/rules_swift. Cover (a) no way to set the sdkroot, sysroot inputs or env on
standalone_toolchain's exec toolchain when the resolved cc toolchain is notcc_toolchain_exec, (b) the guard bug, (c) a question: canstandalone_toolchainbecome public API? rules_dx loads it fromswift/internal/.... Include a minimal repro (aquery: a SwiftCompile with-sdk /dev/nullunder a rules-based cc toolchain). - PR A (fork
TrapsterDK/rules_swift, follow CONTRIBUTING.md and use buildifier): inswift/internal/extensions/standalone_toolchain.bzl, add optionalsysroot = attr.label()andenv = attr.string_dict(). Substitute{sdkroot}(fromattr.sysroot.workspace_root, or""when unset),{sysroot_inputs}and{env}intotoolchain.BUILD. Feed them only toswift_toolchain_exec(sdkroot,env) and to a separate execswift_tools(additional_inputs). Leave the embedded toolchain and the default (unset) behaviour byte-identical. Regression test: follow the pattern intest/swift_toolchain_tests.bzlfrom #1687: Use a shared real Starlark parser for MODULE dependency reads and version edits #1913. Add a dev-depstandalone_toolchaininstance (or a template-render unit test) that asserts SwiftCompile argv carries-sdk <sysroot root>and that the sysroot files are action inputs. If reviewers push back onenv, move it to its own PR. - PR B: fix the guard. For each non-root module, fail if any
toolchaintag hasnot module_ctx.is_dev_dependency(tag). Pull the check into a pure helper and unit-test it with skylibunittest, as intest/utils_tests.bzl. In the PR body, say that this can newly fail downstream modules that use the extension without dev_dependency. - Link the upstream issue and both PRs on swift: upstream a sysroot hook for rules_swift standalone_toolchain #5714.
Tests: in the rules_swift clone,bazel test //test:all(Linux), plus buildifier --lint=warn. No rules_dx tests.
Host: none (Linux-only paths; upstream CI covers macOS).
Upstream: this slice is the upstream work. The owner's Google CLA is already on file (merged Fix rust-analyzer proc-macro merge for k8-opt-exec paths bazelbuild/rules_rust#4140).
Part of #5714
Activity
TrapsterDK commentedon Nov 5, 2026
Upstream work is already open: issue bazelbuild/rules_swift#1991, guard fix #1992, sysroot/env hook #1993 (1993 includes a test in test/utils_tests.bzl). No rules_dx code change is needed. Waiting on upstream review; #6528 follows after a release. Left open until the upstream PRs merge.
Assisted by Claude.
TrapsterDK commentedon Nov 5, 2026
Upstream status (no rules_dx code needed, does not gate #1853):
bazel test //test:all.Leaving open as a child of swift: upstream a sysroot hook for rules_swift standalone_toolchain #5714.
TrapsterDK commentedon Nov 5, 2026
Still waiting on upstream bazelbuild/rules_swift#1992 and #1993 review; no rules_dx change remains. Marked blocked.
Assisted by Claude.
github-actions commentedon Nov 5, 2026
This issue has the
blockedlabel but noBlocked on:line in its body. Add one naming the blocking issue (#N), a pull request URL, or the owner action. See CONTRIBUTING.md.TrapsterDK commentedon Nov 9, 2026
The guard fix bazelbuild/rules_swift#1992 was closed without merging. bazelbuild/rules_swift#1996 (non-root
swift.toolchain) replaces it. rules_dx carries #1993 and #1996 as local patches on rules_swift 4.2.2 in #9375.Assisted by Claude.
TrapsterDK commentedon Nov 9, 2026
Done: the upstream issue and PRs exist.
sysrootandenvtoswift.toolchain.swift.toolchainfrom non-root modules). keith's question there was answered on 2026-11-06.patches/rules_swift/), which closed swift: upstream a sysroot hook for rules_swift standalone_toolchain #5714.#6528 tracks the upstream merge, the release and dropping the patches, so nothing is left here. The
standalone_toolchainplan above is superseded.Assisted by Claude.