Skip to content

Add Android (aarch64) cross-compile support to SwiftTimecodeCore#86

Open
mansbernhardt wants to merge 3 commits into
orchetect:mainfrom
mansbernhardt:android-support
Open

Add Android (aarch64) cross-compile support to SwiftTimecodeCore#86
mansbernhardt wants to merge 3 commits into
orchetect:mainfrom
mansbernhardt:android-support

Conversation

@mansbernhardt
Copy link
Copy Markdown
Contributor

The existing Linux/Glibc/Musl arms in the libc imports cover Linux but not Android, whose Swift SDK exposes its libc as the Android module (Bionic). Without an #elseif canImport(Android) arm, the imports fall through to no-import on Android and the unqualified pow/powf/trunc calls + the ceiling / floor qualified calls fail to resolve.

Verified against the Swift 6.3 open-source toolchain (org.swift.630202603201a) with the Android Swift SDK artifact bundle (android28+) — swift build --target SwiftTimecodeCore --swift-sdk aarch64-unknown-linux-android28 produces an ELF aarch64 .o.

Also adds a GitHub Actions job that runs the same cross-compile in CI so future regressions surface immediately.

Files changed:

  • Sources/SwiftTimecodeCore/Utilities/Outsourced/FloatingPoint and Darwin.swift: add canImport(Android) → import Android in 3 places (top imports, ceiling, floor).
  • Sources/SwiftTimecodeCore/Timecode/Protocol Adoptions/Strideable.swift: add canImport(Android) → import Android in the imports block.
  • .github/workflows/build.yml: new android job builds SwiftTimecodeCore for aarch64-android28 using vapor/swiftly-action to install Swift 6.3 + the Android SDK artifact bundle.

mansbernhardt and others added 3 commits May 9, 2026 18:33
The existing Linux/Glibc/Musl arms in the libc imports cover Linux but
not Android, whose Swift SDK exposes its libc as the `Android` module
(Bionic). Without an `#elseif canImport(Android)` arm, the imports fall
through to no-import on Android and the unqualified `pow`/`powf`/`trunc`
calls + the `ceiling` / `floor` qualified calls fail to resolve.

Verified against the Swift 6.3 open-source toolchain
(org.swift.630202603201a) with the Android Swift SDK artifact bundle
(android28+) — `swift build --target SwiftTimecodeCore --swift-sdk
aarch64-unknown-linux-android28` produces an ELF aarch64 .o.

Also adds a GitHub Actions job that runs the same cross-compile in CI
so future regressions surface immediately.

Files changed:
- Sources/SwiftTimecodeCore/Utilities/Outsourced/FloatingPoint and Darwin.swift:
    add canImport(Android) → import Android in 3 places (top imports,
    `ceiling`, `floor`).
- Sources/SwiftTimecodeCore/Timecode/Protocol Adoptions/Strideable.swift:
    add canImport(Android) → import Android in the imports block.
- .github/workflows/build.yml:
    new `android` job builds SwiftTimecodeCore for aarch64-android28
    using vapor/swiftly-action to install Swift 6.3 + the Android SDK
    artifact bundle.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`vapor/swiftly-action@v0.2 toolchain: "6.3"` is a floating selector — when
Swift 6.3.1 shipped, CI started picking that up and failing to load the
Android SDK's pre-built `.swiftmodule` files (which were compiled by 6.3.0).
Swift's stable ABI covers the runtime, not the swiftmodule binary format —
that requires an exact-version compiler match.
Pin to "6.3.0" to track the Android SDK artifactbundle (also pinned to
6.3-RELEASE). Bump both in lockstep when swift.org publishes a 6.3.1 or
6.4 Android SDK bundle (currently 404).
The previous swift sdk install was incomplete — it only fetches Swift-side
artifacts (stdlib, Foundation .swiftmodule files). C interop in
SwiftOverlayShims needs the NDK's C sysroot (semaphore.h, libc, etc.),
and the SDK bundle's destination JSON needs ANDROID_NDK_HOME baked in by
the setup-android-sdk.sh script that ships with it.
Without these, the build errors mid-compile with:
  'semaphore.h' file not found … could not build C module 'SwiftOverlayShims'
NDK r27d is paired with swift-6.3-RELEASE Android SDK — bump both together
when swift.org publishes a newer SDK bundle.
@orchetect
Copy link
Copy Markdown
Owner

Thanks very much for the submission - I will have a look at this soon.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants