mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Serialize the canonical name of the SDK used when building a swiftmodule file and use it to ensure that the swiftmodule file is loaded only with the same SDK. The SDK name must be passed down from the frontend. This will report unsupported configurations like: - Installing roots between incompatible SDKs without deleting the swiftmodule files. - Having multiple targets in the same project using different SDKs. - Loading a swiftmodule created with a newer SDK (and stdlib) with an older SDK. All of these lead to hard to investigate deserialization failures and this change should detect them early, before reaching a deserialization failure. rdar://78048939
21 lines
955 B
Swift
21 lines
955 B
Swift
// RUN: %empty-directory(%t/cache)
|
|
// RUN: %empty-directory(%t/build)
|
|
// RUN: %{python} %utils/split_file.py -o %t %s
|
|
|
|
/// Build Lib against SDK A.
|
|
// RUN: %target-swift-frontend -emit-module %t/Lib.swift -swift-version 5 -target-sdk-name A -o %t/build -parse-stdlib -module-cache-path %t/cache
|
|
|
|
/// Building Client against SDK A should work fine as expected.
|
|
// RUN: %target-swift-frontend -typecheck %t/Client.swift -swift-version 5 -target-sdk-name A -I %t/build -parse-stdlib -module-cache-path %t/cache
|
|
|
|
/// Build Client against SDK B, this should fail at loading Lib against a different SDK than A.
|
|
// RUN: not %target-swift-frontend -typecheck %t/Client.swift -swift-version 5 -target-sdk-name B -I %t/build -parse-stdlib -module-cache-path %t/cache 2>&1 | %FileCheck %s
|
|
// CHECK: cannot load module 'Lib' built with SDK 'A' when using SDK 'B': {{.*}}Lib.swiftmodule
|
|
|
|
// BEGIN Lib.swift
|
|
public func foo() {}
|
|
|
|
// BEGIN Client.swift
|
|
import Lib
|
|
foo()
|