Skip to content

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

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
merged 4 commits into from
May 18, 2022

Conversation

xymus
Copy link
Contributor

@xymus xymus commented May 16, 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


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

xymus added 3 commits May 16, 2022 11:22
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 branch from 6059538 to 3523adb Compare May 16, 2022 20:24
@xymus
Copy link
Contributor Author

xymus commented May 16, 2022

@swift-ci Please smoke test

@xymus xymus requested review from bnbarham and tshortli May 16, 2022 20:24
@xymus
Copy link
Contributor Author

xymus commented May 17, 2022

@swift-ci Please smoke test

swiftlang/llvm-project#4692

1 similar comment
@xymus
Copy link
Contributor Author

xymus commented May 18, 2022

@swift-ci Please smoke test

swiftlang/llvm-project#4692

@xymus
Copy link
Contributor Author

xymus commented May 18, 2022

swiftlang/llvm-project#4692

@swift-ci Please smoke test

@xymus xymus merged commit 6c287b2 into swiftlang:main May 18, 2022
xymus added a commit to swiftlang/llvm-project that referenced this pull request May 18, 2022
The Swift service validateSerializedAST now accepts the name of the
client SDK to limit loading only swiftmodules built with the same SDK.
This prevents loading swiftmodules built with an incompatible SDK where
the context is different enough that it can lead to hard compiler
crashes.

In this use site, loading the swiftmodule from a binary should be safe
as the SDK context will be extracted from that swiftmodule. Other
imports will use regular loading path and apply the expected
restriction.

Swift API change: swiftlang/swift#58935
xymus added a commit to swiftlang/llvm-project that referenced this pull request May 18, 2022
The Swift service validateSerializedAST now accepts the name of the
client SDK to limit loading only swiftmodules built with the same SDK.
This prevents loading swiftmodules built with an incompatible SDK where
the context is different enough that it can lead to hard compiler
crashes.

In this use site, loading the swiftmodule from a binary should be safe
as the SDK context will be extracted from that swiftmodule. Other
imports will use regular loading path and apply the expected
restriction.

Swift API change: swiftlang/swift#58935
@xymus xymus deleted the swiftmodule-per-sdk-soft-reject branch May 18, 2022 22:10
bnbarham pushed a commit to swiftlang/llvm-project that referenced this pull request May 19, 2022
The Swift service validateSerializedAST now accepts the name of the
client SDK to limit loading only swiftmodules built with the same SDK.
This prevents loading swiftmodules built with an incompatible SDK where
the context is different enough that it can lead to hard compiler
crashes.

In this use site, loading the swiftmodule from a binary should be safe
as the SDK context will be extracted from that swiftmodule. Other
imports will use regular loading path and apply the expected
restriction.

Swift API change: swiftlang/swift#58935
xymus added a commit to swiftlang/llvm-project that referenced this pull request May 23, 2022
The Swift service validateSerializedAST now accepts the name of the
client SDK to limit loading only swiftmodules built with the same SDK.
This prevents loading swiftmodules built with an incompatible SDK where
the context is different enough that it can lead to hard compiler
crashes.

In this use site, loading the swiftmodule from a binary should be safe
as the SDK context will be extracted from that swiftmodule. Other
imports will use regular loading path and apply the expected
restriction.

Swift API change: swiftlang/swift#58935
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