-
Notifications
You must be signed in to change notification settings - Fork 199
🍒[Swift 6.0]: Update Generic Unix linker selection #1595
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
🍒[Swift 6.0]: Update Generic Unix linker selection #1595
Conversation
Explanation: This patch has the Swift driver fallback on the clang-linker for default linker selection instead of hard-coding |
@swift-ci please test |
We'll also need to back-port the corresponding change to the default linker in the clang-linker or the Linux builds will fail: swiftlang/swift#73463 |
Not all generic-"unix" environments have the Gold linker available to them, and in some cases, the vendor of the toolchain may provide their own linker. In these cases, the driver should be internally consistent with the toolchain that it is shipped with. Now that we have the clang-linker, we can lean on the linker selection in the clang-linker to determine a default linker. If the clang-linker, and thus, the swift compiler driver, are part of a specific toolchain, that clang-linker should be built for that platform with the appropriate linker defaults set. If someone overrides the linker with `-use-ld`, we should still honour that, but should otherwise be consistent with the appropriate toolchain linker. Fixes: rdar://123061492
2bf9cdb
to
07a5afc
Compare
@swift-ci please test |
linker = arg.asSingle | ||
// Select the linker to use. | ||
if let arg = parsedOptions.getLastArgument(.useLd)?.asSingle { | ||
commandLine.appendFlag("--fuse-ld=\(arg)") |
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.
It should be -fuse-ld=\(arg)
. Only one dash.
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.
Maybe cherry-pick #1624 as well?
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.
Already posted: #1725
Cherry-Picking #1545 back to Swift 6.0
Not all generic-"unix" environments have the Gold linker available to them, and in some cases, the vendor of the toolchain may provide their own linker. In these cases, the driver should be internally consistent with the toolchain that it is shipped with.
Now that we have the clang-linker, we can lean on the linker selection in the clang-linker to determine a default linker. If the clang-linker, and thus, the swift compiler driver, are part of a specific toolchain, that clang-linker should be built for that platform with the appropriate linker defaults set. If someone overrides the linker with -use-ld, we should still honour that, but should otherwise be consistent with the appropriate toolchain linker.
This will enable building and linking on AmazonLinux 2023 without requiring folks to always pass additional flags. It also means we can produce a self-contained toolchain that is internally consistent using lld as the linker.
Fixes: rdar://123061492