Skip to content

[4.0] IRGen: Fix linkage for shared declarations #12164

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

They need external linkage not linkonce_odr which can only be used by defintions
not declarations. This got exposed by clang imported protocol witness table declarations. They get assigned shared linkage since they are potentially not unique.

  • Explanation: There are situations where we end up with a SIL declaration of a protocol witness table that has shared linkage. We will unconditionally assign llvm’s linkonce_odr linkage to shared definitions and declarations. However, only definitions are allowed with this linkage. Instead we should use external linkage for such declarations.
    This situation can arise under optimized incremental compilation when there are two files. One contains a protocol defintion that extends a clang importer synthesized protocol and another file that uses that protocol.

  • Scope of Issue: Compiler error when one uses incremental compilation with a definition of a hashable protocol conformance to a NS_OPTION type in one file and the use of the NS_OPTION type hashable conformance in another file. This is an older bug that has been around since at least last year.

  • Risk: Low. We are changing the linkage of a declaration from linkonce (which crashes) to a declaration with external linkage. What can at most happen is that we change an compiler error into a linker error (because the declaration is not satisfied by a definition somewhere else).

  • Testing: Added swift regression test

rdar://26563441

They need external linkage not linkonce_odr which can only be used by defintions
not declarations.
This got exposed by clang imported protocol witness table declarations.
They get assigned shared linkage since they are potentially not unique.

rdar://26563441
(cherry picked from commit 3d34fb3)
@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test source compatibility

@tkremenek tkremenek merged commit 58e8c21 into swiftlang:swift-4.0-branch Sep 28, 2017
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