Skip to content

[5.7][Serialization] Soft-reject swiftmodules built against a different SDK on tagged compilers #58988

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

xymus
Copy link
Contributor

@xymus xymus commented May 19, 2022

Rework how the compiler handles swiftmodules built against a different SDK. Instead of raising an error this makes the compiler soft-reject the swiftmodule and silently rebuild from the swiftinterface (as it does with outdated modules). We still get the hard errors for modules with no swiftinterfaces as we can't rebuild them.

Also limit this check to tagged compilers only. This allows dev compilers to be more versatile for testing and production compilers to be more reliable once deployed.

rdar://93257769


When restricting loading swiftmodules to the SDK used to build them, an exception should be made for modules built against an SDK that is a subset of the SDK used when loading the module. For example, a module built with the macOS11 SDK should be loadable by a client targeting the macOS11.secret SDK. In such a case, the swiftmodule file is more likely to be reliable.

Loosening this check should make it easier to land it. However, this is still not a recommended configuration so we might want to remove this accepted use case in the future and bring back the requirement for an exact SDK name match.

rdar://92827584


Note that in practice, this feature is still turned off by default on the driver side behind the ENABLE_RESTRICT_SWIFTMODULE_SDK env var.

Cherry-pick of #58935 and #58702. Includes #58987 to avoid merge-conflicts.

@xymus
Copy link
Contributor Author

xymus commented May 19, 2022

swiftlang/llvm-project#4709

@swift-ci Please test

@xymus xymus requested a review from nkcsgexi May 20, 2022 13:16
xymus added 5 commits May 20, 2022 12:32
When restricting loading swiftmodules to the SDK used to build them,
an exception should be made for modules built against an SDK that is a subset
of the SDK used when loading the module. In such a case, the swiftmodule
file is more reliable.

rdar://92827584
Change the way swiftmodules built against a different SDK than their
clients are rejected. This makes them silently ignored when the module
can be rebuilt from their swiftinterface, instead of reporting a hard
error.

rdar://93257769
…lers

Only production compilers should apply the per-SDK restriction on
loading swiftmodules. Use the "is the compiler tagged" information over
a release build to align with the other main swiftmodule loading
restriction accepting only swiftmodules built by the same tag.

Also use an env var SWIFT_DEBUG_FORCE_SWIFTMODULE_PER_SDK to enable
testing this feature in any compilers.
@xymus xymus force-pushed the swiftmodule-per-sdk-soft-reject-5.7 branch from f7ea752 to 47c3114 Compare May 20, 2022 19:33
@xymus
Copy link
Contributor Author

xymus commented May 20, 2022

swiftlang/llvm-project#4709

@swift-ci Please test

@xymus xymus merged commit e210db4 into swiftlang:release/5.7 May 23, 2022
@xymus xymus deleted the swiftmodule-per-sdk-soft-reject-5.7 branch May 23, 2022 15:09
@AnthonyLatsis AnthonyLatsis added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.7 labels Jan 9, 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 swift 5.7
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants