-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Set default linker to lld for Amazon Linux 2023 #72049
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
Set default linker to lld for Amazon Linux 2023 #72049
Conversation
@sebsto, can you look at this and give some feedback please. |
CMake approach seems fine if it works, but note that you will need a |
@finagolfin The |
Thank you for working on this ! The maintainers of this project will be more qualified than me to suggest the correct approach :-) |
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.
Don't love it, but we're expecting to delete it so I'll be less picky. I would still get @artemcm's approval though. I'll land swiftlang/swift-driver#1545 once we know what our story is with lld
and the removal of the start/stop symbols. I definitely prefer one of @al45tair (#71373 (comment)), @keith (#67476), or @kateinoigakukun's (#71373) approach over mine in swiftlang/llvm-project#8214.
lib/Driver/UnixToolChains.cpp
Outdated
@@ -9,6 +9,8 @@ | |||
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | |||
// | |||
//===----------------------------------------------------------------------===// | |||
#include <iostream> |
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.
If possible, please use the LLVM APIs available. We're already including them.
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.
@etcwilde, I have removed #include <iostream>
as it was only being used for print some log messages while I was debugging.
FWIW, I'm working on a more complete fix for that at the moment. // @etcwilde |
614ba0a
to
03a364e
Compare
@al45tair @artemcm @sebsto @etcwilde @tkremenek |
Sorry, I was thinking of the other PR for changing how the driver selects the linker. I'm definitely not a huge fan of checking the distro names, that doesn't scale and seems brittle. It's for the old driver and I don't have a better idea though. Given that this is @artemcm's world, I defer final vote to him. Alternatively, @al45tair might have an idea for checking distribution info that doesn't involve hardcoding names into the driver. |
A possible alternative might be to actually check for the existence of |
@swift-ci Please smoke test |
@swift-ci Please smoke test Windows platform |
@@ -948,6 +948,10 @@ if(XCODE) | |||
swift_common_xcode_cxx_config() | |||
endif() | |||
|
|||
# Check what linux distribution is being used. | |||
# This can be used to determine the default linker to use. | |||
cmake_host_system_information(RESULT DISTRO_NAME QUERY DISTRIB_PRETTY_NAME) |
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 should be reverted.
The minimum CMake version is 3.19.6 (says so at the top of the file).
This key only appeared on CMake 3.22.
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.
@drodriguez @finagolfin @etcwilde
The minimum cmake version required for the swift toolchain build has been "cmake": "v3.24.2"
since version 5.10
https://github.com/apple/swift/blob/main/utils/update_checkout/update-checkout-config.json#L232
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.
That's the version used by the build-script
for CI, and only on Linux and BSD. The CMake files should be compatible with the version required by the cmake_minimum_required
instruction. This is failing for a macOS which a 3.20 version of CMake (enough to build LLVM and Swift using only CMake).
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 the best option here is to update the minimum cmake version to match the version used in the CI.
This was supposed to have been done already and it makes no sense to be using a cmake version as old as v3.19.6
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 @etcwilde plans to significantly increase the minimum CMake version this year anyway, so it would make sense to increase it to 3.22 now itself.
Evan, wdyt?
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.
But things need to be done in certain order, and not as a reaction to introducing a dependency to check for a specific Linux distribution, and have a broken CMakeLists.txt
at the root of the project.
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.
Assuming #73001 fixes the problem for now, we can discuss the CMake version separately.
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.
One CMake version bump that should be very easy to justify is to 3.20.0, since that's what LLVM needs, and anybody trying to build would need at least that.
Going beyond that is probably a question of distribution support. macOS is an outlier: if one uses Homebrew you are fine, but if some other packing system is used, people will need to upgrade. I think the problem in Linux and BSD distros is worked around with the compiled CMake version (at least when using build-script
).
IMO, for any platform, in any case, it would be good if the actual needed CMake version was detailed in the main CMakeLists.txt
file.
I think the feelings above about hardcoding distribution names were correct. This could have been a configuration in a cache file used to build for that particular distribution. If some particular distribution needs an override for the default linker chosen by the toolchain, that can also be injected during the configuration. It does not need to be hardcoded into the build system (or the compiler). |
I think we lowered our standards, as stated above, because the real fix is in swiftlang/swift-driver#1545 and this legacy Driver is slated to be deleted soon. |
We still need something that is valid for the stated version of CMake. I'm not personally opposed to updating the CMake requirements, but that should come from an explicit decision to do so. |
@futurejones, would you submit a revision to the CMake change that will work with older CMake also? |
Exactly this. Hardcoding distribution names isn't great, but it lets us make forward progress and we have a better fix in the works already. The CMake version problem is a bigger issue, mind. That said, I think we could just do if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.22")
cmake_host_system_information(RESULT DISTRO_NAME QUERY DISTRIB_PRETTY_NAME)
endif() and tell people using Amazon Linux 2023 that they need at least CMake 3.22 for things to work. @drodriguez since you have an old CMake installed, could you confirm that that change fixes things for you? I've raised a PR for the change as #73001 and added you as a reviewer.
If we're talking about official distributions of Swift, either provided by swift.org or by the Amazon Linux folks, sure. I'm not sure that's such a great solution in general though — it'd mean having to have special instructions for building on Amazon Linux 2023 and above. And we already have a better solution in swiftlang/swift-driver#1545. |
There should be no need for any special instructions for Amazon Linux 2023 as the default install version of CMake is already |
@futurejones @al45tair I managed to build Swift 6 on ALI2023 thanks to your PRs. The trick is to install However, when I try to use the tarball I created on a new ALI2023 machine, the swift driver (or compiler) still expects to find
What did I do wrong ? Is the change not merged yet on the 6.x branches ? (Just found out swiftlang/swift-driver#1595) |
As I noted six months ago, |
@finagolfin is this the one you refer too ? This has been merged into main but is not in 6.0.1 nor 6.0.2 :-( |
Yes, it was submitted to 6.0 a while back in swiftlang/swift-driver#1595, which you originally linked. Evan says there that that pull also needs another one from |
The
gold
linker is no longer available in Amazon Linux 2023 and requireslld
to be set as the default linker.This removes the need to build the gold linker from source as proposed here - swiftlang/swift-installer-scripts#278
These changes only effect
amazonlinux 2023
and should not impact on the current builds ofamazonlinux 2
.