Skip to content

Commit 1bb0b6e

Browse files
committed
Use the new #available(Android <API>, *) 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.
1 parent b0aef48 commit 1bb0b6e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

.github/workflows/pull_request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
ios_host_exclude_xcode_versions: '[{"xcode_version": "16.2"}, {"xcode_version": "16.3"}, {"xcode_version": "16.4"}]'
2626
enable_wasm_sdk_build: true
2727
enable_android_sdk_build: true
28+
android_ndk_version: '["r28c"]'
2829
soundness:
2930
name: Soundness
3031
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main

Sources/Testing/SourceAttribution/Backtrace.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public struct Backtrace: Sendable {
4040
self.addresses = addresses.map { Address(UInt(bitPattern: $0)) }
4141
}
4242

43-
#if os(Android) && !SWT_NO_DYNAMIC_LINKING
43+
#if compiler(<6.3) && os(Android)
4444
/// The `backtrace()` function.
4545
///
4646
/// This function was added to Android with API level 33, which is higher than
@@ -76,7 +76,13 @@ public struct Backtrace: Sendable {
7676
initializedCount = .init(clamping: backtrace(addresses.baseAddress!, .init(clamping: addresses.count)))
7777
}
7878
#elseif os(Android)
79-
#if !SWT_NO_DYNAMIC_LINKING
79+
#if compiler(>=6.3)
80+
if #available(Android 33, *) {
81+
initializedCount = addresses.withMemoryRebound(to: UnsafeMutableRawPointer.self) { addresses in
82+
.init(clamping: backtrace(addresses.baseAddress!, .init(clamping: addresses.count)))
83+
}
84+
}
85+
#else
8086
if let _backtrace {
8187
initializedCount = .init(clamping: _backtrace(addresses.baseAddress!, .init(clamping: addresses.count)))
8288
}

0 commit comments

Comments
 (0)