mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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.
This commit is contained in:
@@ -36,7 +36,7 @@ To follow along with this guide, you'll need:
|
|||||||
instructions in the Swift project README.
|
instructions in the Swift project README.
|
||||||
2. The latest build of the Swift compiler for your Linux distro, available at
|
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.
|
https://www.swift.org/download/ or sometimes your distro package manager.
|
||||||
3. The latest version of the Android LTS NDK (r26d at the time of this writing),
|
3. The latest version of the Android LTS NDK (r27c at the time of this writing),
|
||||||
available to download here:
|
available to download here:
|
||||||
https://developer.android.com/ndk/downloads
|
https://developer.android.com/ndk/downloads
|
||||||
4. An Android device with remote debugging enabled or the emulator. We require
|
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
|
|||||||
have a Swift toolchain in your path):
|
have a Swift toolchain in your path):
|
||||||
|
|
||||||
```
|
```
|
||||||
$ NDK_PATH=path/to/android-ndk-r26d
|
$ NDK_PATH=path/to/android-ndk-r27c
|
||||||
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2024-07-09-a-ubuntu22.04/usr/bin
|
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2024-11-09-a-ubuntu22.04/usr/bin
|
||||||
$ git checkout swift-DEVELOPMENT-SNAPSHOT-2024-07-09-a
|
$ git checkout swift-DEVELOPMENT-SNAPSHOT-2024-11-09-a
|
||||||
$ utils/build-script \
|
$ utils/build-script \
|
||||||
-R \ # Build in ReleaseAssert mode.
|
-R \ # Build in ReleaseAssert mode.
|
||||||
--android \ # Build for Android.
|
--android \ # Build for Android.
|
||||||
@@ -83,8 +83,8 @@ Then use the standalone Swift stdlib from the previous step to compile a Swift
|
|||||||
source file, targeting Android:
|
source file, targeting Android:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ NDK_PATH="path/to/android-ndk-r26d"
|
$ NDK_PATH="path/to/android-ndk-r27c"
|
||||||
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2024-07-09-a-ubuntu22.04/usr/bin
|
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2024-11-09-a-ubuntu22.04/usr/bin
|
||||||
$ $SWIFT_PATH/swiftc \ # The prebuilt Swift compiler you downloaded
|
$ $SWIFT_PATH/swiftc \ # The prebuilt Swift compiler you downloaded
|
||||||
# The location of the tools used to build Android binaries
|
# The location of the tools used to build Android binaries
|
||||||
-tools-directory ${NDK_PATH}/toolchains/llvm/prebuilt/linux-x86_64/bin/ \
|
-tools-directory ${NDK_PATH}/toolchains/llvm/prebuilt/linux-x86_64/bin/ \
|
||||||
@@ -122,10 +122,12 @@ commands to copy the Swift Android stdlib:
|
|||||||
|
|
||||||
```
|
```
|
||||||
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftCore.so /data/local/tmp
|
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftCore.so /data/local/tmp
|
||||||
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftGlibc.so /data/local/tmp
|
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftAndroid.so /data/local/tmp
|
||||||
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftSwiftOnoneSupport.so /data/local/tmp
|
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftSwiftOnoneSupport.so /data/local/tmp
|
||||||
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftRemoteMirror.so /data/local/tmp
|
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftRemoteMirror.so /data/local/tmp
|
||||||
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswift_Concurrency.so /data/local/tmp
|
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswift_Concurrency.so /data/local/tmp
|
||||||
|
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswift_RegexParser.so /data/local/tmp
|
||||||
|
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswift_StringProcessing.so /data/local/tmp
|
||||||
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libdispatch.so /data/local/tmp
|
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libdispatch.so /data/local/tmp
|
||||||
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libBlocksRuntime.so /data/local/tmp
|
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libBlocksRuntime.so /data/local/tmp
|
||||||
```
|
```
|
||||||
@@ -133,7 +135,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++:
|
In addition, you'll also need to copy the Android NDK's libc++:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ 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
|
$ 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
|
||||||
```
|
```
|
||||||
|
|
||||||
Finally, you'll need to copy the `hello` executable you built in the
|
Finally, you'll need to copy the `hello` executable you built in the
|
||||||
@@ -176,7 +178,7 @@ $ utils/build-script \
|
|||||||
-R \ # Build in ReleaseAssert mode.
|
-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).
|
-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 \ # Build for Android.
|
||||||
--android-ndk ~/android-ndk-r26d \ # Path to an Android NDK.
|
--android-ndk ~/android-ndk-r27c \ # Path to an Android NDK.
|
||||||
--android-arch aarch64 \ # Optionally specify Android architecture, alternately armv7 or x86_64
|
--android-arch aarch64 \ # Optionally specify Android architecture, alternately armv7 or x86_64
|
||||||
--android-api-level 21
|
--android-api-level 21
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -231,8 +231,11 @@ int autolink_extract_main(ArrayRef<const char *> Args, const char *Argv0,
|
|||||||
"-lswiftRegexBuilder",
|
"-lswiftRegexBuilder",
|
||||||
"-lswift_RegexParser",
|
"-lswift_RegexParser",
|
||||||
"-lswift_Backtracing",
|
"-lswift_Backtracing",
|
||||||
|
"-lswift_Builtin_float",
|
||||||
|
"-lswift_math",
|
||||||
"-lswiftSynchronization",
|
"-lswiftSynchronization",
|
||||||
"-lswiftGlibc",
|
"-lswiftGlibc",
|
||||||
|
"-lswiftAndroid",
|
||||||
"-lBlocksRuntime",
|
"-lBlocksRuntime",
|
||||||
// Dispatch-specific Swift runtime libs
|
// Dispatch-specific Swift runtime libs
|
||||||
"-ldispatch",
|
"-ldispatch",
|
||||||
|
|||||||
@@ -557,7 +557,7 @@ function(_add_target_variant_link_flags)
|
|||||||
if(NOT CMAKE_HOST_SYSTEM MATCHES Windows)
|
if(NOT CMAKE_HOST_SYSTEM MATCHES Windows)
|
||||||
# The Android resource dir is specified from build.ps1 on windows.
|
# The Android resource dir is specified from build.ps1 on windows.
|
||||||
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
|
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
|
||||||
if("${SWIFT_ANDROID_NDK_PATH}" MATCHES "r26")
|
if("${SWIFT_ANDROID_NDK_PATH}" MATCHES "r26|r27")
|
||||||
file(GLOB RESOURCE_DIR ${SWIFT_SDK_ANDROID_ARCH_${LFLAGS_ARCH}_PATH}/../lib/clang/*)
|
file(GLOB RESOURCE_DIR ${SWIFT_SDK_ANDROID_ARCH_${LFLAGS_ARCH}_PATH}/../lib/clang/*)
|
||||||
else()
|
else()
|
||||||
file(GLOB RESOURCE_DIR ${SWIFT_SDK_ANDROID_ARCH_${LFLAGS_ARCH}_PATH}/../lib64/clang/*)
|
file(GLOB RESOURCE_DIR ${SWIFT_SDK_ANDROID_ARCH_${LFLAGS_ARCH}_PATH}/../lib64/clang/*)
|
||||||
|
|||||||
@@ -556,6 +556,14 @@ module _bits_sa_family_t [system] {
|
|||||||
header "bits/sa_family_t.h"
|
header "bits/sa_family_t.h"
|
||||||
export *
|
export *
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module _bits_sockaddr_storage [system] {
|
||||||
|
// Note: this module is not part of 'sys_socket'
|
||||||
|
// to prevent a circular modular dependency
|
||||||
|
header "bits/sockaddr_storage.h"
|
||||||
|
export *
|
||||||
|
}
|
||||||
|
|
||||||
module _bits_stdatomic [system] {
|
module _bits_stdatomic [system] {
|
||||||
// Note: this module is not part of 'stdatomic'
|
// Note: this module is not part of 'stdatomic'
|
||||||
// as it depends on libc++ and forcing it to
|
// as it depends on libc++ and forcing it to
|
||||||
|
|||||||
@@ -21,8 +21,6 @@
|
|||||||
// 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
|
// 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
|
||||||
// FIXME: test c++20 (rdar://117419434)
|
// FIXME: test c++20 (rdar://117419434)
|
||||||
|
|
||||||
// XFAIL: OS=linux-android, OS=linux-androideabi
|
|
||||||
|
|
||||||
//--- header.h
|
//--- header.h
|
||||||
|
|
||||||
struct Trivial {
|
struct Trivial {
|
||||||
|
|||||||
Reference in New Issue
Block a user