Skip to content

AST/SILGen: Use @_alwaysEmitIntoClient diagnostic helper in unavailable code #70547

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

Conversation

tshortli
Copy link
Contributor

The _diagnoseUnavailableCodeReached() function was introduced in the Swift 5.9 standard library and employs @backDeployed to support compilation of binaries that target OS releases aligned with earlier Swift releases. Unfortunately, though, this back-deployment strategy doesn't work well for some unusual build environments. Specifically, in some configurations code may be built with a compiler from a recent Swift toolchain and then linked against the dylibs in an older toolchain. When linking against the older dylibs, the _diagnoseUnavailableCodeReached() function does not exist but the @backDeployed thunks emitted into the binary reference that function and therefore linking fails.

The idea of building with one toolchain and then linking to the dylibs in a different, older toolchain is extremely dubious. However, it exists and for now we need to support it. This PR introduces an alternative _diagnoseUnavailableCodeReached() function that is annotated with @_alwaysEmitIntoClient. Calls to the AEIC variant are now emitted by the compiler when the deployment target is before Swift 5.9.

Once these unusual build environments upgrade and start linking against a Swift 5.9 toolchain or later we can revert all of this.

Resolves rdar://119046537

@tshortli tshortli requested review from hborla, slavapestov, a team and xedin as code owners December 19, 2023 22:17
…le code.

The `_diagnoseUnavailableCodeReached()` function was introduced in the Swift
5.9 standard library and employs `@backDeployed` to support compilation of
binaries that target OS releases aligned with earlier Swift releases.
Unfortunately, though, this backdeployment strategy doesn't work well for some
unusual build environments. Specifically, in some configurations code may be
built with a compiler from a recent Swift toolchain and then linked against the
dylibs in an older toolchain. When linking against the older dylibs, the
`_diagnoseUnavailableCodeReached()` function does not exist but the
`@backDeployed` thunks emitted into the binary reference that function and
therefore linking fails.

The idea of building with one toolchain and then linking to the dylibs in a
different, older toolchain is extremely dubious. However, it exists and for now
we need to support it. This PR introduces an alternative
`_diagnoseUnavailableCodeReached()` function that is annotated with
`@_alwaysEmitIntoClient`. Calls to the AEIC variant are now emitted by the
compiler when the deployment target is before Swift 5.9.

Once these unusual build environments upgrade and start linking against a Swift
5.9 toolchain or later we can revert all of this.

Resolves rdar://119046537
@tshortli tshortli force-pushed the diagnose-unreachable-cant-back-deploy branch from 77aaa35 to 6d22433 Compare December 20, 2023 02:19
@tshortli
Copy link
Contributor Author

@swift-ci please test

@tshortli tshortli enabled auto-merge December 20, 2023 06:33
@tshortli tshortli merged commit 9a0eb73 into swiftlang:main Dec 20, 2023
@tshortli tshortli deleted the diagnose-unreachable-cant-back-deploy branch December 20, 2023 19:25
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