Skip to content

Target platform selection isn't working with the swiftbuild build system #8283

Closed
@cmcgee1024

Description

@cmcgee1024

Is it reproducible with SwiftPM command-line tools: swift build, swift test, swift package etc?

  • Confirmed reproduction steps with SwiftPM CLI. The description text must include reproduction steps with either of command-line SwiftPM commands, swift build, swift test, swift package etc.

Description

When using the native SwiftPM build system you can build without any target/product selector and it will build the top-level products, skipping any irrelevant targets. Also, you can select an executable target and build that. These two things are not working in the same way with the swiftbuild build system. Instead, it should behave in the same way as the native build system with target selection.

This was detected while building Swiftly, which has a Linux target that can only be built on that OS. Dependencies on that target are guarded with .when() selecting only for Linux. Depending on the way that the build is invoked with the swiftbuild build system (no target/product specified) it fails due to compile errors on missing headers. Also, when attempting to target the executable target, it indicates that it can’t find it.

Expected behavior

It is expected that since this is being built on macOS that the Linux-specific dependencies guarded by .when() will not be built and no compile errors will be found.

Actual behavior

Instead, there are compile errors regarding libarchive, a Linux-specific dependency.

Steps to reproduce

  1. Using macOS
  2. Clone and check out the version of swift-package-manager from github with swiftbuild integration code
  3. Clone swiftly from GitHub here: https://github.com/swiftlang/swiftly
  4. Run the following command to build swiftly using SwiftPM and the swift build system: swift run swift-build —build-system=swiftbuild —package-path=<path_to_swiftly>

Swift Package Manager version/commit hash

No response

Swift & OS version (output of swift --version ; uname -a)

No response

Metadata

Metadata

Assignees

Labels

bugswift buildChanges impacting `swift build`

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions