Carry the Android API level into Swift's target triple#1857
Carry the Android API level into Swift's target triple#1857AttilaTheFun wants to merge 1 commit into
Conversation
2727792 to
f26da8d
Compare
The NDK cc toolchain reports a level-less target_gnu_system_name (aarch64-linux-android), so Swift compiles with an availability floor below the SDK's actual minimum - e.g. swift-log fails to build because 'stdout' is 'only available in Android 23 or newer', even though the Swift Android SDK bundle itself declares aarch64-unknown-linux-android28. - swift_toolchain gains an optional target_system_name attribute that overrides the cc-toolchain-derived triple. - The generated Android SDK toolchains pass the bundle's own triple, read from swift-sdk.json's targetTriples (API level included). Verified by cross-compiling swift-log / swift-nio / grpc-swift-2 for aarch64 Android and running a gRPC round trip on-device.
f26da8d to
5e26876
Compare
|
is it safe for us to derive this versus trying to match what is setup by the user in their NDK toolchain setup? |
|
The Swift Android SDK bundle ships a per-API-level stdlib and declares the whole ladder it supports. For 6.3.2 that's
But you're right that "derive" and "match the user's NDK" can diverge:
If you'd prefer we track the user's level rather than the bundle floor, the clean version is: take the API level the NDK is already configured with (the same min-sdk that drives clang's |
|
Opened #1858 as an alternative that implements the "match the NDK's level" behavior I described above: an This PR (#1857) keeps the simpler "always use the bundle floor" approach. They're behavior-identical for the common level-less NDK today; #1858 adds the knob + the don't-override guard. Happy to land whichever you prefer — I'll close the other. |
The NDK cc toolchain reports a level-less
target_gnu_system_name(aarch64-linux-android), so Swift compiles with an availability floor below the SDK's actual minimum. Concretely, cross-compilingswift-logfor Android fails with:even though the Swift Android SDK bundle itself declares
aarch64-unknown-linux-android28in itsswift-sdk.json.This PR:
target_system_nameattribute toswift_toolchainthat overrides the cc-toolchain-derived triple, andswift-sdk.json'stargetTriples(API level included). The wasm toolchain generation is unchanged (empty override).Verified by cross-compiling
swift-log/swift-nio/grpc-swift-2(via rules_swift_package_manager) for aarch64 Android and running a plaintext HTTP/2 gRPC round trip against a host server from the Android emulator: