Skip to content

Commit 723b900

Browse files
authored
Merge branch 'main' into tweak
2 parents 6777696 + 27fd504 commit 723b900

File tree

6 files changed

+34
-26
lines changed

6 files changed

+34
-26
lines changed

swift-ci/sdks/android/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ which will build the sources for each of the specified
4141
architectures and then combines the SDKs into a single
4242
artifactbundle with targetTriples for each of the supported
4343
architectures (`aarch64`, `x86_64`, `aarmv7`)
44-
and Android API levels (28-35).
44+
and Android API levels (23-35).
4545

4646
## Specifying Architectures
4747

swift-ci/sdks/android/build-docker

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,6 @@ source ./scripts/toolchain-vars.sh
3838
# Check-out and patch the sources
3939
./scripts/fetch-source.sh --source-dir ${WORKDIR}/source
4040

41-
# This `git grep` invocation in a trunk test fails in our Docker for some
42-
# reason, so just turn it into a plain `grep` again.
43-
perl -pi -e 's:"git",:#:' ${WORKDIR}/source/swift-project/swift/test/Misc/verify-swift-feature-testing.test-sh
44-
45-
# Work around swiftlang/swift-driver#1822 for now
46-
perl -pi -g -we "s#(call rm ... \".\{LIBDISPATCH_BUILD_DIR\}\"\n(\s+)fi\n)#\1\2if [[ -d \"\\\${ANDROID_NDK}\" ]]; then call ln -sf \"\\\${SWIFT_BUILD_PATH}/lib/swift\" \"\\\${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib\"; fi#" ${WORKDIR}/source/swift-project/swift/utils/build-script-impl
47-
48-
# disable backtrace() for Android (needs either API33+ or libandroid-execinfo, or to manually add in backtrace backport)
49-
perl -pi -e 's;os\(Android\);os\(AndroidDISABLED\);g' ${WORKDIR}/source/swift-project/swift-testing/Sources/Testing/SourceAttribution/Backtrace.swift
50-
5141
mkdir -p ${WORKDIR}/products
5242
chmod ugo+rwx ${WORKDIR}/products
5343

swift-ci/sdks/android/build-local

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
TARGET_ARCHS=${TARGET_ARCHS:-aarch64,x86_64,armv7}
1919

2020
ANDROID_NDK_VERSION=android-ndk-r27d
21-
ANDROID_API=28
2221

2322
BASEPATH=$(dirname $(realpath $0))
2423
cd ${BASEPATH}
@@ -61,15 +60,6 @@ fi
6160

6261
# Check-out and patch the sources
6362
./scripts/fetch-source.sh --source-dir ${WORKDIR}/source
64-
# This `git grep` invocation in a trunk test fails in our Docker for some
65-
# reason, so just turn it into a plain `grep` again.
66-
perl -pi -e 's:"git",:#:' ${WORKDIR}/source/swift-project/swift/test/Misc/verify-swift-feature-testing.test-sh
67-
68-
# Work around swiftlang/swift-driver#1822 for now
69-
perl -pi -g -we "s#(call rm ... \".\{LIBDISPATCH_BUILD_DIR\}\"\n(\s+)fi\n)#\1\2if [[ -d \"\\\${ANDROID_NDK}\" ]]; then call ln -sf \"\\\${SWIFT_BUILD_PATH}/lib/swift\" \"\\\${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib\"; fi#" ${WORKDIR}/source/swift-project/swift/utils/build-script-impl
70-
71-
# disable backtrace() for Android (needs either API33+ or libandroid-execinfo, or to manually add in backtrace backport)
72-
perl -pi -e 's;os\(Android\);os\(AndroidDISABLED\);g' ${WORKDIR}/source/swift-project/swift-testing/Sources/Testing/SourceAttribution/Backtrace.swift
7363

7464
mkdir -p ${WORKDIR}/products
7565

@@ -79,6 +69,5 @@ mkdir -p ${WORKDIR}/products
7969
--build-dir "${WORKDIR}/build" \
8070
--build-compiler "${BUILD_COMPILER}" \
8171
--host-toolchain "${HOST_TOOLCHAIN}" \
82-
--android-api "${ANDROID_API}" \
8372
--ndk-home "${ANDROID_NDK_HOME}" \
8473
--archs "${TARGET_ARCHS}"

swift-ci/sdks/android/scripts/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ declare_package boringssl "boringssl" "OpenSSL AND ISC AND MIT" \
128128
android_sdk_version=0.1
129129
sdk_name=
130130
archs=aarch64,armv7,x86_64
131-
android_api=28
131+
android_api=23
132132
build_type=Release
133133
parallel_jobs=$(($(nproc --all) + 2))
134134
source_dir=
@@ -345,12 +345,12 @@ for arch in $archs; do
345345
-DCMAKE_TOOLCHAIN_FILE=$ndk_home/build/cmake/android.toolchain.cmake \
346346
-DCMAKE_BUILD_TYPE=$build_type \
347347
-DCMAKE_EXTRA_LINK_FLAGS="-rtlib=compiler-rt -unwindlib=libunwind -stdlib=libc++ -fuse-ld=lld -lc++ -lc++abi -Wl,-z,max-page-size=16384" \
348-
-DCMAKE_BUILD_TYPE=$build_type \
349348
-DCMAKE_INSTALL_PREFIX=$sdk_root/usr \
350349
-DLIBXML2_WITH_PYTHON=NO \
351350
-DLIBXML2_WITH_ICU=NO \
352351
-DLIBXML2_WITH_ICONV=NO \
353352
-DLIBXML2_WITH_LZMA=NO \
353+
-DLIBXML2_WITH_TESTS=OFF \
354354
-DBUILD_SHARED_LIBS=OFF \
355355
-DBUILD_STATIC_LIBS=ON
356356

swift-ci/sdks/android/scripts/fetch-source.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,32 @@ pushd boringssl >/dev/null 2>&1
161161
git checkout ${BORINGSSL_VERSION}
162162
popd >/dev/null 2>&1
163163
groupend
164+
165+
groupstart "Patching Sources"
166+
pushd swift-project >/dev/null
167+
168+
# This `git grep` invocation in a trunk test fails in our Docker for some
169+
# reason, so just turn it into a plain `grep` again.
170+
perl -pi -e 's:"git",:#:' swift/test/Misc/verify-swift-feature-testing.test-sh
171+
172+
# Work around swiftlang/swift-driver#1822 for now
173+
perl -pi -g -we "s#(call rm ... \".\{LIBDISPATCH_BUILD_DIR\}\"\n(\s+)fi\n)#\1\2if [[ -d \"\\\${ANDROID_NDK}\" ]]; then call ln -sf \"\\\${SWIFT_BUILD_PATH}/lib/swift\" \"\\\${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib\"; fi#" swift/utils/build-script-impl
174+
175+
# fix optional result value in backtrace() call
176+
perl -pi -e 's;.init\(clamping: addresses.count\)\)\);.init\(clamping: addresses.count\)\) ?? 0\);g' swift-testing/Sources/Testing/SourceAttribution/Backtrace.swift
177+
178+
# disable backtrace() for Android (needs either API33+ or libandroid-execinfo, or to manually add in backtrace backport); will be fixed post 6.2 (in which case only the above patch is needed)
179+
perl -pi -e 's;os\(Android\);os\(AndroidDISABLED\);g' swift-testing/Sources/Testing/SourceAttribution/Backtrace.swift
180+
181+
182+
# Disable posix_spawnattr_* calls for Android API 23
183+
perl -pi -e 's;try _throwIfPosixError\(posix_spawnattr_init;throw NSError\(domain: NSPOSIXErrorDomain, code: .init\(ENOEXEC\), userInfo: [ NSLocalizedFailureReasonErrorKey: "Process unavailable on Android" ]\) //try _throwIfPosixError\(posix_spawnattr_init;g' swift-corelibs-foundation/Sources/Foundation/Process.swift
184+
perl -pi -e 's;try _throwIfPosixError\(posix_spawnattr_setflags;//try _throwIfPosixError\(posix_spawnattr_setflags;g' swift-corelibs-foundation/Sources/Foundation/Process.swift
185+
perl -pi -e 's;posix_spawnattr_destroy;//posix_spawnattr_destroy;g' swift-corelibs-foundation/Sources/Foundation/Process.swift
186+
187+
# Stub out getgrgid_r and getgrnam_r missing from Android API 23
188+
perl -pi -e 's;getgrgid_r|getgrnam_r;{ _, _, _, _, _ in 0 };g' swift-foundation/Sources/FoundationEssentials/Platform.swift
189+
190+
popd >/dev/null 2>&1
191+
groupend
192+

swift-ci/sdks/android/scripts/toolchain-vars.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ elif [[ $SWIFT_VERSION == scheme:* ]]; then
4949
echo "Building $SWIFT_VERSION with prebuilt Swift $RELEASE_TAG compiler"
5050
BUILD_COMPILER=yes
5151
echo "Branch scheme builds always build the Swift compiler from source and take much longer."
52-
else
53-
echo "Invalid Swift version=${SWIFT_VERSION}"
52+
else
53+
echo "Invalid SWIFT_VERSION: $SWIFT_VERSION"
5454
exit 1
5555
fi
5656

0 commit comments

Comments
 (0)