Serialization: reword diagnostic about serialization channel mismatch

This diagnostic reports when two compilers that are marked as targetting
different distribution channels try to read swiftmodules produced by the
other one. For a resilient module, this error is usually silently ignored
as the reader compiler picks the swiftinterface over the swiftmodule.
It is visibile to the end user when the module is non-resilient.
For such a case, we here try to improve the diagnostic to be more
meaningful.

The new diagnostics looks like so:
```
import ChannelLib // error: the binary module for 'ChannelLib' was compiled
                  // for 'restricted-channel', it cannot be imported by the
                  // current compiler which is aligned with 'other-channel'.
                  // Binary module loaded from path: .../ChannelLib.swiftmodule
```

Vendors should be mindful to pick meaningful channel names
to guide users in the direction of the actual solution.
This commit is contained in:
Alexis Laferrière
2024-08-15 12:53:29 -07:00
parent 1f93fb3fbc
commit 020d5784df
2 changed files with 7 additions and 6 deletions

View File

@@ -864,9 +864,10 @@ ERROR(serialization_module_incompatible_revision,Fatal,
"rebuild %1 and try again: %2",
(StringRef, Identifier, StringRef))
ERROR(serialization_module_incompatible_channel,Fatal,
"compiled module was created for a different distribution channel '%0' "
"than the local compiler '%1', "
"please ensure %2 is found from the expected path: %3",
"the binary module for %2 was compiled for '%0', "
"it cannot be imported by the current compiler "
"which is aligned with '%1'. "
"Binary module loaded from path: %3",
(StringRef, StringRef, Identifier, StringRef))
ERROR(serialization_missing_single_dependency,Fatal,
"missing required module '%0'", (StringRef))

View File

@@ -25,7 +25,7 @@ public func foo() {}
/// 2. Test importing the non-resilient no-channel library from a channel compiler.
//--- NonResilientClient.swift
import NonResilientLib // expected-error {{compiled module was created for a different distribution channel '' than the local compiler 'restricted-channel', please ensure 'NonResilientLib' is found from the expected path:}}
import NonResilientLib // expected-error {{the binary module for 'NonResilientLib' was compiled for '', it cannot be imported by the current compiler which is aligned with 'restricted-channel'. Binary module loaded from path:}}
foo()
/// Building a NonResilientLib client should reject the import for a tagged compiler
@@ -37,7 +37,7 @@ foo()
/// 3. Test importing the resilient no-channel library.
//--- ResilientClient.swift
import ResilientLib // expected-reject-error {{compiled module was created for a different distribution channel '' than the local compiler 'restricted-channel', please ensure 'ResilientLib' is found from the expected path:}}
import ResilientLib // expected-reject-error {{the binary module for 'ResilientLib' was compiled for '', it cannot be imported by the current compiler which is aligned with 'restricted-channel'. Binary module loaded from path:}}
// expected-rebuild-remark @-1 {{rebuilding module 'ResilientLib' from interface}}
// expected-rebuild-note @-2 {{compiled module is out of date}}
// expected-rebuild-note @-3 {{compiled for a different distribution channel}}
@@ -80,7 +80,7 @@ foo()
/// 4. Test importing the channel restricted library
//--- ChannelClient.swift
import ChannelLib // expected-reject-error {{compiled module was created for a different distribution channel 'restricted-channel' than the local compiler 'other-channel', please ensure 'ChannelLib' is found from the expected path}}
import ChannelLib // expected-reject-error {{the binary module for 'ChannelLib' was compiled for 'restricted-channel', it cannot be imported by the current compiler which is aligned with 'other-channel'. Binary module loaded from path:}}
foo()
/// Importing ChannelLib should succeed with the same channel.