Skip to content

[6.0] Various low-risk cherry-picks #7578

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

Merged
merged 13 commits into from
May 18, 2024

Conversation

bnbarham
Copy link
Contributor

@bnbarham bnbarham commented May 18, 2024

Explanation: I went through the last few months of PRs to make sure anything relevant is cherry-picked. Most of these are NFC but cherry-picking will help with conflicts. The main are:

Scope: Package manifests/graphs with duplicate product/target names.
Risk: Very low
Reviewed By: Various, mostly @MaxDesiatov

MaxDesiatov and others added 13 commits May 17, 2024 17:25
`standbox` -> `sandbox`

(cherry picked from commit 9d48dc7)
…tFound (swiftlang#7419)

Fixed a bug in the productDependencyNotFound error message

### Motivation:

fix swiftlang#7398

The above issue suggests the following two defects.

1. package dependency resolution changes depending on the order of
packages (alphabetical order)
2. the phrase "Did you meen..." in the error message in the error
message is not on target.

### Modifications:

The first problem is as described in the issue, if users rename the
directory containing Package.swift from repro to zzz, the "Did you
meen..." will appear. will appear. Essentially, the error minutes should
be displayed in full, regardless of the name of the directory. This is
due to the fact that the loop used to resolve dependencies depends on
the alphabetical order of the directories and the side effect on
allTargetName inside the loop. Therefore, the side effect for
allTargetName inside the loop has been moved to the outside of the loop.

The second problem is that when dependency A of a package is not found,
a strange suggestion "Did you meen `A`? ", which is a strange
suggestion. This is because when a dependency is not found, the message
"Did you meen `<target name>`" is printed if there is a dependency with
a similar name (even the exact same name). Thus, if the names are the
same, "Did you meen `.product(name: ... , package:
"swift-argugument")"`" instead of the found target name.

### Result:

Command to execute:
`swift build`

Result of command:.
`error: 'repro': product 'ArgumentParser' required by package 'repro'
target 'repro' not found. Did you mean '.product(name: "ArgumentParser",
package: "swift-argument-parser")'?`

Condition:
The following steps were taken to create the environment.

1. mkdir repro
1. cd repro
1. swift package init --type executable
1. Open Package.swift and make sure it has this content:

```swift
// swift-tools-version: 5.10

import PackageDescription

let package = Package(
    name: "repro",
    dependencies: [
        .package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.3.0")
    ],
    targets: [
        .executableTarget(
            name: "repro",
            dependencies: ["ArgumentParser"]
        )
    ]
)
```

---------

Co-authored-by: Yuta Saito <kateinoigakukun@gmail.com>
(cherry picked from commit ea1730b)
Resolve warnings in `Tests/PackageModelTests/MinimumDeploymentTargetTests.swift` .

### Motivation:

3 warnings were displayed indicating that a deprecated function is being
used and suggesting the use of an alternative function.

### Modifications:

Following the suggestion, the warning was resolved.

### Result:

The following warnings have been resolved:

> `init(arguments:environment:exitStatus:output:stderrOutput:)` is
deprecated: use
`init(arguments:environmentBlock:exitStatus:output:stderrOutput:)`

(cherry picked from commit a809fb5)
We require Swift 5.9 to build the package, so we can adopt 5.9-specific formatting tweak as well.

(cherry picked from commit 8193ed6)
Achieved by converting `DownloadTask` and `DataTask` to value types and adding more `Sendable` annotations where needed.

(cherry picked from commit 549d781)
Sticking to `@escaping @Sendable` as a preferred order of attributes.

Also fixed `dependecies` -> `dependencies` typo.

(cherry picked from commit 72b8498)
#### Motivation:
In the process of generating PIF, I identified a missing case for
VisionOS in the implementation of the
`[PackageConditionProtocol].toPlatformFilters()`, which led to
assertionFailure when Package's platforms included VisionOS.

#### Modifications:
- Added a new case `.visionOS` in the switch statement within the
`toPlatformFilters()` extension for `[PackageCondition]`.
- Added a new static property `visionOSFilters` within
`PIF.PlatformFilter` to define filters specific to VisionOS.

#### Result:
With these changes, PIFBuilder can now generate PIF without errors for
packages that include VisionOS as a target

(cherry picked from commit 1c68e6c)
Also refactored `URLSessionHTTPClient` to remove `weak` references,
which were incompatible with strict concurrency checks.

(cherry picked from commit f249153)
swiftlang#7454)

Fix empty token when adding a new package-registry and adding token
interactively on release builds

### Motivation:

When executing swift package-registry login it asks for a token but
fails to retrieve it properly. It sends an empty string to the registry
server and login therefore fails. (see
swiftlang#7453)

### Modifications:

I've debugged the code a bit and found out, that somehow `buffer` and
`passwordPtr` don't seem to be holding correct values after the
`readpassphrase` call.

- An easy quick fix is to make sure that `buffer` doesn't get
deallocated by adding smth like `_ = buffer` after the String init. This
works but is not nice.
- My first try was to use `buffer` instead of `passwordPtr` to create
the string. These works, but I remember reading somewhere that `&` can
be quite nasty sometimes.
- I also tried `buffer.withUnsafeMutablePointer`. However
`readpassphrase` seems to not only change the content of `buffer` but
move it. This leads to a runtime failure `Fatal error: Array
withUnsafeMutableBufferPointer: replacing the buffer is not allowed`

### Result:
The buffer is retained, the token is properly parsed and sent to the
server.

(cherry picked from commit d8c8d0f)
This "Returns true if the state file exists on the filesystem" doc comment was copy-pasted from a function above and is clearly wrong: `reload()` function doesn't return any values.

(cherry picked from commit 2093d2c)
These haven't been relevant for a while.

(cherry picked from commit ec1bfe8)
I fixed warning appears when building with Swift 6.

(cherry picked from commit 32442c6)
…#7552)

As a convenience for when we want to be able to add new target
dependencies, introduce a manifest editing API that adds a new target
dependency to an existing target in the manifest.

(cherry picked from commit ecf3e8c)
@bnbarham bnbarham requested review from xedin and DougGregor May 18, 2024 00:43
@bnbarham
Copy link
Contributor Author

@swift-ci please test

@bnbarham bnbarham added the swift 6.0 Related to Swift 6.0 release branch label May 18, 2024
@shahmishal shahmishal enabled auto-merge (squash) May 18, 2024 06:23
@shahmishal shahmishal disabled auto-merge May 18, 2024 06:23
@shahmishal shahmishal merged commit 915fa72 into swiftlang:release/6.0 May 18, 2024
5 checks passed
@bnbarham bnbarham deleted the missing-cherry-picks branch May 20, 2024 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
swift 6.0 Related to Swift 6.0 release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.