Skip to content

Commit 22833fb

Browse files
committed
[android] Update to LTS NDK 27c
Add a new bits/ header to the Android overlay, include runtime libraries that are auto-extracted and listed many times to the list of libraries to be de-duplicated, enable a C++ interop test that's working again, and update the doc with new libraries that need to be available to run a simple executable.
1 parent 1965f96 commit 22833fb

File tree

5 files changed

+23
-12
lines changed

5 files changed

+23
-12
lines changed

docs/Android.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ 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 latest version of the Android LTS NDK (r26d at the time of this writing),
39+
3. The latest version of the Android LTS NDK (r27c at the time of this writing),
4040
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
@@ -54,9 +54,9 @@ 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-r26d
58-
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2024-07-09-a-ubuntu22.04/usr/bin
59-
$ git checkout swift-DEVELOPMENT-SNAPSHOT-2024-07-09-a
57+
$ NDK_PATH=path/to/android-ndk-r27c
58+
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2024-11-09-a-ubuntu22.04/usr/bin
59+
$ git checkout swift-DEVELOPMENT-SNAPSHOT-2024-11-09-a
6060
$ utils/build-script \
6161
-R \ # Build in ReleaseAssert mode.
6262
--android \ # Build for Android.
@@ -83,8 +83,8 @@ 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-r26d"
87-
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2024-07-09-a-ubuntu22.04/usr/bin
86+
$ NDK_PATH="path/to/android-ndk-r27c"
87+
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2024-11-09-a-ubuntu22.04/usr/bin
8888
$ $SWIFT_PATH/swiftc \ # The prebuilt Swift compiler you downloaded
8989
# The location of the tools used to build Android binaries
9090
-tools-directory ${NDK_PATH}/toolchains/llvm/prebuilt/linux-x86_64/bin/ \
@@ -122,18 +122,20 @@ commands to copy the Swift Android stdlib:
122122

123123
```
124124
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftCore.so /data/local/tmp
125-
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftGlibc.so /data/local/tmp
125+
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftAndroid.so /data/local/tmp
126126
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftSwiftOnoneSupport.so /data/local/tmp
127127
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftRemoteMirror.so /data/local/tmp
128128
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswift_Concurrency.so /data/local/tmp
129+
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswift_RegexParser.so /data/local/tmp
130+
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswift_StringProcessing.so /data/local/tmp
129131
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libdispatch.so /data/local/tmp
130132
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libBlocksRuntime.so /data/local/tmp
131133
```
132134

133135
In addition, you'll also need to copy the Android NDK's libc++:
134136

135137
```
136-
$ adb push /path/to/android-ndk-r26d/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so /data/local/tmp
138+
$ adb push /path/to/android-ndk-r27c/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so /data/local/tmp
137139
```
138140

139141
Finally, you'll need to copy the `hello` executable you built in the
@@ -176,7 +178,7 @@ $ utils/build-script \
176178
-R \ # Build in ReleaseAssert mode.
177179
-T \ # Run all tests, including on the Android device (add --host-test to only run Android tests on the Linux host).
178180
--android \ # Build for Android.
179-
--android-ndk ~/android-ndk-r26d \ # Path to an Android NDK.
181+
--android-ndk ~/android-ndk-r27c \ # Path to an Android NDK.
180182
--android-arch aarch64 \ # Optionally specify Android architecture, alternately armv7 or x86_64
181183
--android-api-level 21
182184
```

lib/DriverTool/autolink_extract_main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,11 @@ int autolink_extract_main(ArrayRef<const char *> Args, const char *Argv0,
231231
"-lswiftRegexBuilder",
232232
"-lswift_RegexParser",
233233
"-lswift_Backtracing",
234+
"-lswift_Builtin_float",
235+
"-lswift_math",
234236
"-lswiftSynchronization",
235237
"-lswiftGlibc",
238+
"-lswiftAndroid",
236239
"-lBlocksRuntime",
237240
// Dispatch-specific Swift runtime libs
238241
"-ldispatch",

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ function(_add_target_variant_link_flags)
557557
if(NOT CMAKE_HOST_SYSTEM MATCHES Windows)
558558
# The Android resource dir is specified from build.ps1 on windows.
559559
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
560-
if("${SWIFT_ANDROID_NDK_PATH}" MATCHES "r26")
560+
if("${SWIFT_ANDROID_NDK_PATH}" MATCHES "r26|r27")
561561
file(GLOB RESOURCE_DIR ${SWIFT_SDK_ANDROID_ARCH_${LFLAGS_ARCH}_PATH}/../lib/clang/*)
562562
else()
563563
file(GLOB RESOURCE_DIR ${SWIFT_SDK_ANDROID_ARCH_${LFLAGS_ARCH}_PATH}/../lib64/clang/*)

stdlib/public/Platform/android.modulemap

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,14 @@ module _bits_sa_family_t [system] {
556556
header "bits/sa_family_t.h"
557557
export *
558558
}
559+
560+
module _bits_sockaddr_storage [system] {
561+
// Note: this module is not part of 'sys_socket'
562+
// to prevent a circular modular dependency
563+
header "bits/sockaddr_storage.h"
564+
export *
565+
}
566+
559567
module _bits_stdatomic [system] {
560568
// Note: this module is not part of 'stdatomic'
561569
// as it depends on libc++ and forcing it to

test/Interop/CxxToSwiftToCxx/bridge-cxx-struct-back-to-cxx.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
// RUN: %target-interop-build-clangxx -fsyntax-only -x c++-header %t/full-cxx-swift-cxx-bridging.h -std=gnu++17 -c -fmodules -fcxx-modules -I %t
2222
// FIXME: test c++20 (rdar://117419434)
2323

24-
// XFAIL: OS=linux-android, OS=linux-androideabi
25-
2624
//--- header.h
2725

2826
struct Trivial {

0 commit comments

Comments
 (0)