Android: Use CMAKE_SYSROOT for Android sysroot#87293
Conversation
The NDK configures `CMAKE_SYSROOT` in `android-legacy.toolchain.cmake`. I've verified this from Android NDK r26b to r29. This gets the build system cross-compiling to Android from a non-Windows builder.
|
@swift-ci please test |
|
The Windows bits don't appear to be using the Android NDK toolchain file, which might be why |
|
Linux test failure: This is not affected by the Android build. macOS failure was a clang segfault while building parts of compiler-rt for the iOS simulator: Also unrelated to changes to Android. |
When cross-compiling, the toolchain file is supposed to set the `CMAKE_SYSROOT` variable, which In this case, there is no toolchain file to set it as build.ps1 is passing everything through explicitly. Setting it explicitly now for the C and C++ bits and for computing flags. CMake doesn't yet support passing `CMAKE_SYSROOT` to the Swift compiler via the `sysroot` flag though: https://gitlab.kitware.com/cmake/cmake/-/work_items/27717 For now, we need to keep passing it as an explicit Swift flag.
|
@swift-ci please test |
7ed0f2d to
0cef5bc
Compare
|
@swift-ci please test |
compnerd
left a comment
There was a problem hiding this comment.
I definitely like the removal of --sysroot from C/CXX FLAGS
|
The Windows failure is unrelated and should have been fixed by swiftlang/swift-build#1236 |
|
@swift-ci please test Windows |
|
The pre-commit Windows CI do nothing with Android, so if you want to test this, I suggest you temporarily add the That linked pull is so we can add building Android SDKs to the pre-commit Windows CI and avoid manual testing workarounds like this. |
Yeah, I know. I'm just trying to get this merged. |
|
@swift-ci please test macOS |
|
I'm just worried this may break the trunk Windows snapshot toolchain CI, which adds that flag I linked and builds the Android SDKs but only after these pulls are merged, so suggesting this be tested first. |
|
@swift-ci please test macOS |
|
I hope you weren't waiting for me to sign off on this, Evan. All I meant last month is that the current pre-merge Windows CI do not build the Android SDKs, #87867, so I have been testing Android changes like this on Windows by modifying that batch file and running the PR toolchain CI, then removing that flag before merging. I was simply suggesting you do the same, but not a problem at all if you don't, as the post-merge Windows trunk snapshot toolchain CI will give us that signal anyway. |
|
Ah, okay. I tested it on my Windows box locally. I'll keep an eye out for failures on Windows from this. |
The NDK configures
CMAKE_SYSROOTinandroid-legacy.toolchain.cmake. I've verified this from Android NDK r26b to r29.This gets the build system cross-compiling to Android from a non-Windows builder.