Skip to content

feat: add Linux x86_64 support to the prebuilt archive#20

Open
luispadron wants to merge 4 commits into
mainfrom
luis/linux-support
Open

feat: add Linux x86_64 support to the prebuilt archive#20
luispadron wants to merge 4 commits into
mainfrom
luis/linux-support

Conversation

@luispadron
Copy link
Copy Markdown
Collaborator

Summary

  • Refactors build.sh into two phases: build (per-platform binary build, run once per TARGET_PLATFORM) and package (combines staged platform tarballs into the final release archive).
  • The released tarball now ships per-platform subdirs (macos-arm64/, linux-x86_64/) of .a / .swiftinterface / .swiftdoc. The generated BUILD.bazel uses select() over @platforms//os + @platforms//cpu config_settings so a single archive_override URL works for any consumer.
  • Updates dry-run.yml and build-publish.yml to fan out to a macOS job + a Linux job, then fan in to a single packaging/publish job. Linux uses swift-actions/setup-swift@v2 for the Swift toolchain and pulls a static buildozer release.
  • Patches the apple/swift-syntax checkout's BUILD.bazel and utils/bazel/swift_syntax_library.bzl on Linux builds to drop the @build_bazel_rules_apple load + ios_xctestrun_runner / ios_unit_test references that the prebuilt doesn't need.
  • README updated to document the supported platforms and the two build phases.

Why

Consuming the current prebuilt on a Linux Bazel build fails with module 'SwiftSyntax' was created for incompatible target arm64-apple-macos13.0, because the .a and .swiftinterface files in the archive are arm64-apple-macos only. Downstream repos that want to run their Bazel build on Blox/Linux runners have had to work around this by skipping the archive_override on Linux. With per-platform artifacts, that workaround can go away.

Test plan

  • dry-run workflow runs on this PR (validates both build-macos-arm64 + build-linux-x86_64 jobs and the package fan-in step end-to-end).
  • Manually gh workflow run build-publish.yml against a test tag/build-number and verify the published archive's BUILD.bazel resolves the right artifacts on both macOS and Linux consumers.

Refactors build.sh into two phases (build, package) so per-platform builds can run on heterogeneous CI runners (macOS for darwin-arm64, Linux for linux-x86_64) and a final packaging job fans them in. The released tarball now ships per-platform subdirectories of .a / .swiftinterface / .swiftdoc plus a BUILD.bazel that uses select() on (os, cpu) constraints, so a single archive_override works for both macOS and Linux consumers.
Comment thread .github/workflows/build-publish.yml Fixed
Comment thread .github/workflows/dry-run.yml Fixed
Comment thread .github/workflows/build-publish.yml Fixed
Comment thread .github/workflows/dry-run.yml Fixed
Comment thread .github/workflows/build-publish.yml Fixed
Comment thread .github/workflows/build-publish.yml Fixed
Comment thread .github/workflows/build-publish.yml Fixed
Comment thread .github/workflows/dry-run.yml Fixed
luispadron added 2 commits May 5, 2026 22:55
Addresses CodeQL / zizmor / Semgrep findings on the workflows: defaults GITHUB_TOKEN to contents:read, opts the publish job into contents:write for gh release create, pins swift-actions/setup-swift to a commit SHA, and hoists workflow_dispatch inputs into env vars in the publish step's run block to avoid shell-context-variable injection.
Three fixes from the first dry-run on the PR:

- Linux: rules_swift's local toolchain refuses to configure with the
  default ubuntu-latest gcc, so install clang and set CC/CXX=clang(++)
  for the build job.

- macOS: querying swift_library + cc_library together via cquery
  set(...) caused the cc_library outputs to land under ios_sim_arm64.
  Build and query the swift labels and cc_library deps separately so
  each gets its native config.

- Both: process-substitution swallowed cquery non-zero exits, which is
  how the Linux dry-run silently produced an empty staging tarball.
  Capture cquery output into a variable, fail fast on empty results.
@luispadron luispadron marked this pull request as ready for review May 6, 2026 03:23
Three fixes:

- macOS build.sh: skip cquery output paths that point at the ios_sim_arm64
  apple-transition variant of cc_library deps (those weren't built by our
  darwin-only `bazel build`, so the cp would fail). Restores the original
  -f guard.
- Linux build.sh: drop *TestSupport* targets from the build set. Linux
  Foundation (swift-corelibs-foundation) isn't compiled with library
  evolution, so any target that imports Foundation fails to compile under
  swift.enable_library_evolution. Downstream consumers that need test
  support on Linux can build from source.
- Semgrep shell-injection: funnel workflow_dispatch \`inputs.tag\` and
  static \`env.SWIFT_SYNTAX_VERSION\` through explicit env vars instead of
  expanding \`\${{ ... }}\` directly in the Clone SwiftSyntax shell bodies
  of build-publish.yml and dry-run.yml.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants