From a550b794faa99db1b4e0d9768c0ad4a06f9acb69 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Fri, 17 Jan 2025 11:53:22 -0500 Subject: [PATCH 1/2] Revert "Merge pull request #916 from tshortli/fix-wasi-build" This reverts commit 904272145dba929798ef8f99da663a813541243c, reversing changes made to dfa0d2460e4e6d27b18e50b34b942ff5f81c12ae. --- Sources/Testing/Discovery.swift | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Sources/Testing/Discovery.swift b/Sources/Testing/Discovery.swift index d9acdca19..0a566c36c 100644 --- a/Sources/Testing/Discovery.swift +++ b/Sources/Testing/Discovery.swift @@ -86,13 +86,8 @@ struct TestContentRecord: Sendable where T: ~Copyable { /// with interfaces such as `dlsym()` that expect such a pointer. #if SWT_NO_DYNAMIC_LINKING @available(*, unavailable, message: "Image addresses are not available on this platform.") - nonisolated(unsafe) var imageAddress: UnsafeRawPointer? { - get { fatalError() } - set { fatalError() } - } -#else - nonisolated(unsafe) var imageAddress: UnsafeRawPointer? #endif + nonisolated(unsafe) var imageAddress: UnsafeRawPointer? /// The underlying test content record loaded from a metadata section. private var _record: __TestContentRecord From ae3ae7c225bc919b14c3da7080280db85e8d7172 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Fri, 17 Jan 2025 11:54:11 -0500 Subject: [PATCH 2/2] Revert #916 and apply a slightly different change. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thank you to @tshortli for the patch! We don't actually _need_ this property to be unavailable on WASI—it was just meant as a convenience. But since we're not using the property for anything at this time (a future PR might try to productize `TestContentRecord`), it's overkill. So instead I'll just leave the property available, and document it's always `nil` on statically-linked platforms. --- Sources/Testing/Discovery.swift | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Sources/Testing/Discovery.swift b/Sources/Testing/Discovery.swift index 0a566c36c..5ce454d1c 100644 --- a/Sources/Testing/Discovery.swift +++ b/Sources/Testing/Discovery.swift @@ -78,24 +78,19 @@ protocol TestContent: ~Copyable { struct TestContentRecord: Sendable where T: ~Copyable { /// The base address of the image containing this instance, if known. /// - /// This property is not available on platforms such as WASI that statically - /// link to the testing library. + /// On platforms such as WASI that statically link to the testing library, the + /// value of this property is always `nil`. /// /// - Note: The value of this property is distinct from the pointer returned /// by `dlopen()` (on platforms that have that function) and cannot be used /// with interfaces such as `dlsym()` that expect such a pointer. -#if SWT_NO_DYNAMIC_LINKING - @available(*, unavailable, message: "Image addresses are not available on this platform.") -#endif nonisolated(unsafe) var imageAddress: UnsafeRawPointer? /// The underlying test content record loaded from a metadata section. private var _record: __TestContentRecord fileprivate init(imageAddress: UnsafeRawPointer?, record: __TestContentRecord) { -#if !SWT_NO_DYNAMIC_LINKING self.imageAddress = imageAddress -#endif self._record = record } }