Skip to content

[android] Update to LTS NDK 25b #60938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,6 @@ set(SWIFT_ANDROID_API_LEVEL "" CACHE STRING

set(SWIFT_ANDROID_NDK_PATH "" CACHE STRING
"Path to the directory that contains the Android NDK tools that are executable on the build machine")
set(SWIFT_ANDROID_NDK_CLANG_VERSION "12.0.9" CACHE STRING
"The Clang version to use when building for Android.")
set(SWIFT_ANDROID_DEPLOY_DEVICE_PATH "" CACHE STRING
"Path on an Android device where build products will be pushed. These are used when running the test suite against the device")

Expand Down
2 changes: 0 additions & 2 deletions cmake/caches/Runtime-Android-aarch64.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,3 @@ set(SWIFT_SDK_ANDROID_ARCHITECTURES aarch64 CACHE STRING "")

# NOTE(compnerd) this is lollipop, which seems to still have decent usage.
set(SWIFT_ANDROID_API_LEVEL 21 CACHE STRING "")
# NOTE(compnerd) this matches the value from the NDK r24.
set(SWIFT_ANDROID_NDK_CLANG_VERSION 14.0.1 CACHE STRING "" FORCE)
3 changes: 0 additions & 3 deletions cmake/caches/Runtime-Android-armv7.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,3 @@ set(SWIFT_SDK_ANDROID_ARCHITECTURES armv7 CACHE STRING "")

# NOTE(compnerd) this is lollipop, which seems to still have decent usage.
set(SWIFT_ANDROID_API_LEVEL 21 CACHE STRING "")
# NOTE(compnerd) this matches the value from the NDK r24.
set(SWIFT_ANDROID_NDK_CLANG_VERSION 14.0.1 CACHE STRING "" FORCE)

10 changes: 5 additions & 5 deletions docs/Android.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ To follow along with this guide, you'll need:
instructions in the Swift project README.
2. The latest build of the Swift compiler for your Linux distro, available at
https://www.swift.org/download/ or sometimes your distro package manager.
3. The latest version of the Android LTS NDK (r23c at the time of this writing),
3. The latest version of the Android LTS NDK (r25b at the time of this writing),
available to download here:
https://developer.android.com/ndk/downloads
4. An Android device with remote debugging enabled or the emulator. We require
Expand All @@ -54,7 +54,7 @@ and the prebuilt Swift toolchain (add --skip-early-swift-driver if you already
have a Swift toolchain in your path):

```
$ NDK_PATH=path/to/android-ndk-r23c
$ NDK_PATH=path/to/android-ndk-r25b
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2022-05-31-a-ubuntu20.04/usr/bin
$ git checkout swift-DEVELOPMENT-SNAPSHOT-2022-05-31-a
$ utils/build-script \
Expand Down Expand Up @@ -83,7 +83,7 @@ Then use the standalone Swift stdlib from the previous step to compile a Swift
source file, targeting Android:

```
$ NDK_PATH="path/to/android-ndk-r23c"
$ NDK_PATH="path/to/android-ndk-r25b"
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2022-05-31-a-ubuntu20.04/usr/bin
$ $SWIFT_PATH/swiftc \ # The prebuilt Swift compiler you downloaded
# The location of the tools used to build Android binaries
Expand Down Expand Up @@ -133,7 +133,7 @@ $ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libBlo
In addition, you'll also need to copy the Android NDK's libc++:

```
$ adb push /path/to/android-ndk-r23c/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so /data/local/tmp
$ adb push /path/to/android-ndk-r25b/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so /data/local/tmp
```

Finally, you'll need to copy the `hello` executable you built in the
Expand Down Expand Up @@ -176,7 +176,7 @@ $ utils/build-script \
-R \ # Build in ReleaseAssert mode.
-T \ # Run all tests, including on the Android device (add --host-test to only run Android tests on the Linux host).
--android \ # Build for Android.
--android-ndk ~/android-ndk-r23c \ # Path to an Android NDK.
--android-ndk ~/android-ndk-r25b \ # Path to an Android NDK.
--android-arch aarch64 \ # Optionally specify Android architecture, alternately armv7
--android-api-level 21
```
Expand Down
3 changes: 2 additions & 1 deletion stdlib/cmake/modules/AddSwiftStdlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,8 @@ function(_add_target_variant_link_flags)
# We need to add the math library, which is linked implicitly by libc++
list(APPEND result "-lm")
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
list(APPEND result "-resource-dir=${SWIFT_SDK_ANDROID_ARCH_${LFLAGS_ARCH}_PATH}/../lib64/clang/${SWIFT_ANDROID_NDK_CLANG_VERSION}")
file(GLOB RESOURCE_DIR ${SWIFT_SDK_ANDROID_ARCH_${LFLAGS_ARCH}_PATH}/../lib64/clang/*)
list(APPEND result "-resource-dir=${RESOURCE_DIR}")
endif()

# link against the custom C++ library
Expand Down