Skip to content

Commit 09ef130

Browse files
committed
[android] Update to LTS NDK 26c
NDK 26 renamed the directory in which it places the Android compiler-rt from `lib64/`, and added a bunch of nullability annotations to the Bionic libc.
1 parent 52c1f50 commit 09ef130

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

docs/Android.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ To follow along with this guide, you'll need:
3636
instructions in the Swift project README.
3737
2. The latest build of the Swift compiler for your Linux distro, available at
3838
https://www.swift.org/download/ or sometimes your distro package manager.
39-
3. The last version of the Android LTS NDK (r25c, the latest LTS NDK 26 at the
40-
time of this writing doesn't work yet), available to download here:
39+
3. The latest version of the Android LTS NDK (r26c at the time of this writing),
40+
available to download here:
4141
https://developer.android.com/ndk/downloads
4242
4. An Android device with remote debugging enabled or the emulator. We require
4343
remote debugging in order to deploy built stdlib products to the device. You
@@ -54,7 +54,7 @@ and the prebuilt Swift toolchain (add --skip-early-swift-driver if you already
5454
have a Swift toolchain in your path):
5555

5656
```
57-
$ NDK_PATH=path/to/android-ndk-r25c
57+
$ NDK_PATH=path/to/android-ndk-r26c
5858
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2023-09-30-a-ubuntu20.04/usr/bin
5959
$ git checkout swift-DEVELOPMENT-SNAPSHOT-2023-09-30-a
6060
$ utils/build-script \
@@ -83,7 +83,7 @@ Then use the standalone Swift stdlib from the previous step to compile a Swift
8383
source file, targeting Android:
8484

8585
```
86-
$ NDK_PATH="path/to/android-ndk-r25c"
86+
$ NDK_PATH="path/to/android-ndk-r26c"
8787
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2023-09-30-a-ubuntu20.04/usr/bin
8888
$ $SWIFT_PATH/swiftc \ # The prebuilt Swift compiler you downloaded
8989
# The location of the tools used to build Android binaries
@@ -133,7 +133,7 @@ $ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libBlo
133133
In addition, you'll also need to copy the Android NDK's libc++:
134134

135135
```
136-
$ adb push /path/to/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so /data/local/tmp
136+
$ adb push /path/to/android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so /data/local/tmp
137137
```
138138

139139
Finally, you'll need to copy the `hello` executable you built in the
@@ -176,7 +176,7 @@ $ utils/build-script \
176176
-R \ # Build in ReleaseAssert mode.
177177
-T \ # Run all tests, including on the Android device (add --host-test to only run Android tests on the Linux host).
178178
--android \ # Build for Android.
179-
--android-ndk ~/android-ndk-r25c \ # Path to an Android NDK.
179+
--android-ndk ~/android-ndk-r26c \ # Path to an Android NDK.
180180
--android-arch aarch64 \ # Optionally specify Android architecture, alternately armv7
181181
--android-api-level 21
182182
```

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,11 @@ function(_add_target_variant_link_flags)
530530
# We need to add the math library, which is linked implicitly by libc++
531531
list(APPEND result "-lm")
532532
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
533-
file(GLOB RESOURCE_DIR ${SWIFT_SDK_ANDROID_ARCH_${LFLAGS_ARCH}_PATH}/../lib64/clang/*)
533+
if("${SWIFT_ANDROID_NDK_PATH}" MATCHES "r26")
534+
file(GLOB RESOURCE_DIR ${SWIFT_SDK_ANDROID_ARCH_${LFLAGS_ARCH}_PATH}/../lib/clang/*)
535+
else()
536+
file(GLOB RESOURCE_DIR ${SWIFT_SDK_ANDROID_ARCH_${LFLAGS_ARCH}_PATH}/../lib64/clang/*)
537+
endif()
534538
list(APPEND result "-resource-dir=${RESOURCE_DIR}")
535539
endif()
536540

stdlib/private/SwiftPrivateLibcExtras/SwiftPrivateLibcExtras.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public func _stdlib_pipe() -> (readEnd: CInt, writeEnd: CInt, error: CInt) {
132132
#elseif os(WASI)
133133
preconditionFailure("No pipes available on WebAssembly/WASI")
134134
#else
135-
return pipe(unsafeFds.baseAddress)
135+
return pipe(unsafeFds.baseAddress!)
136136
#endif
137137
}
138138
return (readEnd: fds[0], writeEnd: fds[1], error: ret)

stdlib/private/SwiftReflectionTest/SwiftReflectionTest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ internal func sendBytes() {
318318
var totalBytesWritten = 0
319319
var pointer = UnsafeMutableRawPointer(bitPattern: address)
320320
while totalBytesWritten < count {
321-
let bytesWritten = Int(fwrite(pointer, 1, Int(count), stdout))
321+
let bytesWritten = Int(fwrite(pointer!, 1, Int(count), stdout))
322322
fflush(stdout)
323323
if bytesWritten == 0 {
324324
printErrnoAndExit()

0 commit comments

Comments
 (0)