Skip to content

Commit f936234

Browse files
committed
Add package-name flag to public .swiftinterface
Usually package symbols are not printed in public .swiftinterface but if they are @usableFromInlinable or @inlinable they are printed. However, the -package-name flag is not visible (currently only printed in .private.swiftinterface); this was intended to ensure a strict boundary between external clients and a package. This however causes ABI breakage; it is possible for an external client to access a symbol that used to be public but now @usableFromInlinable package. This PR adds the flag back into the public interface as it was previously written. The ignorable private flag flow is left as is, in case we might have to move the flag back to that category. We will separately track adding a guard around the package-name value for SDKs to make sure they are public facing names. Resolves rdar://116142791
1 parent 1470023 commit f936234

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

include/swift/Option/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ def module_abi_name : Separate<["-"], "module-abi-name">,
542542
Flags<[FrontendOption, ModuleInterfaceOption]>,
543543
HelpText<"ABI name to use for the contents of this module">;
544544
def package_name : Separate<["-"], "package-name">,
545-
Flags<[FrontendOption, ModuleInterfaceOptionIgnorablePrivate]>,
545+
Flags<[FrontendOption, ModuleInterfaceOption]>,
546546
HelpText<"Name of the package the module belongs to">;
547547
def export_as : Separate<["-"], "export-as">,
548548
Flags<[FrontendOption, ModuleInterfaceOption]>,

test/Sema/accessibility_package_interface.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,22 @@
1414
// CHECK-PUBLIC-NOT: -package-name swift-utils.log
1515
// CHECK-PUBLIC-NOT: package func packageFunc()
1616
// CHECK-PUBLIC: -module-name Utils
17+
// CHECK-PUBLIC: -package-name swift-utils.log
1718
// CHECK-PUBLIC: public func publicFunc()
1819

1920
// RUN: %target-swift-typecheck-module-from-interface(%t/Utils.private.swiftinterface) -module-name Utils -I %t
2021
// RUN: %FileCheck %s --check-prefix=CHECK-PRIVATE < %t/Utils.private.swiftinterface
2122

23+
// CHECK-PRIVATE-NOT: swift-module-flags-ignorable-private: -package-name swift-utils.log
2224
// CHECK-PRIVATE-NOT: package func packageFunc()
23-
// CHECK-PRIVATE: swift-module-flags-ignorable-private: -package-name swift-utils.log
25+
// CHECK-PRIVATE: -package-name swift-utils.log
2426
// CHECK-PRIVATE: public func publicFunc()
2527

2628
// RUN: %target-swift-frontend -typecheck %t/Client.swift -package-name swift-utils.log -I %t -verify
2729

2830
//--- Utils.swift
2931
package func packageFunc() {}
32+
@usableFromInline package func ufiPackageFunc() {}
3033
public func publicFunc() {}
3134

3235
//--- Client.swift
@@ -36,3 +39,7 @@ func clientFunc() {
3639
packageFunc()
3740
publicFunc()
3841
}
42+
43+
@inlinable public func inlinableClientFunc() {
44+
ufiPackageFunc()
45+
}

test/Serialization/load_package_module.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919
// RUN: %target-swift-typecheck-module-from-interface(%t/LibInterface.swiftinterface) -I %t
2020
// RUN: %FileCheck %s --check-prefix=CHECK-PUBLIC < %t/LibInterface.swiftinterface
2121
// CHECK-PUBLIC: -module-name LibInterface
22-
// CHECK-PUBLIC-NOT: -package-name
22+
// CHECK-PUBLIC: -package-name libPkg
2323

2424
// RUN: %target-swift-typecheck-module-from-interface(%t/LibInterface.private.swiftinterface) -module-name LibInterface -I %t
2525
// RUN: %FileCheck %s --check-prefix=CHECK-PRIVATE < %t/LibInterface.private.swiftinterface
26-
// CHECK-PRIVATE: swift-module-flags-ignorable-private: -package-name libPkg
26+
// CHECK-PRIVATE-NOT: swift-module-flags-ignorable-private: -package-name libPkg
27+
// CHECK-PRIVATE: -package-name libPkg
2728

2829
// RUN: not %target-swift-frontend -typecheck %t/ClientLoadInterface.swift -package-name otherPkg -I %t 2> %t/resultX.output
2930
// RUN: %FileCheck %s -check-prefix CHECK-X < %t/resultX.output

test/Serialization/module_package_name.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
// RUN: %target-swift-typecheck-module-from-interface(%t/Logging.swiftinterface) -I %t
1212
// RUN: %FileCheck %s --check-prefix=CHECK-PUBLIC < %t/Logging.swiftinterface
1313
// CHECK-PUBLIC: -module-name Logging
14-
// CHECK-PUBLIC-NOT: -package-name
14+
// CHECK-PUBLIC: -package-name MyLoggingPkg
1515

1616
// RUN: %target-swift-typecheck-module-from-interface(%t/Logging.private.swiftinterface) -module-name Logging -I %t
1717
// RUN: %FileCheck %s --check-prefix=CHECK-PRIVATE < %t/Logging.private.swiftinterface
18+
// CHECK-PRIVATE-NOT: swift-module-flags-ignorable-private: -package-name MyLoggingPkg
1819
// CHECK-PRIVATE: -module-name Logging
19-
// CHECK-PRIVATE: swift-module-flags-ignorable-private: -package-name MyLoggingPkg
20+
// CHECK-PRIVATE: -package-name MyLoggingPkg
2021

2122
//--- File.swift
2223
public func log(level: Int) {}

0 commit comments

Comments
 (0)