Skip to content

[Driver] Use library search group when linking statically #36356

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
Mar 15, 2021

Conversation

drexin
Copy link
Contributor

@drexin drexin commented Mar 8, 2021

Fixes rdar://75099393

When statically linking, we sometimes run into circular dependencies (e.g. Foundation and CoreFoundation). Using library search groups resolves linker issues in these cases.

@drexin
Copy link
Contributor Author

drexin commented Mar 8, 2021

@swift-ci smoke test

@tomerd tomerd requested a review from beccadax March 10, 2021 18:48
@tomerd
Copy link
Contributor

tomerd commented Mar 13, 2021

@drexin @beccadax once merged, we need to bring this into 5.4 branch as well

@airspeedswift airspeedswift requested a review from artemcm March 13, 2021 00:48
Copy link
Contributor

@beccadax beccadax left a comment

Choose a reason for hiding this comment

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

This looks okay from a driver implementation perspective.

I'm not very familiar with the linker feature you're using, but the man page seems to recommend against using it very aggressively:

Using this option has a significant performance cost. It is best to use it only when there are unavoidable circular references between two or more archives.

Do we definitely need to cover everything being added here in a library search group, or can we limit it somehow?

Copy link
Contributor

@beccadax beccadax left a comment

Choose a reason for hiding this comment

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

(I'll approve on the assumption that the list is indeed minimal.)

@drexin
Copy link
Contributor Author

drexin commented Mar 15, 2021

@beccadax Thanks. This will only affect static linking and the list of the dependencies will be whatever swift-autolink-extract produces. I would definitely prefer this to only be applied when necessary, but it's not really possible to figure this out automatically.

@drexin drexin merged commit 2083e1b into swiftlang:main Mar 15, 2021
@artemcm
Copy link
Contributor

artemcm commented Mar 16, 2021

@drexin,
Could you please make an analogous change in the new driver?

This should be a good starting point:
https://github.com/apple/swift-driver/blob/main/Sources/SwiftDriver/Jobs/GenericUnixToolchain%2BLinkerSupport.swift#L46

@drexin
Copy link
Contributor Author

drexin commented Mar 16, 2021

@artemcm Yes, I was planning to do that. Thanks for the ping.

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.

4 participants