Skip to content

Fix the legacy driver path construction on non-Windows platforms #1756

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

Conversation

kateinoigakukun
Copy link
Member

swift-driver tries to invoke swiftc-legacy-driver. (trailing dot) on non-Windows platforms when legacy driver is requested since #1746

This is because URL.pathExtension returns an empty string if the URL does not have an extension but URL.appendPathExtension appends a period before the extension even if given an empty string. Thus url.deletingPathExtension().appendingPathExtension(url.pathExtension) will not be equal to url if url does not have an extension.

@kateinoigakukun
Copy link
Member Author

@swift-ci test

@kateinoigakukun
Copy link
Member Author

Wait, it seems like a swift-foundation side issue:

import Foundation
let url = URL(fileURLWithPath: "/tmp/x")
print(url.deletingPathExtension().appendingPathExtension(url.pathExtension))
// Swift 5.10: file:///tmp/x
// Swift 6.0: file:///tmp/x.

@kateinoigakukun
Copy link
Member Author

@swift-ci test macOS

kateinoigakukun added a commit to swiftwasm/swiftwasm-build that referenced this pull request Dec 11, 2024
@compnerd
Copy link
Member

Can you check with swift-foundation if the behaviour change is intentional? If not, we should mark this as a workaround and then revert it once we have a newer Foundation.

@kateinoigakukun kateinoigakukun force-pushed the yt/fix-non-windows-legacy-driver branch from 17873dc to 107b39b Compare December 12, 2024 04:44
@kateinoigakukun
Copy link
Member Author

@compnerd The team said it was an unintentional change and fixed in the main branch. swiftlang/swift-foundation#1080

@kateinoigakukun
Copy link
Member Author

@swift-ci smoke test

@@ -83,10 +83,18 @@ do {
// invocation for a multi-call binary.
let executable: URL = URL(fileURLWithPath: ProcessInfo.processInfo.arguments[0])
let invocation: URL = URL(fileURLWithPath: CommandLine.arguments[0])
let legacyExecutablePath: URL =
var legacyExecutablePath: URL =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you duplicate this code instead and guard it with a compiler version check please?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, gated behind 6.2 until we cherry-pick the fix to 6.1 branch.

`swift-driver` tries to invoke `swiftc-legacy-driver.` (trailing dot)
on non-Windows platforms when legacy driver is requested since
swiftlang#1746

This is because `URL.pathExtension` returns an empty string if the
URL does not have an extension but `URL.appendPathExtension` appends
a period before the extension even if given an empty string.
Thus `url.deletingPathExtension().appendingPathExtension(url.pathExtension)`
will not be equal to `url` if `url` does not have an extension.
@kateinoigakukun kateinoigakukun force-pushed the yt/fix-non-windows-legacy-driver branch from 107b39b to 46cc429 Compare December 12, 2024 16:44
@compnerd
Copy link
Member

@swift-ci please test

@compnerd
Copy link
Member

@swift-ci please test macOS platform

@compnerd
Copy link
Member

@swift-ci please test Windows platform

@kateinoigakukun kateinoigakukun merged commit 1bebc64 into swiftlang:main Dec 14, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants