Skip to content
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

[5.7][Autolink Extract] Filter out common Swift libraries from being linked more than once #59115

Merged

Conversation

artemcm
Copy link
Contributor

@artemcm artemcm commented May 26, 2022

Cherry-pick of #59063

• Explanation: #58380 brought up an issue of excessive memory consumption at link-time on Linux. The cause of memory-consumption explosion appears to be due to the linker invocation command having duplicated -lxxx flags which come from the swift-autolink-extract tool which aggregates auto-linking directives across all input object files. For common Swift libraries that every Swift object file links (e.g. swiftCore) this means that they appear on the linker invocation as many times as the number of object files in the project. Which for large projects means possibly thousands of times. The linker is not able to de-duplicate these flags because duplicate linked libraries in a certain order has a semantic meaning, and apparently it loads them into memory as many times as they appear on the linker command-line. This change addresses this issue at least partially by making sure that the common Swift libraries, at least, are de-duplicated across all object files and are only linked once: SwiftCore, SwiftOnoneSupport, and SwiftConcurrency.
• Scope of Issue: High memory consumption when building modules with many object files on Linux.
• Risk: Low, this change only filters common Swift libraries and should leave behavior of other linked libraries largely unchanged.
• Automated Testing: Automated test added to the compiler test suite

@artemcm artemcm requested a review from a team as a code owner May 26, 2022 21:11
@artemcm
Copy link
Contributor Author

artemcm commented May 26, 2022

@swift-ci please test

2 similar comments
@artemcm
Copy link
Contributor Author

artemcm commented May 26, 2022

@swift-ci please test

@artemcm
Copy link
Contributor Author

artemcm commented May 31, 2022

@swift-ci please test

Copy link
Contributor

@nkcsgexi nkcsgexi left a comment

Choose a reason for hiding this comment

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

This should only affect Swift on non-Darwin platforms.

@artemcm
Copy link
Contributor Author

artemcm commented May 31, 2022

@swift-ci please test

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.

2 participants