From e6685850fbe8229ac9e20636e59fe03d91984d92 Mon Sep 17 00:00:00 2001 From: Finagolfin Date: Thu, 6 Nov 2025 04:30:57 +0530 Subject: [PATCH] Use the new `#available(Android , *)` instead from Swift 6.3 to look for `backtrace()` Mads just added this compiler feature for Android in swiftlang/swift#84574 --- Sources/Testing/SourceAttribution/Backtrace.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sources/Testing/SourceAttribution/Backtrace.swift b/Sources/Testing/SourceAttribution/Backtrace.swift index 552e16d68..e9f53816e 100644 --- a/Sources/Testing/SourceAttribution/Backtrace.swift +++ b/Sources/Testing/SourceAttribution/Backtrace.swift @@ -40,7 +40,7 @@ public struct Backtrace: Sendable { self.addresses = addresses.map { Address(UInt(bitPattern: $0)) } } -#if os(Android) && !SWT_NO_DYNAMIC_LINKING +#if compiler(<6.3) && os(Android) /// The `backtrace()` function. /// /// This function was added to Android with API level 33, which is higher than @@ -76,7 +76,13 @@ public struct Backtrace: Sendable { initializedCount = .init(clamping: backtrace(addresses.baseAddress!, .init(clamping: addresses.count))) } #elseif os(Android) -#if !SWT_NO_DYNAMIC_LINKING +#if compiler(>=6.3) + if #available(Android 33, *) { + initializedCount = addresses.withMemoryRebound(to: UnsafeMutableRawPointer.self) { addresses in + .init(clamping: backtrace(addresses.baseAddress!, .init(clamping: addresses.count))) + } + } +#else if let _backtrace { initializedCount = .init(clamping: _backtrace(addresses.baseAddress!, .init(clamping: addresses.count))) }