Error when running swift-algorithmsPackageTests.xctest: "unknown reloc type 16"
marcprux opened this issue · 9 comments
When building and running tests against swift-algorithms
on an x86 host+emulator with the Swift 6.0 Android toolchain, I'm seeing the following warning and error:
WARNING: linker: /data/local/tmp/swift-android/swift-algorithms/swift-algorithmsPackageTests.xctest: unsupported flags DT_FLAGS_1=0x8000001
CANNOT LINK EXECUTABLE "/data/local/tmp/swift-android/swift-algorithms/swift-algorithmsPackageTests.xctest": unknown reloc type 16 @ 0x7e9b7e351e48 (16114)
Error: Error terminated(code: 134) running command: /Users/runner/Library/Android/sdk/platform-tools/adb shell /data/local/tmp/swift-android/swift-algorithms/swift-algorithmsPackageTests.xctest
This doesn't occur when running on an arm host+emulator (the tests all run and pass on my machine).
It's especially odd, since this package is passing tests on CI.
Is this something that termux-elf-cleaner might help with? I notice that we are using it in CI, but only for the swift-argument-parser
tests and not any other packages.
What Android APIs are you running it on in the emulator? List out what APIs you tried for each of arm and x86.
Is this something that termux-elf-cleaner might help with?
No, I tried, it doesn't. This is related to the TLS issue I mentioned earlier.
This is related to the TLS issue I mentioned earlier.
FTR, the issue mentioned is: #170 (comment)
What Android APIs are you running it on in the emulator? List out what APIs you tried for each of arm and x86.
I haven't tested against arm API variations yet, but on x86, testing swift-algorithms fails against API 25–28, and passes on API 29+ (see https://github.com/marcprux/swift-algorithms/actions/runs/11114132859). This tracks with the note about TLS becoming available in API 29: https://github.com/aosp-mirror/platform_bionic/blob/master/android-changes-for-ndk-developers.md#elf-tls-available-for-api-level--29
I haven't tested against arm API variations yet
OK, but you tested it on some AArch64 device or emulator, what API was that? I just wonder if it works before API 29 on AArch64.
This tracks with the note about TLS becoming available in API 29
Yep, this is why I raised the API used on the CI emulator from 24 to 29 with Swift 6, because all the test runners were failing otherwise.
The problem is that a Swift file in Foundation calls that inline _swift_stdlib_gettid()
function from the stdlib's synchronization shims that now uses a TLS variable, and that C++ code is presumably compiled by the Swift compiler somehow without specifying an API level, which on Android then defaults to the latest API level, ie with native TLS.
We'll need to find where in the Swift compiler such inline compilation of C++ functions is done and check what it's doing wrong. The full target triple with the API level is passed to the ClangImporter
that integrates C/C++ headers, so I'm not sure why this C++ compilation doesn't.
OK, but you tested it on some AArch64 device or emulator, what API was that? I just wonder if it works before API 29 on AArch64.
It was API 34.
I don't recall when this changed, but it works now. Closing.
Doesn't appear to be the case, where did you see it working?
Doesn't appear to be the case, where did you see it working?
Sorry, you are right. I was accidentally running against Android API 29 rather than 28 as I had thought.
I've submitted a fix for this upstream, swiftlang/swift#77883.