Skip to content

Commit 0c6ff1c

Browse files
committed
[android] Update to LTS NDK 25b (#60938)
Also, remove `SWIFT_ANDROID_NDK_CLANG_VERSION` and just extract the resource directory from the NDK using `file(GLOB)`.
1 parent 4dda4af commit 0c6ff1c

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,6 @@ set(SWIFT_ANDROID_API_LEVEL "" CACHE STRING
315315

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

docs/Android.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ To follow along with this guide, you'll need:
3333
Ubuntu 18.04 or Ubuntu 16.04. Before attempting to build for Android,
3434
please make sure you are able to build for Linux by following the
3535
instructions in the Swift project README.
36-
2. The latest version of the Android NDK (r23b at the time of this writing),
36+
3. The latest version of the Android LTS NDK (r25b at the time of this writing),
3737
available to download here:
3838
https://developer.android.com/ndk/downloads/index.html.
3939
3. An Android device with remote debugging enabled or the emulator. We require
@@ -49,7 +49,7 @@ Enter your Swift directory, then run the build script, passing the path to the
4949
Android NDK:
5050

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

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

118118
```
119-
$ adb push /path/to/android-ndk-r23b/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so /data/local/tmp
119+
$ 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
120120
```
121121

122122
Finally, you'll need to copy the `hello` executable you built in the
@@ -159,7 +159,7 @@ $ utils/build-script \
159159
-R \ # Build in ReleaseAssert mode.
160160
-T \ # Run all tests, including on the Android device (add --host-test to only run Android tests on the linux host).
161161
--android \ # Build for Android.
162-
--android-ndk ~/android-ndk-r23b \ # Path to an Android NDK.
162+
--android-ndk ~/android-ndk-r25b \ # Path to an Android NDK.
163163
--android-arch armv7 \ # Optionally specify Android architecture, alternately aarch64
164164
--android-api-level 21
165165
```

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,8 @@ function(_add_target_variant_link_flags)
457457
# We need to add the math library, which is linked implicitly by libc++
458458
list(APPEND result "-lm")
459459
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
460-
list(APPEND result "-resource-dir=${SWIFT_SDK_ANDROID_ARCH_${LFLAGS_ARCH}_PATH}/../lib64/clang/${SWIFT_ANDROID_NDK_CLANG_VERSION}")
460+
file(GLOB RESOURCE_DIR ${SWIFT_SDK_ANDROID_ARCH_${LFLAGS_ARCH}_PATH}/../lib64/clang/*)
461+
list(APPEND result "-resource-dir=${RESOURCE_DIR}")
461462
endif()
462463

463464
# link against the custom C++ library

0 commit comments

Comments
 (0)