Skip to content

[Explicit Module Builds] Move generation of explicit auto-link flags to a toolchain-specific method #1874

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

Merged
merged 1 commit into from
May 6, 2025

Conversation

artemcm
Copy link
Contributor

@artemcm artemcm commented Apr 14, 2025

  • This way we can adopt a feature of a specific platform's linker separately from the others.
  • Adopt -possible_l* and -possible_framework * flags on Darwin platforms.

@artemcm
Copy link
Contributor Author

artemcm commented Apr 14, 2025

@swift-ci test

@artemcm
Copy link
Contributor Author

artemcm commented Apr 24, 2025

@swift-ci test Linux platform

@artemcm artemcm force-pushed the PerPlatformExplicitAutoLinkFlags branch from 2d6d7a9 to 85c26cb Compare April 24, 2025 22:03
@artemcm
Copy link
Contributor Author

artemcm commented Apr 24, 2025

@swift-ci test

@artemcm
Copy link
Contributor Author

artemcm commented Apr 24, 2025

@swift-ci test Windows platform

1 similar comment
@artemcm
Copy link
Contributor Author

artemcm commented Apr 24, 2025

@swift-ci test Windows platform

…to a toolchain-specific method

This way we can adopt a feature of a specific platform's linker separately from the others
@artemcm artemcm force-pushed the PerPlatformExplicitAutoLinkFlags branch from 85c26cb to 20a42b6 Compare April 29, 2025 22:44
@artemcm
Copy link
Contributor Author

artemcm commented Apr 29, 2025

@swift-ci test

@artemcm
Copy link
Contributor Author

artemcm commented Apr 29, 2025

@swift-ci test Windows platform

@artemcm artemcm marked this pull request as ready for review May 6, 2025 15:59
@artemcm artemcm requested review from cachemeifyoucan and owenv May 6, 2025 15:59
for linkLibrary in linkLibraries {
if !linkLibrary.isFramework {
commandLine.appendFlag(.Xlinker)
commandLine.appendFlag("-possible-l\(linkLibrary.linkName)")
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have a rule for what is the linker compatibility from swift-driver? This is quite a new option that doesn't work with older linker and doesn't work with ld-classic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do not, but since this entire code-path is currently behind an opt-in flag (-explicit-auto-linking), my thinking is to defer to the client to figure that out, at the moment. We have some precedent in swift-build of enabling compiler features based on the current system linker version.

On Darwin, with older linkers which do not support this option, this feature does not really make much sense anyway since using the non--possible flags changes the semantics too much compared to the current auto-linking mechanism (load directives in object files).

Copy link
Contributor

Choose a reason for hiding this comment

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

I am fine with defer to swift-build to figure out but if you use the option from command-line, there is no link that the error message of unknown linker flag has anything to do with -explicit-auto-linking?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, there's not really a link there. I'm not sure I see an obvious way to establish such a link, especially given that we use clang as the linker driver. Maybe we could emit a warning when the user enables this feature, but that's got its own obvious downsides. And I'm not sure it's worth it, given that this is a fully opt-in behavior.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have better idea either.

@artemcm artemcm merged commit f7b8007 into swiftlang:main May 6, 2025
3 checks passed
@artemcm artemcm deleted the PerPlatformExplicitAutoLinkFlags branch May 6, 2025 19:47
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