Skip to content

[5.6][build] Clean up ICU detritus that is no longer used to build the stdlib #40817

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

Merged
merged 3 commits into from
Jan 13, 2022
Merged
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
17 changes: 0 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -304,23 +304,6 @@ set(SWIFT_ANDROID_NDK_CLANG_VERSION "12.0.8" CACHE STRING
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")

#
# User-configurable ICU specific options for Android, FreeBSD, Linux, Haiku, and WASI.
#

foreach(sdk ANDROID;FREEBSD;LINUX;WINDOWS;HAIKU;WASI)
foreach(arch aarch64;armv6;armv7;i686;powerpc64;powerpc64le;s390x;wasm32;x86_64)
set(SWIFT_${sdk}_${arch}_ICU_UC "" CACHE STRING
"Path to a directory containing the icuuc library for ${sdk}")
set(SWIFT_${sdk}_${arch}_ICU_UC_INCLUDE "" CACHE STRING
"Path to a directory containing headers for icuuc for ${sdk}")
set(SWIFT_${sdk}_${arch}_ICU_I18N "" CACHE STRING
"Path to a directory containing the icui18n library for ${sdk}")
set(SWIFT_${sdk}_${arch}_ICU_I18N_INCLUDE "" CACHE STRING
"Path to a directory containing headers icui18n for ${sdk}")
endforeach()
endforeach()

#
# User-configurable Darwin-specific options.
#
Expand Down
5 changes: 0 additions & 5 deletions cmake/modules/SwiftConfigureSDK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ function(_report_sdk prefix)
if(NOT prefix IN_LIST SWIFT_DARWIN_PLATFORMS)
foreach(arch ${SWIFT_SDK_${prefix}_ARCHITECTURES})
message(STATUS " ${arch} libc header path: ${SWIFT_SDK_${prefix}_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY}")
message(STATUS " ${arch} libc architecture specific header path: ${SWIFT_SDK_${prefix}_ARCH_${arch}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY}")
endforeach()
endif()

Expand Down Expand Up @@ -288,7 +287,6 @@ macro(configure_sdk_unix name architectures)
swift_android_sysroot(android_sysroot)
set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${android_sysroot}")
set(SWIFT_SDK_ANDROID_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY "${android_sysroot}/usr/include" CACHE STRING "Path to C library headers")
set(SWIFT_SDK_ANDROID_ARCH_${arch}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY "${android_sysroot}/usr/include" CACHE STRING "Path to C library architecture headers")

if("${arch}" STREQUAL "armv7")
set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE "arm-linux-androideabi")
Expand Down Expand Up @@ -320,10 +318,8 @@ macro(configure_sdk_unix name architectures)

if("${prefix}" STREQUAL "HAIKU")
set(SWIFT_SDK_HAIKU_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY "/system/develop/headers/posix" CACHE STRING "Path to C library headers")
set(SWIFT_SDK_HAIKU_ARCH_${arch}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY "/system/develop/headers" CACHE STRING "Path to C library architecture headers")
else()
set(SWIFT_SDK_${prefix}_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY "/usr/include" CACHE STRING "Path to C library headers")
set(SWIFT_SDK_${prefix}_ARCH_${arch}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY "${SWIFT_SDK_${prefix}_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY}/${CMAKE_LIBRARY_ARCHITECTURE}" CACHE STRING "Path to C library architecture headers")
endif()

if("${prefix}" STREQUAL "LINUX")
Expand Down Expand Up @@ -373,7 +369,6 @@ macro(configure_sdk_unix name architectures)
set(SWIFT_SDK_WASI_ARCH_wasm32_PATH "${SWIFT_WASI_SYSROOT_PATH}")
set(SWIFT_SDK_WASI_ARCH_wasm32_TRIPLE "wasm32-unknown-wasi")
set(SWIFT_SDK_WASI_ARCH_wasm32_LIBC_INCLUDE_DIRECTORY "${SWIFT_WASI_SYSROOT_PATH}/include")
set(SWIFT_SDK_WASI_ARCH_wasm32_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY "${SWIFT_WASI_SYSROOT_PATH}/include")
else()
message(FATAL_ERROR "unknown Unix OS: ${prefix}")
endif()
Expand Down
60 changes: 9 additions & 51 deletions docs/Android.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,51 +43,22 @@ To follow along with this guide, you'll need:

## "Hello, world" on Android

### 1. Downloading (or building) the Swift Android stdlib dependencies
### 1. Building the Swift stdlib for Android

You may have noticed that, in order to build the Swift stdlib for Linux, you
needed to `apt-get install libicu-dev icu-devtools`. Similarly, building
the Swift stdlib for Android requires the libiconv and libicu libraries.
However, you'll need versions of these libraries that work on Android devices.

The steps are as follows:

1. Ensure you have `curl`, `autoconf`, `automake`, `libtool`, and
`git` installed.
2. Clone the [SwiftAndroid/libiconv-libicu-android](https://github.com/SwiftAndroid/libiconv-libicu-android)
project. From the command-line, run the following command:
`git clone https://github.com/SwiftAndroid/libiconv-libicu-android.git`.
3. From the command-line, run `which ndk-build`. Confirm that the path to
the `ndk-build` executable in the Android NDK you downloaded is displayed.
If not, you may need to add the Android NDK directory to your `PATH`.
4. Change directories into `libiconv-libicu-android`: `cd libiconv-libicu-android`
5. Run the Swift build script: `./build-swift.sh`
6. Confirm that the various `libicuXYZswift.so` libraries are located in the
`armeabi-v7a` directory.

### 2. Building the Swift stdlib for Android

Enter your Swift directory, then run the build script, passing paths to the
Android NDK, as well as the directories that contain the `libicuucswift.so` and
`libicui18nswift.so` you downloaded or built in step one:
Enter your Swift directory, then run the build script, passing the path to the
Android NDK:

```
$ ARM_DIR=path/to/libiconv-libicu-android/armeabi-v7a
$ NDK_PATH=path/to/android-ndk-r23b
$ utils/build-script \
-R \ # Build in ReleaseAssert mode.
--android \ # Build for Android.
--android-ndk $NDK_PATH \ # Path to an Android NDK.
--android-arch armv7 \ # Optionally specify Android architecture, alternately aarch64 or x86_64
--android-api-level 21 \ # The Android API level to target. Swift only supports 21 or greater.
--android-icu-uc ${ARM_DIR}/libicuucswift.so \
--android-icu-uc-include ${ARM_DIR}/icu/source/common \
--android-icu-i18n ${ARM_DIR}/libicui18nswift.so \
--android-icu-i18n-include ${ARM_DIR}/icu/source/i18n \
--android-icu-data ${ARM_DIR}/libicudataswift.so
--android-api-level 21 # The Android API level to target. Swift only supports 21 or greater.
```

### 3. Compiling `hello.swift` to run on an Android device
### 2. Compiling `hello.swift` to run on an Android device

Create a simple Swift file named `hello.swift`:

Expand Down Expand Up @@ -121,7 +92,7 @@ This is exactly the error we want: the executable is built to run on an
Android device--it does not run on Linux. Next, let's deploy it to an Android
device in order to execute it.

### 4. Deploying the build products to the device
### 3. Deploying the build products to the device

You can use the `adb push` command to copy build products from your Linux
environment to your Android device. If you haven't already installed `adb`,
Expand All @@ -142,14 +113,6 @@ $ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswi
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftRemoteMirror.so /data/local/tmp
```

You will also need to push the icu libraries:

```
adb push /path/to/libicu-android/armeabi-v7a/libicudataswift.so /data/local/tmp
adb push /path/to/libicu-android/armeabi-v7a/libicui18nswift.so /data/local/tmp
adb push /path/to/libicu-android/armeabi-v7a/libicuucswift.so /data/local/tmp
```

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

```
Expand All @@ -162,7 +125,7 @@ previous step:
$ adb push hello /data/local/tmp
```

### 5. Running "Hello, world" on your Android device
### 4. Running "Hello, world" on your Android device

You can use the `adb shell` command to execute the `hello` executable on
the Android device:
Expand All @@ -182,7 +145,7 @@ Congratulations! You've just run your first Swift program on Android.
## Running the Swift test suite hosted on an Android device

When running the test suite, build products are automatically pushed to your
device. As in part four, you'll need to connect your Android device via USB:
device. As in part three, you'll need to connect your Android device via USB:

1. Connect your Android device to your computer via USB. Ensure that remote
debugging is enabled for that device by following the official instructions:
Expand All @@ -198,10 +161,5 @@ $ utils/build-script \
--android \ # Build for Android.
--android-ndk ~/android-ndk-r23b \ # Path to an Android NDK.
--android-arch armv7 \ # Optionally specify Android architecture, alternately aarch64
--android-ndk-version 21 \
--android-icu-uc ~/libicu-android/armeabi-v7a/libicuuc.so \
--android-icu-uc-include ~/libicu-android/armeabi-v7a/icu/source/common \
--android-icu-i18n ~/libicu-android/armeabi-v7a/libicui18n.so \
--android-icu-i18n-include ~/libicu-android/armeabi-v7a/icu/source/i18n/ \
--android-icu-data ~/libicu-android/armeabi-v7a/libicudata.so
--android-ndk-version 21
```
4 changes: 0 additions & 4 deletions docs/AndroidBuild.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ cmake -C S:\swift-build\cmake\caches\android-armv7.cmake
-DANDROID_ALTERNATE_TOOLCHAIN=S:/b/a/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr ^
-DLLVM_DIR=S:/b/a/llvm/lib/cmake/llvm ^
-DSWIFT_NATIVE_SWIFT_TOOLS_PATH=S:/b/a/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin ^
-DSWIFT_ANDROID_armv7_ICU_UC_INCLUDE=S:/b/a/Library/icu-64/usr/include/unicode ^
-DSWIFT_ANDROID_armv7_ICU_UC=S:/b/a/Library/icu-64/usr/lib/libicuuc64.so ^
-DSWIFT_ANDROID_armv7_ICU_I18N_INCLUDE=S:/b/a/Library/icu-64/usr/include ^
-DSWIFT_ANDROID_armv7_ICU_I18N=S:/b/a/Library/icu-64/usr/lib/libicuin64.so ^
S:/swift
ninja
ninja install
Expand Down
6 changes: 1 addition & 5 deletions docs/WindowsBuild.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ structure should resemble:
┕ usr/...
```

Note that only ICU is required for building the toolchain, and SQLite is only
Note that ICU is only required for building Foundation, and SQLite is only
needed for building llbuild and onwards. The ICU project provides binaries,
alternatively, see the ICU project for details on building ICU from source.

Expand Down Expand Up @@ -134,10 +134,6 @@ cmake -B "S:\b\1" ^
-D LLVM_EXTERNAL_CMARK_SOURCE_DIR=S:\cmark ^
-D LLVM_EXTERNAL_SWIFT_SOURCE_DIR=S:\swift ^
-D SWIFT_PATH_TO_LIBDISPATCH_SOURCE=S:\swift-corelibs-libdispatch ^
-D SWIFT_WINDOWS_x86_64_ICU_I18N_INCLUDE=S:\Library\icu-67\usr\include ^
-D SWIFT_WINDOWS_x86_64_ICU_I18N=S:\Library\icu-67\usr\lib\icuin67.lib ^
-D SWIFT_WINDOWS_x86_64_ICU_UC_INCLUDE=S:\Library\icu-67\usr\include ^
-D SWIFT_WINDOWS_x86_64_ICU_UC=S:\Library\icu-67\usr\lib\icuuc67.lib ^
-G Ninja ^
-S S:\llvm-project\llvm

Expand Down
7 changes: 1 addition & 6 deletions docs/WindowsCrossCompile.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,14 @@ the `build-script` invocation to achieve this. You will need to expand out the
path where `llvm-ar` and `llvm-ranlib` are built. These are needed to correctly
build the static libraries. Note that cross-compiling will require the use of
`lld`. Ensure that `lld-link.exe` is available to clang via your path.
Additionally, the ICU headers and libraries need to be provided for the build.

#### macOS

```bash
--extra-cmake-options=-DSWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER=FALSE,\
-DCMAKE_AR=<path to llvm-ar>,\
-DCMAKE_RANLIB=<path to llvm-ranlib>,\
-DSWIFT_SDKS='OSX;WINDOWS',\
-DSWIFT_WINDOWS_x86_64_ICU_I18N_INCLUDE=<path to ICU i18n includes>,\
-DSWIFT_WINDOWS_x86_64_ICU_UC_INCLUDE=<path to ICU UC includes>,\
-DSWIFT_WINDOWS_x86_64_ICU_I18N=<path to ICU i18n lib>,\
-DSWIFT_WINDOWS_x86_64_ICU_UC=<path to ICU UC lib>
-DSWIFT_SDKS='OSX;WINDOWS'
```

#### Linux
Expand Down
10 changes: 1 addition & 9 deletions stdlib/cmake/modules/AddSwiftStdlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1144,17 +1144,9 @@ function(add_swift_target_library_single target name)
target_link_libraries("${target}" INTERFACE ${SWIFTLIB_SINGLE_LINK_LIBRARIES})
endif()

# Don't add the icucore target.
set(SWIFTLIB_SINGLE_LINK_LIBRARIES_WITHOUT_ICU)
foreach(item ${SWIFTLIB_SINGLE_LINK_LIBRARIES})
if(NOT "${item}" STREQUAL "icucore")
list(APPEND SWIFTLIB_SINGLE_LINK_LIBRARIES_WITHOUT_ICU "${item}")
endif()
endforeach()

if(target_static)
_list_add_string_suffix(
"${SWIFTLIB_SINGLE_LINK_LIBRARIES_WITHOUT_ICU}"
"${SWIFTLIB_SINGLE_LINK_LIBRARIES}"
"-static"
target_static_depends)
# FIXME: should this be target_link_libraries?
Expand Down
8 changes: 2 additions & 6 deletions stdlib/public/Platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ foreach(sdk ${SWIFT_SDKS})
OUTPUT "${glibc_modulemap_out}"
FLAGS
"-DCMAKE_SDK=${sdk}"
"-DGLIBC_INCLUDE_PATH=${SWIFT_SDK_${sdk}_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY}"
"-DGLIBC_ARCH_INCLUDE_PATH=${SWIFT_SDK_${sdk}_ARCH_${arch}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY}")
"-DGLIBC_INCLUDE_PATH=${SWIFT_SDK_${sdk}_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY}")

list(APPEND glibc_modulemap_target_list ${glibc_modulemap_target})

Expand Down Expand Up @@ -185,15 +184,12 @@ foreach(sdk ${SWIFT_SDKS})

string(REPLACE "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${arch}_PATH}"
"" absolute_libc_include_path "${SWIFT_SDK_${sdk}_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY}")
string(REPLACE "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${arch}_PATH}"
"" absolute_libc_arch_include_path ${SWIFT_SDK_${sdk}_ARCH_${arch}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY})

handle_gyb_source_single(glibc_modulemap_native_target
SOURCE "${glibc_modulemap_source}"
OUTPUT "${glibc_sysroot_relative_modulemap_out}"
FLAGS "-DCMAKE_SDK=${sdk}"
"-DGLIBC_INCLUDE_PATH=${absolute_libc_include_path}"
"-DGLIBC_ARCH_INCLUDE_PATH=${absolute_libc_arch_include_path}")
"-DGLIBC_INCLUDE_PATH=${absolute_libc_include_path}")

list(APPEND glibc_modulemap_target_list ${glibc_modulemap_native_target})
set(glibc_modulemap_out ${glibc_sysroot_relative_modulemap_out})
Expand Down
8 changes: 1 addition & 7 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,7 @@ foreach(SDK ${SWIFT_SDKS})
--destination "${SWIFT_ANDROID_DEPLOY_DEVICE_PATH}"
--destination-arch "${ARCH}"
# Build products like libswiftCore.so.
"${SWIFTLIB_DIR}/android"
# These two directories may contain the same libraries,
# but upload both to device just in case. Duplicates will be
# overwritten, and uploading doesn't take very long anyway.
"${SWIFT_ANDROID_${ARCH}_ICU_UC}"
"${SWIFT_ANDROID_${ARCH}_ICU_I18N}"
"${SWIFT_ANDROID_${ARCH}_ICU_DATA}")
"${SWIFTLIB_DIR}/android")
endif()
add_custom_target("upload-stdlib${VARIANT_SUFFIX}"
${command_upload_stdlib}
Expand Down
11 changes: 0 additions & 11 deletions test/stdlib/Character.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,12 @@ var testCharacters = [
"\u{0061}\u{0300}\u{0300}\u{0300}\u{0300}", // UTF-8: 9 bytes
]

// Only run it on ObjC platforms. Supported Linux versions do not have a
// recent enough ICU
#if _runtime(_ObjC)
testCharacters += [
"\u{0061}\u{0300}\u{0300}\u{0300}\u{0300}\u{0300}", // UTF-8: 11 bytes
"\u{0061}\u{0300}\u{0300}\u{0300}\u{0300}\u{0300}\u{0300}", // UTF-8: 13 bytes
"\u{0061}\u{0300}\u{0300}\u{0300}\u{0300}\u{0300}\u{0300}\u{0300}", // UTF-8: 15 bytes
"\u{0061}\u{0300}\u{0300}\u{0300}\u{0300}\u{0300}\u{0300}\u{0300}\u{0300}", // UTF-8: 17 bytes
]
#endif

testCharacters += [
// U+00A9 COPYRIGHT SIGN
Expand All @@ -105,8 +101,6 @@ testCharacters += [
"\u{00a9}\u{0300}\u{0300}\u{0300}\u{0300}", // UTF-8: 10 bytes
]

// Only run it on recent enough versions of ICU
#if _runtime(_ObjC)
if #available(iOS 11.0, macOS 10.13, tvOS 11.0, watchOS 4.0, *) {
testCharacters += [
"\u{00a9}\u{0300}\u{0300}\u{0300}\u{0300}\u{0300}", // UTF-8: 12 bytes
Expand All @@ -117,7 +111,6 @@ if #available(iOS 11.0, macOS 10.13, tvOS 11.0, watchOS 4.0, *) {
"👩‍👩‍👦‍👦", // UTF-8: 25 bytes
]
}
#endif

func randomGraphemeCluster(_ minSize: Int, _ maxSize: Int) -> String {
let n = Int.random(in: (minSize + 1) ..< maxSize)
Expand Down Expand Up @@ -224,9 +217,6 @@ CharacterTests.test("CR-LF") {
}

CharacterTests.test("Unicode 9 grapheme breaking") {
// Only run it on ObjC platforms. Supported Linux versions do not have a
// recent enough ICU for Unicode 9 support.
#if _runtime(_ObjC)
// Check for Unicode 9 or later
guard #available(iOS 10.0, macOS 10.12, *) else { return }

Expand All @@ -241,7 +231,6 @@ CharacterTests.test("Unicode 9 grapheme breaking") {
let skinTone = "👋👋🏻👋🏼👋🏽👋🏾👋🏿"
expectEqual(6, skinTone.count)
expectEqual(skinTone.reversed().count, skinTone.count)
#endif
}

/// Test that a given `String` can be transformed into a `Character` and back
Expand Down
5 changes: 0 additions & 5 deletions test/stdlib/CharacterProperties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,7 @@ CharacterPropertiesTests.test("Casing") {

expectEqual("SS", Character("ß").uppercased())

// Some versions of ICU on Linux (62.1) have a bug producing the wrong value
// when lowercasing "ẞ". Darwin platforms never shipped this version, so
// conditionally test based on platform.
#if canImport(Darwin)
expectEqual("ß", Character("ẞ").lowercased())
#endif

expectEqual("и", Character("И").lowercased())
expectEqual("И", Character("и").uppercased())
Expand Down
48 changes: 0 additions & 48 deletions utils/android/build-toolchain

This file was deleted.

Loading