Skip to content

Use the new #available(Android <API>, *) instead from Swift 6.3 to look for backtrace()#1546

Draft
finagolfin wants to merge 2 commits intoswiftlang:mainfrom
finagolfin:droid
Draft

Use the new #available(Android <API>, *) instead from Swift 6.3 to look for backtrace()#1546
finagolfin wants to merge 2 commits intoswiftlang:mainfrom
finagolfin:droid

Conversation

@finagolfin
Copy link
Member

Mads added this compiler feature for Android in swiftlang/swift#84574 before the 6.3 branch, so update the Android triples and NDK version to test it, as it requires NDK 28 or later.

@grynspan, just a pure rebased copy of #1373, unfortunately, may be a while before we can merge it.

@finagolfin finagolfin added android 🤖 Android support cross-compilation Compiling tests for other platforms than the host tech-debt 💾 reduces technical debt labels Feb 12, 2026
@grynspan grynspan added this to the Swift 6.4.0 (main) milestone Feb 12, 2026
@grynspan
Copy link
Contributor

Converted to a draft since it's not possible to safely merge it yet.

@grynspan grynspan marked this pull request as draft February 12, 2026 14:19
…look for `backtrace()`

Mads added this compiler feature for Android in swiftlang/swift#84574 before the
6.3 branch, so update the Android triples and NDK version to test it, as it requires
NDK 28 or later.
@finagolfin
Copy link
Member Author

Rebased and changed official workflow version to get an NDK fix, swiftlang/github-workflows#235, so this pull's CI finally uses the NDK 28 it requires and passes.

This change requires Android NDK 28 or later, but the Swift SDK for Android is still stuck on LTS NDK 27, which doesn't have the header annotations to support this Android availability feature.

I just tried changing the availability condition to if __NDK_MAJOR__ > 27, #available(Android 33, *) {, using that NDK C define, which worked fine with NDK 29 but doesn't compile with NDK 27, as it still looks for backtrace without the required NDK header changes, /home/finagolfin/swift-testing/Sources/Testing/SourceAttribution/Backtrace.swift:82:27: error: cannot find 'backtrace' in scope.

I think this would be fixed if we had compile-time NDK versioning, swiftlang/swift#81402, but for now, users will have to choose one NDK or the other and we cannot merge this till all Android CI switch to NDK 28 or later.

@grynspan
Copy link
Contributor

I just tried changing the availability condition to if __NDK_MAJOR__ > 27, #available(Android 33, *) {, using that NDK C define, which worked fine with NDK 29 but doesn't compile with NDK 27, as it still looks for backtrace without the required NDK header changes, /home/finagolfin/swift-testing/Sources/Testing/SourceAttribution/Backtrace.swift:82:27: error: cannot find 'backtrace' in scope.

Yeah that's not surprising; the __NDK_MAJOR__ test is a runtime test (optimized away obviously) and the symbol is still "needed" at least in debug builds.

I probably said "don't do this" previously, but to cut the knot: maybe add an swt_backtrace() thunk in Stubs.h that checks #if __NDK_MAJOR >= 33 and skip the runtime checks for now?

@finagolfin
Copy link
Member Author

Heh, nice idea but I'd rather not resort to C, will just wait till we update the NDK. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

android 🤖 Android support cross-compilation Compiling tests for other platforms than the host tech-debt 💾 reduces technical debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants