Skip to content

swift-tools-version behavior differs from SE-0209 #7869

@norio-nomura

Description

@norio-nomura

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 building the release/6.0 branch of swift-syntax using Xcode 16 beta 5, the build process includes the -swift-version 6 flag. However, according to SE-0209, this should not be the case.

Referring to Example 4 in SE-0209:

Example 4:

// swift-tools-version:4.2

import PackageDescription

let package = Package(
    name: "HTTPClient",
    ...
    swiftLanguageVersions: [.v4, .version("5")]
)

The sources will be compiled with -swift-version 4.

In alignment with this example, the release/6.0 branch of swift-syntax, which has // swift-tools-version:5.7 in its Package.swift, should be built with the -swift-version 5 flag. However, this is not the case, and the build process uses -swift-version 6 instead.

While I personally believe the current behavior might be more correct, it still represents a deviation from the behavior specified in SE-0209, which could be problematic.

Expected behavior

No response

Actual behavior

swift-build --verbose outputs logs using "-swift-version 6"

Steps to reproduce

  1. git clone https://github.com/swiftlang/swift-syntax.git -b release/6.0
  2. cd swift-syntax
  3. swift build --verbose | grep -e "-swift-version 6"

Swift Package Manager version/commit hash

Swift Package Manager - Swift 6.0.0-dev

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

swift-driver version: 1.113 Apple Swift version 6.0 (swiftlang-6.0.0.7.6 clang-1600.0.24.1)
Target: arm64-apple-macosx15.0
Darwin norio-nomura-MacBook-Pro.local 24.0.0 Darwin Kernel Version 24.0.0: Wed Jul 31 21:50:55 PDT 2024; root:xnu-11215.0.199.501.2~1/RELEASE_ARM64_T6020 arm64

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions