Skip to content

Enable Android emulator testing with the snapshot toolchains employing swift-build in SwiftPM#1745

Open
finagolfin wants to merge 1 commit into
swiftlang:mainfrom
finagolfin:droid
Open

Enable Android emulator testing with the snapshot toolchains employing swift-build in SwiftPM#1745
finagolfin wants to merge 1 commit into
swiftlang:mainfrom
finagolfin:droid

Conversation

@finagolfin

Copy link
Copy Markdown
Member

@marcprux found that the trunk snapshot toolchain now successfully cross-compiles the tests for Android, which I was able to reproduce locally with the latest 6.4 snapshot also. With the latest GitHub workflows using swift-build again for the 6.4 and trunk snapshots, swiftlang/github-workflows#269, let's see if the trunk tests run in the emulator.

We currently cross-compile this repo to Android using the defaults of 6.3, nightly-6.3, and trunk, and we'll probably add nightly-6.4 soon: can we drop cross-compiling for Android with 6.3 then? That will allow us to run the tests for 6.4 and trunk in the emulator, without any workarounds needed for 6.3 being unable to cross-compile these tests.

tests:
name: Test
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@0.0.11
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shahmishal Should we cut a new tag of swift_package_test? I would rather we not depend on main here, but the last tag was April 14th

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hold on, we're still adjusting the Android workflow to swift-build, swiftlang/github-workflows#277 and the NDK bug below, for which this repo is a good test.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just echoing @harlanhaskins: I think we should not switch to main, and should instead wait for a new tag of github-workflows containing whatever new content you need. We use pinned versions intentionally.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but I can't test those new workflow changes from upstream without this update of the workflow branch here, while I work on this pull and the workflow changes needed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely, no problem. I only meant to say that I think by the time this lands, we ought to replace this with a new tag. Using it temporarily to iterate makes sense

@finagolfin finagolfin changed the title Enable Android emulator testing with the snapshot toolchains enabling swift-build in SwiftPM Enable Android emulator testing with the snapshot toolchains employing swift-build in SwiftPM Jun 5, 2026
@marcprux

marcprux commented Jun 5, 2026

Copy link
Copy Markdown

Weird, failing with:

/home/runner/work/swift-testing/swift-testing/Sources/Testing/SourceAttribution/Backtrace.swift:75:27: error: cannot find 'backtrace' in scope
 73 |       if #available(Android 33, *) {
 74 |         initializedCount = addresses.withMemoryRebound(to: UnsafeMutableRawPointer.self) { addresses in
 75 |           .init(clamping: backtrace(addresses.baseAddress!, .init(clamping: addresses.count)))
    |                           `- error: cannot find 'backtrace' in scope
 76 |         }
 77 |       }

Why isn't the #available(Android 33, *) guard working? Some new regression? Any ideas, @madsodgaard?

@finagolfin

Copy link
Copy Markdown
Member Author

I am trying to reproduce that failure locally with the trunk snapshot toolchain, will let you know.

@finagolfin

Copy link
Copy Markdown
Member Author

Huh, I cannot reproduce that build error in a linux environment running the same commands, implying it is something specific to the CI environment.

@finagolfin

Copy link
Copy Markdown
Member Author

Oh, found it, swift-build is using the wrong NDK, not the ones we specified: -sdk /usr/local/lib/android/sdk/ndk/27.3.13750724/toolchains/llvm/prebuilt/linux-x86_64/sysroot -sysroot /usr/local/lib/android/sdk/ndk/27.3.13750724/toolchains/llvm/prebuilt/linux-x86_64/sysroot.

@finagolfin

Copy link
Copy Markdown
Member Author

The workflow was updated to add the 6.4 snapshots, will submit a fix for the NDK issue next.

@grynspan

grynspan commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Sounds like this isn't ready to review yet?

@finagolfin

Copy link
Copy Markdown
Member Author

No, the failed tests are an indicator, 😉 but what do you think about disabling 6.3 testing?

@grynspan

grynspan commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

what do you think about disabling 6.3 testing?

Specifically for Android? Sure, I buy it. For all platforms? Nay!

@finagolfin

Copy link
Copy Markdown
Member Author

Specifically for Android?

Yep, just stop cross-compiling trunk for Android with the 6.3 toolchain, as we're doing with this pull still.

For all platforms?

Why not? Doesn't much matter to me, but I don't see any value in continuing to build trunk Testing with 6.3, and I think you once said the practice here is only to keep it compiling with the previous release branch, which is now 6.4.

@grynspan

Copy link
Copy Markdown
Contributor

6.4 hasn't been released yet, and we don't have 6.4 toolchains set up in CI for all platforms. So 6.3 needs to stay for now, but since we don't formally support Android with Swift Testing yet (since, hey, no CI tests!) we can probably drop the 6.3 Android jobs without much fuss.

@stmontgomery

Copy link
Copy Markdown
Contributor

Is the problem that the tests build for 6.3 but they encounter failures? Or do the tests (or the product code itself) fail to build outright? If the former, my preference would be to maintain the CI which builds everything for 6.3, but just disable running the tests on that Swift version.

@finagolfin

Copy link
Copy Markdown
Member Author

@stmontgomery, the latter, ie the tests do not cross-compile for Android with Swift 6.3, whereas they now do with Swift 6.4 and 6.5 using swift-build.

Also, the official Swiftlang workflows don't provide ways to only build for one Swift version while testing other versions.

@stmontgomery stmontgomery added this to the Swift 6.5.0 (main) milestone Jun 11, 2026
@stmontgomery stmontgomery added build 🧱 Affects the project's build configuration or process android 🤖 Android support labels Jun 11, 2026
@stmontgomery

Copy link
Copy Markdown
Contributor

@stmontgomery, the latter, ie the tests do not cross-compile for Android with Swift 6.3, whereas they now do with Swift 6.4 and 6.5 using swift-build.

In that case I'm fine with dropping the 6.3 CI build for Android

@finagolfin finagolfin mentioned this pull request Jun 14, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

android 🤖 Android support build 🧱 Affects the project's build configuration or process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants