From 1bb0b6e4519896541da76b27ab0495b6a3a36377 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, so update the NDK version too, since that new feature requires NDK 28 or later. --- .github/workflows/pull_request.yml | 1 + Sources/Testing/SourceAttribution/Backtrace.swift | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 086b2226e..8f51610b8 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -25,6 +25,7 @@ jobs: ios_host_exclude_xcode_versions: '[{"xcode_version": "16.2"}, {"xcode_version": "16.3"}, {"xcode_version": "16.4"}]' enable_wasm_sdk_build: true enable_android_sdk_build: true + android_ndk_version: '["r28c"]' soundness: name: Soundness uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main 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))) }