Skip to content

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

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 26, 2022

Conversation

artemcm
Copy link
Contributor

@artemcm artemcm commented May 24, 2022

A partial solution to #58380

We cannot filter all libraries because duplicate -l flags have a semantic meaning based on their order, but filtering out just the common Swift libraries should yield a good size improvement already and is safe.

@artemcm artemcm requested a review from compnerd May 24, 2022 23:09
@artemcm
Copy link
Contributor Author

artemcm commented May 24, 2022

@swift-ci please test

// Swift libraries that ususally have autolink directives
// in most object fiels
std::unordered_map<std::string, bool> CommonAddedSwiftLibraries = {{"-lswiftSwiftOnoneSupport", false},
{"-lswiftCore", false},
Copy link
Member

Choose a reason for hiding this comment

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

Technically, -lswiftCore should be added by the driver (and this tool is only ever invoked by the swift driver) ... so we could even eliminate it entirely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like to put this change in a release asap so let's just de-duplicate it for now to be safe and then examine the duplication with the driver, too. Because it'd probably be better to remove this at the place where the directives get inserted, instead of completely removing here.

@@ -245,7 +275,7 @@ int autolink_extract_main(ArrayRef<const char *> Args, const char *Argv0,
}

if (extractLinkerFlags(BinaryOwner->getBinary(), Instance, BinaryFileName,
LinkerFlags)) {
LinkerFlags, CommonAddedSwiftLibraries)) {
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps it makes sense to sink this entirely into the 3 instances, and use a constexpr as an initializer?

@artemcm artemcm force-pushed the AutoLinkExtractFilterCommon branch from 34c1abe to 3d30527 Compare May 25, 2022 22:21
@artemcm
Copy link
Contributor Author

artemcm commented May 26, 2022

@swift-ci please test

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

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

Thanks! This looks good! We may want to extend this to cover the string processing libraries and the regex libraires subsequently.

@artemcm
Copy link
Contributor Author

artemcm commented May 26, 2022

@swift-ci Please Build Toolchain Linux Platform

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