swift-testing: Failing to build for Android in SPI
Looks like Swift Testing is failing to build for Android on Swift Package Index’s site: https://swiftpackageindex.com/builds/875FEA40-0F76-47AF-A7E3-54A39616BA9C
/host/spi-builder-workspace/Sources/Testing/SourceAttribution/Backtrace.swift:70:56: error: cannot convert value of type 'UnsafeMutablePointer<UnsafeMutableRawPointer>' to expected argument type 'UnsafeMutablePointer<UnsafeMutableRawPointer?>'
68 | #elseif os(Android)
69 | initializedCount = addresses.withMemoryRebound(to: UnsafeMutableRawPointer.self) { addresses in
70 | .init(clamping: backtrace(addresses.baseAddress!, .init(clamping: addresses.count)))
| |- error: cannot convert value of type 'UnsafeMutablePointer<UnsafeMutableRawPointer>' to expected argument type 'UnsafeMutablePointer<UnsafeMutableRawPointer?>'
| `- note: arguments to generic parameter 'Pointee' ('UnsafeMutableRawPointer' and 'UnsafeMutableRawPointer?') are expected to be equal
71 | }
72 | #elseif os(Linux) || os(FreeBSD)
We have special-casing to convert the pointers here to remove optionality because, at one point, the signature of backtrace() was annotated such that the pointers were non-optional. This has either changed or is inconsistent across different Android versions.
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 16 (13 by maintainers)
As @finagolfin mentions, the single SDK supports multiple API levels, so you could add an API level parameter to your
.spi.ymland specifyaarch64-unknown-linux-androidN. One tricky area, though, would be a transitive dependency: if packageSomeTestingClienthas API minimum of 30 and its dependentTestinghas a minimum of 33, would you somehow gather all the.spi.ymlfiles and use the max?In my experience, having a package require a higher API level is exceedingly rare, this Testing package being a notable example which we are currently patching around.
All that being said, note that the release candidate for the official 6.2 SDK bundle will bump the minimum API level from 24 to 28, so it will need to be increased in the future.
Once there are official releases, the SDK should start showing up in https://www.swift.org/api/v1/install/releases.json alongside the “static-sdk” releases, so you can eventually use that. Personally, I might just wait for that to be released, because there will (unfortunately) be some additional setup steps that will be required due to the official version not bundling an NDK. You can read about it in my draft PR for the setup instructions: https://github.com/swiftlang/swift-org-website/pull/985