Android SDK support on Linux ARM64

I am getting build error on latest 6.4.0 Android SDK on arm64 ubuntu 24.04

/home/runner/work/setup-swift/setup-swift/Package.swift: SetupLib: clang: error: unable to execute command: posix_spawn failed: Exec format error

/home/runner/work/setup-swift/setup-swift/Package.swift: SetupLib: clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: Ld /home/runner/work/setup-swift/setup-swift/.build/out/Products/Debug-android-aarch64/SetupLib.o normal failed with a nonzero exit code. Command line: cd /home/runner/work/setup-swift/setup-swift

/opt/hostedtoolcache/swift-6.4.0-RELEASE-ubuntu2404-aarch64/6.4.0/aarch64/usr/bin/clang -target aarch64-unknown-linux-android28 -r --sysroot /home/runner/.config/swiftpm/swift-sdks/swift-6.4.0-RELEASE_android.artifactbundle/swift-android/android-ndk-r27d/toolchains/llvm/prebuilt/linux-x86_64/sysroot -resource-dir /home/runner/.config/swiftpm/swift-sdks/swift-6.4.0-RELEASE_android.artifactbundle/swift-android/android-ndk-r27d/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/18 -O0 @/home/runner/work/setup-swift/setup-swift/.build/out/Intermediates.noindex/SetupLib.build/Debug-android-aarch64/SetupLib-t.build/Objects-normal/aarch64/SetupLib.LinkFileList -nostdlib -fuse-ld\\=lld --ld-path\\=/home/runner/.config/swiftpm/swift-sdks/swift-6.4.0-RELEASE_android.artifactbundle/swift-android/android-ndk-r27d/toolchains/llvm/prebuilt/linux-x86_64/bin/ld.lld -o /home/runner/work/setup-swift/setup-swift/.build/out/Products/Debug-android-aarch64/SetupLib.o

error: Build failed

The build used to work on 6.3.3. Is there additional set up required for arm64 ubuntu 24.04?

More details:

This is a result of the switch to the new Swift Build build system in SwiftPM 6.4.0 exposing that this CI setup was not really doing much in the first place. Try adding --build-system native to the Android command to go back to the old behavior that worked.

We sort of supported these linux/AArch64 setups with the native build system so far by only using the LLVM tools like lld from the Swift toolchain itself to compile C/C++ and link too, but the new build system tries to use the NDK lld, ld-path\=/home/runner/.config/swiftpm/swift-sdks/swift-6.4.0-RELEASE_android.artifactbundle/swift-android/android-ndk-r27d/toolchains/llvm/prebuilt/linux-x86_64/bin/ld.lld, which fails since the Android NDK only has x86_64 tools on linux (work is underway on a linux/AArch64 NDK, but won't be released till NDK 31 or later).

Since nobody is really testing building Android on linux/AArch64 much to my knowledge, my suggestion would be not to use that build host right now, though switching build systems should work.