Skip to content

[5.6] IRGen: Fix using weak linkage to avoid duplicate metadata by only applying this to PROTOCOL related data #40546

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

Conversation

aschwaighofer
Copy link
Contributor

rdar://86256970

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@compnerd
Copy link
Member

@aschwaighofer would you mind adding a bit more detail to the commit message? What is "this"?

@aschwaighofer
Copy link
Contributor Author

@compnerd "this" is using weak hidden linkage for objective-c metadata.

This PR is a cherry-pick of #40486.

@compnerd
Copy link
Member

Ah! Thanks; that would be great to have in the commit message. BTW, for cherry-picks, the -x option is very helpful for tracking the original commit.

@aschwaighofer
Copy link
Contributor Author

We originally used internal linkage which causes duplicate metadata entries.

I then applied weak hidden linkage generally to all objective-c metadata (in #40342). This causes linkage issues with CATEGORY objective-c metadata. The linker applies some optimization to category metadata that does not expect to see weak symbols. So, this PR selectively applies weak hidden linkage only to PROTOCOL objective c metadata.

@compnerd
Copy link
Member

Hmm, I assume that weak hidden translates to internal ODR? The category metadata needs to be visible across module boundaries, and the category DCE that ld64 does as an optimization over ObjC metadata will require it to be weak ODR so that it can iterate and drop the category. The change itself seems reasonable, its purely the commit message which I was hoping could be improved so that future readers can follow the change. The reference to the cherry-picked commit would also work - as I believe that the original commit had a bit more context in the commit message.

…ly applying weak linkage to PROTOCOL related data

This adjusts PR#40342 with a fix for category linker errors. We will now only apply weak linkage to PROTOCOL metadata.

Cherry-pick of commits from swiftlang#40486.

rdar://86256970
@aschwaighofer aschwaighofer force-pushed the fix_weak_linking_objc_metadata_5.6 branch from 6db60ad to 7277d86 Compare December 14, 2021 17:27
@aschwaighofer
Copy link
Contributor Author

I have updated the commit message.

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@aschwaighofer aschwaighofer merged commit e13580f into swiftlang:release/5.6 Dec 15, 2021
@AnthonyLatsis AnthonyLatsis added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.6 labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants