mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Option to disable printing package-name in public or private interface.
Having package-name flag in non-package interfaces causes them to be built as if belonging to a package, which causes an issue for a loading client outside of the package as follows. For example, when building X that depends on A with the following dependency chain: X --> A --> B --(package-only)--> C 1. X itself is not in the same package as A, B, and C. 2. When dependency scanning X, and opening up B, because the scan target is in a different package domain, the scanner decides that B's package-only dependency on C is to be ignored. 3. When then finally building A itself, it will load its dependencies, but because the .private.swiftinterface of A still specifies -package-name, when it loads B, it will then examine its dependencies and deem that this package-only dependency on C is required. Because (2) and (3) disagree, we get an error now when building the private A textual interface. rdar://130701866
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
/// Do not print package-name for public or private interfaces
|
||||
// RUN: %target-build-swift -emit-module %s -I %t \
|
||||
// RUN: -module-name Bar -package-name foopkg \
|
||||
// RUN: -enable-library-evolution -swift-version 6 \
|
||||
// RUN: -package-name barpkg \
|
||||
// RUN: -Xfrontend -disable-print-package-name-for-non-package-interface \
|
||||
// RUN: -emit-module-interface-path %t/Bar.swiftinterface \
|
||||
// RUN: -emit-private-module-interface-path %t/Bar.private.swiftinterface \
|
||||
// RUN: -emit-package-module-interface-path %t/Bar.package.swiftinterface
|
||||
|
||||
// RUN: %FileCheck %s --check-prefix=CHECK-PUBLIC < %t/Bar.swiftinterface
|
||||
// RUN: %FileCheck %s --check-prefix=CHECK-PRIVATE < %t/Bar.private.swiftinterface
|
||||
// RUN: %FileCheck %s --check-prefix=CHECK-PACKAGE < %t/Bar.package.swiftinterface
|
||||
|
||||
// CHECK-PUBLIC-NOT: -package-name foopkg
|
||||
// CHECK-PUBLIC-NOT: -package-name barpkg
|
||||
// CHECK-PRIVATE-NOT: -package-name foopkg
|
||||
// CHECK-PRIVATE-NOT: -package-name barpkg
|
||||
// CHECK-PACKAGE-NOT: -package-name foopkg
|
||||
// CHECK-PACKAGE: -package-name barpkg
|
||||
|
||||
// CHECK-PUBLIC: -module-name Bar
|
||||
// CHECK-PRIVATE: -module-name Bar
|
||||
// CHECK-PACKAGE: -module-name Bar
|
||||
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface %t/Bar.swiftinterface -o %t/Bar.swiftmodule -module-name Bar
|
||||
// RUN: rm -rf %t/Bar.swiftmodule
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface %t/Bar.private.swiftinterface -o %t/Bar.swiftmodule -module-name Bar
|
||||
// RUN: rm -rf %t/Bar.swiftmodule
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface %t/Bar.package.swiftinterface -o %t/Bar.swiftmodule -module-name Bar
|
||||
|
||||
// RUN: rm -rf %t/Bar.swiftmodule
|
||||
// RUN: rm -rf %t/Bar.swiftinterface
|
||||
// RUN: rm -rf %t/Bar.private.swiftinterface
|
||||
// RUN: rm -rf %t/Bar.package.swiftinterface
|
||||
|
||||
/// By default, -package-name is printed in all interfaces.
|
||||
// RUN: %target-build-swift -emit-module %s -I %t \
|
||||
// RUN: -module-name Bar -package-name barpkg \
|
||||
// RUN: -enable-library-evolution -swift-version 6 \
|
||||
// RUN: -emit-module-interface-path %t/Bar.swiftinterface \
|
||||
// RUN: -emit-private-module-interface-path %t/Bar.private.swiftinterface \
|
||||
// RUN: -emit-package-module-interface-path %t/Bar.package.swiftinterface
|
||||
|
||||
// RUN: %FileCheck %s < %t/Bar.swiftinterface
|
||||
// RUN: %FileCheck %s < %t/Bar.private.swiftinterface
|
||||
// RUN: %FileCheck %s < %t/Bar.package.swiftinterface
|
||||
|
||||
// CHECK: -package-name barpkg
|
||||
// CHECK: -module-name Bar
|
||||
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface %t/Bar.swiftinterface -o %t/Bar.swiftmodule -module-name Bar
|
||||
// RUN: rm -rf %t/Bar.swiftmodule
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface %t/Bar.private.swiftinterface -o %t/Bar.swiftmodule -module-name Bar
|
||||
// RUN: rm -rf %t/Bar.swiftmodule
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface %t/Bar.package.swiftinterface -o %t/Bar.swiftmodule -module-name Bar
|
||||
|
||||
public struct PubStruct {}
|
||||
@_spi(bar) public struct SPIStruct {}
|
||||
package struct PkgStruct {}
|
||||
Reference in New Issue
Block a user