From a3ac36c96d0b3dd31f52111bf9e0c8a3e98c3c0f Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Tue, 12 Dec 2023 12:05:41 -0800 Subject: [PATCH 1/2] [native] Stop using @_implementationOnly import in package configs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @_implementationOnly does not work correctly unless Swift’s Library Evolution dialect is enabled — it leads to obscure module loading failures. There seems to be no way to create a compile-time condition on whether library evolution is enabled, so we need to stop using @_implementationOnly imports in all package configurations. --- Sources/Atomics/Unmanaged extensions.swift | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Sources/Atomics/Unmanaged extensions.swift b/Sources/Atomics/Unmanaged extensions.swift index f2e07b3..a9edfa3 100644 --- a/Sources/Atomics/Unmanaged extensions.swift +++ b/Sources/Atomics/Unmanaged extensions.swift @@ -16,9 +16,17 @@ internal func _sa_retain_n(_ object: UnsafeMutableRawPointer, _ delta: UInt32) @_silgen_name("_sa_release_n") internal func _sa_release_n(_ object: UnsafeMutableRawPointer, _ delta: UInt32) -#elseif ATOMICS_NATIVE_BUILTINS -@_implementationOnly import _AtomicsShims #else +// Note: with ATOMICS_NATIVE_BUILTINS, this file contains the last remaining +// import of the shims module, and we only need it to get the declarations for +// _sa_retain_n/_sa_release_n. The import is unfortunately still problematic; +// these functions need to be moved into the stdlib or (preferably) we need +// a compiler-level fix for https://bugs.swift.org/browse/SR-13708 to get rid +// of it. +// +// Hiding the import using @_implementationOnly is not possible unless +// Swift's library evolution dialect is enabled. (Which we cannot easily test +// here.) Perhaps `internal import` will help work around this at some point. import _AtomicsShims #endif From 074c8c8feadd5d659f85826928f7448ec58b05aa Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Wed, 13 Dec 2023 15:04:52 -0800 Subject: [PATCH 2/2] Update link to compiler issue Co-authored-by: Guillaume Lessard --- Sources/Atomics/Unmanaged extensions.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Atomics/Unmanaged extensions.swift b/Sources/Atomics/Unmanaged extensions.swift index a9edfa3..c664959 100644 --- a/Sources/Atomics/Unmanaged extensions.swift +++ b/Sources/Atomics/Unmanaged extensions.swift @@ -21,7 +21,7 @@ internal func _sa_release_n(_ object: UnsafeMutableRawPointer, _ delta: UInt32) // import of the shims module, and we only need it to get the declarations for // _sa_retain_n/_sa_release_n. The import is unfortunately still problematic; // these functions need to be moved into the stdlib or (preferably) we need -// a compiler-level fix for https://bugs.swift.org/browse/SR-13708 to get rid +// a compiler-level fix for https://github.com/apple/swift/issues/56105 to get rid // of it. // // Hiding the import using @_implementationOnly is not possible unless