Skip to content

Merge main to 6.2 #8516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 34 commits into
base: release/6.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a0fbf35
Minor Codable conformance improvements in SwiftBuildSupport (#8449)
pmattos Apr 4, 2025
c8d439a
Switch to ProjectModel API in the new SwiftBuildSupport PIF builder (…
pmattos Apr 5, 2025
60976ee
Tests: Enabled SourceControlTests on Windows (#8453)
bkhouri Apr 8, 2025
d4368fe
Clarify documented behavior of versioned manifest files in usage docs…
stmontgomery Apr 8, 2025
4511962
Tests: Enable some WorkspaceTests on Windows (#8463)
bkhouri Apr 9, 2025
cc0b1a5
Tests: Enable tests on Windows (#8466)
bkhouri Apr 9, 2025
21e3336
SwiftSDK: Remove hardcoded WASI sysroot path derivation (#8468)
kateinoigakukun Apr 9, 2025
e303b89
Copy helpers internally (#8467)
bkhouri Apr 9, 2025
cd5d9dd
Revert "Copy helpers internally" (#8474)
nate-chandler Apr 9, 2025
a0d1600
Fix duplicate modulemap errors with macro and plugin deps (#8472)
dschaefer2 Apr 10, 2025
1d48e0a
Copy helpers internally (#8476)
bkhouri Apr 11, 2025
6dfb613
Fix `SwiftBuildSupport/README.md` (#8483)
MaxDesiatov Apr 12, 2025
57a67b4
Fix bootstrapping on OpenBSD (#8451)
3405691582 Apr 14, 2025
3d063d0
Link test command test failures on Linux to issue (#8459)
cmcgee1024 Apr 14, 2025
49e69c7
Revert "Copy helpers internally" again (#8494)
pmattos Apr 14, 2025
453e6d3
Tests: Split SerializedJSONTests (#8496)
bkhouri Apr 15, 2025
b69b792
Mark skipped test with a GitHub issue (#8502)
bkhouri Apr 15, 2025
dec1ded
Improve Swift Build error formatting (#8493)
pmattos Apr 15, 2025
1befa52
Docs: Refer to swiftly in CONTRIBUTING.md (#8504)
bkhouri Apr 16, 2025
8432220
Test: Enable ConcurrencyHelpersTests on Windows (#8506)
bkhouri Apr 16, 2025
6245fa9
Really fix duplicate module maps this time. (#8498)
dschaefer2 Apr 16, 2025
e842b0e
Implement --enable-parseable-module-interfaces for swift-build builds…
daveinglis Apr 16, 2025
861a871
Add `swift test --attachments-path`. (#8492)
grynspan Apr 16, 2025
0b23073
Tests: Ensure we get clean test fixtures (#8507)
pmattos Apr 17, 2025
f673bf6
Revert "Really fix duplicate module maps this time." (#8517)
dschaefer2 Apr 17, 2025
393a8f3
Adopt new PIF builder in SwiftBuildSupport (#8454)
pmattos Apr 17, 2025
2c4c785
Tests: Fix 22 warning in BuildCommandTests (#8509)
pmattos Apr 17, 2025
9fb4efb
Add an .editorconfig file
jakepetroules Apr 17, 2025
95ce2a3
Make sure the workspace state is saved after adding/removing artifact…
shawnhyam Apr 18, 2025
b938328
build-using-self use a self build of swift-test instead (#8548)
dschaefer2 Apr 23, 2025
2bc3390
Disable failing SwiftBuild test on AmazonLinux 2 (#8546)
bkhouri Apr 23, 2025
ffdc0c0
Tests: Run packageInitExecutable test on all platforms for native bui…
pmattos Apr 23, 2025
6b256f3
Adopt MemberImportVisibility (#8525)
plemarquand Apr 23, 2025
7998442
Merge branch 'main' into merge-main-to-6.2
dschaefer2 Apr 23, 2025
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
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
xcode_trim_whitespace_on_empty_lines = true

[*.{yml,yaml}]
indent_size = 2
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ $> swift --version
Apple Swift version 5.3
```

Note: Alternatively use tools like [swiftenv](https://github.com/kylef/swiftenv) that help manage toolchains versions.
Note: Alternatively use tools like [swiftly](https://www.swift.org/swiftly/documentation/swiftlydocs/) that help manage toolchains versions.

## Local Development

Expand Down
26 changes: 17 additions & 9 deletions Documentation/Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ This feature is intended for use in the following scenarios:

It is *not* expected that the packages would ever use this feature unless absolutely
necessary to support existing clients. Specifically, packages *should not*
adopt this syntax for tagging versions supporting the _latest GM_ Swift
adopt this syntax for tagging versions supporting the _latest released_ Swift
version.

The package manager supports looking for any of the following marked tags, in
Expand All @@ -511,7 +511,7 @@ order of preference:

The package manager will additionally look for a version-specific marked
manifest version when loading the particular version of a package, by searching
for a manifest in the form of `Package@swift-3.swift`. The set of markers
for a manifest in the form of `Package@swift-6.swift`. The set of markers
looked for is the same as for version-specific tag selection.

This feature is intended for use in cases where a package wishes to maintain
Expand All @@ -521,20 +521,28 @@ changes in the manifest API).

It is *not* expected the packages would ever use this feature unless absolutely
necessary to support existing clients. Specifically, packages *should not*
adopt this syntax for tagging versions supporting the _latest GM_ Swift
adopt this syntax for tagging versions supporting the _latest released_ Swift
version.

In case the current Swift version doesn't match any version-specific manifest,
the package manager will pick the manifest with the most compatible tools
version. For example, if there are three manifests:

`Package.swift` (tools version 3.0)
`Package@swift-4.swift` (tools version 4.0)
`Package@swift-4.2.swift` (tools version 4.2)
- `Package.swift` (tools version 6.0)
- `Package@swift-5.10.swift` (tools version 5.10)
- `Package@swift-5.9.swift` (tools version 5.9)

The package manager will pick `Package.swift` on Swift 3, `[email protected]` on
Swift 4, and `[email protected]` on Swift 4.2 and above because its tools
version will be most compatible with future version of the package manager.
The package manager will pick `Package.swift` on Swift 6 and above, because its
tools version will be most compatible with future version of the package manager.
When using Swift 5.10, it will pick `[email protected]`. Otherwise, when
using Swift 5.9 it will pick `[email protected]`, and this is the minimum
tools version this package may be used with.

A package may have versioned manifest files which specify newer tools versions
than its unversioned `Package.swift` file[^1]. In this scenario, the manifest
corresponding to the newest-compatible tools version will be used.

[^1]: Support for having a versioned manifest file with a _newer_ tools version was required when the feature was first introduced, because prior versions of the package manager were not aware of the concept and only knew to look for the unversioned `Package.swift`. This is still supported, but there have been many Swift releases since the feature was introduced and it is now considered best practice to have `Package.swift` declare the newest-supported tools version and for versioned manifest files to only specifer older versions.

## Editing a Package

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public let lldb: AbsolutePath = {
}()

public let swiftpmBinaryDirectory: AbsolutePath = {
if let environmentPath = ProcessInfo.processInfo.environment["SWIFTPM_BIN_DIR"] {
if let environmentPath = ProcessInfo.processInfo.environment["SWIFTPM_CUSTOM_BIN_DIR"] {
return try! AbsolutePath(validating: environmentPath)
}

Expand Down
2 changes: 1 addition & 1 deletion IntegrationTests/Tests/IntegrationTests/BasicTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private struct BasicTests {
}

@Test(
.skipHostOS(.windows, "'try!' expression unexpectedly raised an error: TSCBasic.Process.Error.missingExecutableProgram(program: \"which\")"),
.skipHostOS(.windows, "'try!' expression unexpectedly raised an error: TSCBasic.Process.Error.missingExecutableProgram(program: \"which\")")
)
func testSwiftCompiler() throws {
try withTemporaryDirectory { tempDir in
Expand Down
101 changes: 58 additions & 43 deletions IntegrationTests/Tests/IntegrationTests/SwiftPMTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,64 +75,79 @@ private struct SwiftPMTests {
}

@Test(
.requireThreadSafeWorkingDirectory,
arguments: [BuildSystemProvider.native]
)
func packageInitExecutable(_ buildSystemProvider: BuildSystemProvider) throws {
try _packageInitExecutable(buildSystemProvider)
}

@Test(
.skipHostOS(.windows),
.requireThreadSafeWorkingDirectory,
.bug(
"https://github.com/swiftlang/swift-package-manager/issues/8416",
"swift run using --build-system swiftbuild fails to run executable"
"[Linux] swift run using --build-system swiftbuild fails to run executable"
),
arguments: BuildSystemProvider.allCases
.bug(
"https://github.com/swiftlang/swift-package-manager/issues/8514",
"[Windows] Integration test SwiftPMTests.packageInitExecutable with --build-system swiftbuild is skipped"
),
arguments: [BuildSystemProvider.swiftbuild]
)
func packageInitExecutable(_ buildSystemProvider: BuildSystemProvider) throws {
// Executable
do {
try withTemporaryDirectory { tmpDir in
let packagePath = tmpDir.appending(component: "foo")
try localFileSystem.createDirectory(packagePath)
try sh(swiftPackage, "--package-path", packagePath, "init", "--type", "executable")
try sh(swiftBuild, "--package-path", packagePath, "--build-system", buildSystemProvider.rawValue)

try withKnownIssue("Error while loading shared libraries: libswiftCore.so: cannot open shared object file: No such file or directory") {
// The 'native' build system uses 'swiftc' as the linker driver, which adds an RUNPATH to the swift runtime libraries in the SDK.
// 'swiftbuild' directly calls clang, which does not add the extra RUNPATH, so runtime libraries cannot be found.
let (stdout, stderr) = try sh(
swiftRun, "--package-path", packagePath, "--build-system", buildSystemProvider.rawValue
)
#expect(!stderr.contains("error:"))
#expect(stdout.contains("Hello, world!"))
} when: {
buildSystemProvider == .swiftbuild && ProcessInfo.hostOperatingSystem == .linux
}
func packageInitExecutablSkipWindows(_ buildSystemProvider: BuildSystemProvider) throws {
try _packageInitExecutable(buildSystemProvider)
}

private func _packageInitExecutable(_ buildSystemProvider: BuildSystemProvider) throws {
try withTemporaryDirectory { tmpDir in
let packagePath = tmpDir.appending(component: "foo")
try localFileSystem.createDirectory(packagePath)
try sh(swiftPackage, "--package-path", packagePath, "init", "--type", "executable")
try sh(swiftBuild, "--package-path", packagePath, "--build-system", buildSystemProvider.rawValue)

try withKnownIssue("Error while loading shared libraries: libswiftCore.so: cannot open shared object file: No such file or directory") {
// The 'native' build system uses 'swiftc' as the linker driver, which adds an RUNPATH to the swift runtime libraries in the SDK.
// 'swiftbuild' directly calls clang, which does not add the extra RUNPATH, so runtime libraries cannot be found.
let (stdout, stderr) = try sh(
swiftRun, "--package-path", packagePath, "--build-system", buildSystemProvider.rawValue
)
#expect(!stderr.contains("error:"))
#expect(stdout.contains("Hello, world!"))
} when: {
buildSystemProvider == .swiftbuild && ProcessInfo.hostOperatingSystem == .linux
}
}
}
}

@Test(
.requireThreadSafeWorkingDirectory,
.bug(id: 0, "SWBINTTODO: Linux: /lib/x86_64-linux-gnu/Scrt1.o:function _start: error:"),
.bug("https://github.com/swiftlang/swift-package-manager/issues/8380", "lld-link: error: subsystem must be defined"),
.bug(id:0, "SWBINTTODO: MacOS: Could not find or use auto-linked library 'Testing': library 'Testing' not found"),
.bug(id: 0, "SWBINTTODO: MacOS: Could not find or use auto-linked library 'Testing': library 'Testing' not found"),
arguments: BuildSystemProvider.allCases
)
func packageInitLibrary(_ buildSystemProvider: BuildSystemProvider) throws {
do {
try withTemporaryDirectory { tmpDir in
let packagePath = tmpDir.appending(component: "foo")
try localFileSystem.createDirectory(packagePath)
try sh(swiftPackage, "--package-path", packagePath, "init", "--type", "library")
try withKnownIssue("""
Linux: /lib/x86_64-linux-gnu/Scrt1.o:function _start: error: undefined reference to 'main'
Windows: lld-link: error: subsystem must be defined
MacOS: Could not find or use auto-linked library 'Testing': library 'Testing' not found
""") {
try sh(swiftBuild, "--package-path", packagePath, "--build-system", buildSystemProvider.rawValue, "--vv")
let (stdout, stderr) = try sh(
swiftTest, "--package-path", packagePath, "--build-system", buildSystemProvider.rawValue, "--vv"
)
#expect(!stderr.contains("error:"))
#expect(stdout.contains("Test Suite 'All tests' passed"))
} when: {
buildSystemProvider == .swiftbuild
}
try withTemporaryDirectory { tmpDir in
let packagePath = tmpDir.appending(component: "foo")
try localFileSystem.createDirectory(packagePath)
try sh(swiftPackage, "--package-path", packagePath, "init", "--type", "library")
try withKnownIssue(
"""
Linux: /lib/x86_64-linux-gnu/Scrt1.o:function _start: error: undefined reference to 'main'
Windows: lld-link: error: subsystem must be defined
MacOS: Could not find or use auto-linked library 'Testing': library 'Testing' not found
""",
isIntermittent: true
) {
try sh(swiftBuild, "--package-path", packagePath, "--build-system", buildSystemProvider.rawValue, "--vv")
let (stdout, stderr) = try sh(
swiftTest, "--package-path", packagePath, "--build-system", buildSystemProvider.rawValue, "--vv"
)
#expect(!stderr.contains("error:"))
#expect(stdout.contains("Test Suite 'All tests' passed"))
} when: {
buildSystemProvider == .swiftbuild
}
}
}
Expand Down
Loading