-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix –-toolchain
value shadowed by local executables
#7483
Conversation
We should prevent possible regressions in how this argument is handled.
@swift-ci test |
Since #7483 this type is implemented in SwiftPM.
@swift-ci test |
@swift-ci test |
@swift-ci test |
…xd/test-toolchain-argument # Conflicts: # Sources/PackageModel/UserToolchain.swift
–-toolchain
argument in SwiftCommandStateTests
–-toolchain
behavior regression
–-toolchain
behavior regression–-toolchain
value shadowed by local executables
@swift-ci test |
For posterity: I changed the logic here slightly, |
@swift-ci please clean test Linux platform |
1 similar comment
@swift-ci please clean test Linux platform |
3ecfea4
to
a68d7cf
Compare
@swift-ci please clean test Linux platform |
This reverts commit 133fbee.
Drop `SWIFTPM_CUSTOM_BIN_DIR` and related files because they are not passed through to the `hostSwiftSDK` anyway and even if they were we cannot use non-existant binaries because `targetTriple` of host toolchain gets computed by invoking `swiftc -print-target-info`.
a68d7cf
to
a7f8121
Compare
@swift-ci please clean test Linux platform |
For posterity there are currently multiple issues here
|
I worked on this one specifically in ce70582, 1f2a1ca and a few other recent commits. When specifying a fake environment with in-memory FS one should provide a predetermined host triple to avoid trying to spawn that process at a fake path. |
@MaxDesiatov This cannot be done at the moment for SwiftCommandState which is under test, I should have mentioned explicitly that the only failing test on Linux is the new one in SwiftCommandStateTests. We need to figure out whether we want to mock a host toolchain there, provide a host triple somehow or do something else… |
…xd/test-toolchain-argument # Conflicts: # Tests/BuildTests/BuildPlanTests.swift
@swift-ci test |
72a9833
to
ad05fcb
Compare
@swift-ci test |
@swift-ci test linux |
@swift-ci test macos |
@swift-ci test windows |
1 similar comment
@swift-ci test windows |
environment: self.environment, | ||
observabilityScope: self.observabilityScope | ||
) | ||
hostSwiftSDK.targetTriple = self.hostTriple |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for this PR - maybe we should rename this to triple
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On SwiftSDK
or on SwiftCommandState
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SwiftSDK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SwiftSDKs have both triples specified on purpose, as one can have a Swift SDK installed supporting certain host triples that don't include the triple of a machine it's installed on. hostTriple
is optional on it for Swift SDKs that don't have such requirements. But we still need to distinguish target from host there.
Behavior of `--toolchain` regressed in #7296 by preferring the first match in toolset root paths: when `swiftc` is available in the same directory next to the SwiftPM binary being invoked, that became preferred with `--toolchain` value ignored. This is now fixed by slightly tweaking where custom toolchain gets added - it's prepended. A newly added test verifies that the behavior is fixed. For that we had to inject `FileSystem` and `EnvironmentVariables` in a lot more places, with an added benefit of making our tests more consistent and isolated from an arbitrary build environment. Resolves: rdar://126095653 --------- Co-authored-by: Pavel Yaskevich <[email protected]> (cherry picked from commit ee9d0b2) # Conflicts: # Sources/PackageModel/UserToolchain.swift
Cherry-pick of #7483. **Explanation**: Behavior of `--toolchain` regressed in https://github.com/apple/swift-package-manager/pull/7296/files by preferring the first match in toolset root paths: when `swiftc` is available in the same directory next to the SwiftPM binary being invoked, that became preferred with `--toolchain` value ignored. **Scope**: limited to cross-compilation and infrequent builds that utilize this option. **Risk**: low due to limited scope, merged to `main` for a week with no regressions discovered. **Testing**: A newly added test verifies that the behavior is fixed. For that we had to inject `FileSystem` and `EnvironmentVariables` in a lot more places, with an added benefit of making our tests more consistent and isolated from an arbitrary build environment. **Issue**: rdar://126095653 **Reviewer**: @bnbarham
Behavior of
--toolchain
regressed in https://github.com/apple/swift-package-manager/pull/7296/files by preferring the first match in toolset root paths: whenswiftc
is available in the same directory next to the SwiftPM binary being invoked, that became preferred with--toolchain
value ignored.This is now fixed by slightly tweaking where custom toolchain gets added - it's prepended.
A newly added test verifies that the behavior is fixed. For that we had to inject
FileSystem
andEnvironmentVariables
in a lot more places, with an added benefit of making our tests more consistent and isolated from an arbitrary build environment.Resolves: rdar://126095653