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

Sema: Narrow down the derivation of == for RawRepresentable enums to non-resilient modules #40382

Conversation

slavapestov
Copy link
Contributor

This change was originally introduced in #36752.

The problem occurs in the following scenario:

  • New compiler with this change is used to build a dylib and swiftinterface
    file for module A, which defines a RawRepresentable enum type E.

  • Module B imports module A and references == on two E instances.

  • The module B is run against a dylib of module A built with the old compiler.

At this point, module B will not link (or run) because the symbol for E.==
is not present in the old dylib for A.

The only real solution here is to disable this new optimization when
building a module for -enable-library-evolution, unfortunately.

In the future, we could make the derived E.== symbol @_alwaysEmitIntoClient.
However today, synthesized declarations cannot be @_alwaysEmitIntoClient
because they do not have source text that can be emitted into the
swiftinterface file. One day, we might gain the ability to print Exprs as
source text that parses back in, at which point we could allow synthesized
declarations to be @_alwaysEmitIntoClient.

Fixes rdar://problem/84912735 and rdar://problem/82919247.

…non-resilient modules

This change was originally introduced in swiftlang#36752.

The problem occurs in the following scenario:

- New compiler with this change is used to build a dylib and swiftinterface
  file for module A, which defines a RawRepresentable enum type E.

- Module B imports module A and references == on two E instances.

- The module B is run against a dylib of module A built with the old compiler.

At this point, module B will not link (or run) because the symbol for E.==
is not present in the old dylib for A.

The only real solution here is to disable this new optimization when
building a module for -enable-library-evolution, unfortunately.

In the future, we could make the derived E.== symbol @_alwaysEmitIntoClient.
However today, synthesized declarations cannot be @_alwaysEmitIntoClient
because they do not have source text that can be emitted into the
swiftinterface file. One day, we might gain the ability to print Exprs as
source text that parses back in, at which point we could allow synthesized
declarations to be @_alwaysEmitIntoClient.

Fixes rdar://problem/84912735 and rdar://problem/82919247.
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

Copy link
Contributor

@LucianoPAlmeida LucianoPAlmeida left a comment

Choose a reason for hiding this comment

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

Thank you for fixing this and for the detailed explanation @slavapestov!

@LucianoPAlmeida
Copy link
Contributor

@swift-ci Please smoke test Linux Platform

@slavapestov slavapestov merged commit e087704 into swiftlang:main Dec 3, 2021
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