Skip to content

[5.7][android] Update to LTS NDK 25b (#60938) #61297

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

Closed
wants to merge 1 commit into from
Closed
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 @@ -315,8 +315,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.8" 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
10 changes: 5 additions & 5 deletions docs/Android.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ To follow along with this guide, you'll need:
Ubuntu 18.04 or Ubuntu 16.04. Before attempting to build for Android,
please make sure you are able to build for Linux by following the
instructions in the Swift project README.
2. The latest version of the Android NDK (r23b 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/index.html.
3. An Android device with remote debugging enabled or the emulator. We require
Expand All @@ -49,7 +49,7 @@ Enter your Swift directory, then run the build script, passing the path to the
Android NDK:

```
$ NDK_PATH=path/to/android-ndk-r23b
$ NDK_PATH=path/to/android-ndk-r25b
$ utils/build-script \
-R \ # Build in ReleaseAssert mode.
--android \ # Build for Android.
Expand All @@ -70,7 +70,7 @@ Then use the built Swift compiler from the previous step to compile a Swift
source file, targeting Android:

```
$ NDK_PATH="path/to/android-ndk-r23b"
$ NDK_PATH="path/to/android-ndk-r25b"
$ build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swiftc \ # The Swift compiler built in the previous step
# The location of the tools used to build Android binaries
-tools-directory ${NDK_PATH}/toolchains/llvm/prebuilt/linux-x86_64/bin/ \
Expand Down Expand Up @@ -116,7 +116,7 @@ $ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswi
In addition, you'll also need to copy the Android NDK's libc++:

```
$ adb push /path/to/android-ndk-r23b/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so /data/local/tmp
$ adb push /path/to/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/arm-linux-androideabi/libc++_shared.so /data/local/tmp
```

Finally, you'll need to copy the `hello` executable you built in the
Expand Down Expand Up @@ -159,7 +159,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-r23b \ # Path to an Android NDK.
--android-ndk ~/android-ndk-r25b \ # Path to an Android NDK.
--android-arch armv7 \ # Optionally specify Android architecture, alternately aarch64
--android-api-level 21
```
3 changes: 2 additions & 1 deletion stdlib/cmake/modules/AddSwiftStdlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,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