-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Use swift-driver triple #6627
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
Use swift-driver triple #6627
Conversation
@swift-ci please smoke test |
@swift-ci please smoke test windows |
@@ -382,11 +382,11 @@ public final class UserToolchain: Toolchain { | |||
// the merged swiftmodules. XCTest followed suit. | |||
"-I", | |||
AbsolutePath( | |||
validating: "usr/lib/swift/windows/\(triple.arch)", | |||
validating: "usr/lib/swift/windows/\(triple.arch?.rawValue ?? "unknown")", |
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.
I'm somewhat uncomfortable with this. The unknown
here is confusing. Would we be able to replace this with something like <<NULL>>
or something that is explicitly bad and obviously so?
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.
should this throw in case it is null?
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.
I think that having it throw would be a much safer option. We need to know the architecture to be able to build.
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.
Resolved this by using archName
which is non-optional
@@ -716,32 +716,32 @@ public final class UserToolchain: Toolchain { | |||
// (~5.7), we always had a singular installed SDK. Prefer the | |||
// new variant which has an architecture subdirectory in `bin` | |||
// if available. | |||
switch triple.arch { | |||
case .x86_64, .x86_64h: | |||
switch triple.archName { |
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.
Can we ensure that this is in lower case? I'm worried about the stringly matching here.
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.
switching on the string feels like a regression from a type safety pov. is it necessary?
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.
Changed this back to switch on arch, the coverage of the included cases is increased as a result though.
Is there a reason we're not using Driver's |
That's a @neonichu question |
@swift-ci please smoke test |
I've previously copied this |
We don't want to introduce a dependency on Driver in the "data model" portion of SwiftPM since that will cause issues for the Xcode integration. |
@swift-ci test windows |
@swift-ci please smoke test |
@swift-ci please smoke test windows |
$0.platform == triple.os.asXCFrameworkPlatformString && | ||
$0.architectures.contains(triple.arch.rawValue) | ||
$0.platform == triple.os?.asXCFrameworkPlatformString && | ||
$0.architectures.contains(triple.archName) |
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.
can architectures be made more type safe instead of string array?
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.
I have absolutely no idea how this XCFramework code works and I'd like to avoid touching it if possible in this PR.
struct XCFrameworkMetadata.Library {
let libraryIdentifier: String
let libraryPath: String
let headersPath: String?
let platform: String
let architectures: [String]
}
Sources/Basics/Triple.swift
Outdated
return nil | ||
} | ||
extension Triple { | ||
public static let macOS = try! Self("x86_64-apple-macosx") |
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.
does Triple need a non-throwing constructer that takes a static string / ExpressibleByStringLiteral?
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.
Probably, but I want to avoid additional changes API changes in this PR. (The existing triple uses the above API shape)
Sources/Basics/Triple.swift
Outdated
candidates.append((name: "macos", value: .macOS)) | ||
return candidates.first(where: { string.hasPrefix($0.name) })?.value | ||
extension Triple { | ||
public init(_ description: String) throws { |
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.
where/how is this used? worried about the public extension
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.
I added this to match the current Basics.Triple API
Sources/Basics/Triple.swift
Outdated
import enum TSCBasic.JSON | ||
import class TSCBasic.Process | ||
import struct SwiftDriver.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.
This file should probably be renamed to Triple+Extension to match style of repo
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.
Fixed!
Package.swift
Outdated
@@ -152,6 +152,7 @@ let package = Package( | |||
.product(name: "DequeModule", package: "swift-collections"), | |||
.product(name: "OrderedCollections", package: "swift-collections"), | |||
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"), | |||
.product(name: "SwiftDriver", package: "swift-driver"), |
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.
hmm I dont love adding this to Basics. I think we are going that only for the extension which are a bit questionable imho. Maybe we can limit the dependency to the modules that actually use it and find a better home (closer to call site) for the extensions
@swift-ci test Windows |
What if |
I think creating a new library that has some of these very basic models (eg semantic version, triple) is called for. TSC was suppose to be that but became a grab bag of "stuff" that is impossible to version properly and as such lost utility, and will be deprecated. while we are working to deprecate TSC, this specific solution seems like an okay compromise |
Yah, I would see this as a temporary compromise, but in the future we should have a library with shared types like this one between driver and SwiftPM. |
Removes and replaces the custom LLVM Triple type from the Basics module with the implementation from SwiftDrvier. This change allows spm to understand all triples that swift-driver already does and resolves some issues surrounding incorrect triple parsing. For example the Basics.Triple was not able to parse 'armv7em-apple-none-eabihf-macho' where as SwiftDriver.Triple can.
@rauhul is this ready to be merged? |
eb3a1f9
to
459d652
Compare
@tomerd I just pushed fixes to address the review feedback, do you mind taking another look? |
Likely in a follow on PR |
@swift-ci please smoke test |
@swift-ci please test windows |
@swift-ci test Windows |
@swift-ci test windows |
Cherry-pick of #6627 Removes and replaces the custom LLVM Triple type from the Basics module with the implementation from the Swift Driver. This change allows SwiftPM to understand all triples that the Swift Driver already does and resolves some issues surrounding incorrect triple parsing. For example the Basics.Triple was not able to parse 'armv7em-apple-none-eabihf-macho' where as SwiftDriver.Triple can. (cherry picked from commit 4e6501b) ``` # Conflicts: # Sources/Basics/CMakeLists.txt # Sources/Basics/Triple.swift ```
Cherry-pick of #6627 Removes and replaces the custom LLVM Triple type from the Basics module with the implementation from the Swift Driver. This change allows SwiftPM to understand all triples that the Swift Driver already does and resolves some issues surrounding incorrect triple parsing. For example the Basics.Triple was not able to parse 'armv7em-apple-none-eabihf-macho' where as SwiftDriver.Triple can. (cherry picked from commit 4e6501b) ``` # Conflicts: # Sources/Basics/CMakeLists.txt # Sources/Basics/Triple.swift ``` * Fix missing `import struct TSCBasic.AbsolutePath` --------- Co-authored-by: Rauhul Varma <[email protected]>
Removes and replaces the custom LLVM Triple type from the Basics module with the implementation from SwiftDriver. This change allows SwiftPM to understand all triples that swift-driver already does and resolves some issues surrounding incorrect triple parsing. For example the Basics.Triple was not able to parse 'armv7em-apple-none-eabihf-macho' where as SwiftDriver.Triple can.