Skip to content
Open
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
2 changes: 1 addition & 1 deletion swift-ci/sdks/android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ which will build the sources for each of the specified
architectures and then combines the SDKs into a single
artifactbundle with targetTriples for each of the supported
architectures (`aarch64`, `x86_64`, `aarmv7`)
and Android API levels (28-35).
and Android API levels (23-35).

## Specifying Architectures

Expand Down
12 changes: 0 additions & 12 deletions swift-ci/sdks/android/build-docker
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
TARGET_ARCHS=${TARGET_ARCHS:-aarch64,x86_64,armv7}

ANDROID_NDK_VERSION=android-ndk-r27d
ANDROID_API=28

BASEPATH=$(dirname $(realpath $0))
cd ${BASEPATH}
Expand All @@ -39,16 +38,6 @@ source ./scripts/toolchain-vars.sh
# Check-out and patch the sources
./scripts/fetch-source.sh --source-dir ${WORKDIR}/source

# This `git grep` invocation in a trunk test fails in our Docker for some
# reason, so just turn it into a plain `grep` again.
perl -pi -e 's:"git",:#:' ${WORKDIR}/source/swift-project/swift/test/Misc/verify-swift-feature-testing.test-sh

# Work around swiftlang/swift-driver#1822 for now
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

# disable backtrace() for Android (needs either API33+ or libandroid-execinfo, or to manually add in backtrace backport)
perl -pi -e 's;os\(Android\);os\(AndroidDISABLED\);g' ${WORKDIR}/source/swift-project/swift-testing/Sources/Testing/SourceAttribution/Backtrace.swift

mkdir -p ${WORKDIR}/products
chmod ugo+rwx ${WORKDIR}/products

Expand All @@ -70,6 +59,5 @@ $DOCKER run -i --rm \
--products-dir "/products" \
--host-toolchain "/usr/local/swift" \
--build-compiler "${BUILD_COMPILER}" \
--android-api "${ANDROID_API}" \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The android-api is just set in the default in build.sh; we never override it from build-docker or build-local, so I removed it so where is just a single place where we define the default.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the idea was that people using these scripts could pass in ANDROID_API and build the SDK for other API levels too.

--ndk-home "/usr/local/ndk/${ANDROID_NDK_VERSION}" \
--archs "${TARGET_ARCHS}"
11 changes: 0 additions & 11 deletions swift-ci/sdks/android/build-local
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
TARGET_ARCHS=${TARGET_ARCHS:-aarch64,x86_64,armv7}

ANDROID_NDK_VERSION=android-ndk-r27d
ANDROID_API=28

BASEPATH=$(dirname $(realpath $0))
cd ${BASEPATH}
Expand Down Expand Up @@ -61,15 +60,6 @@ fi

# Check-out and patch the sources
./scripts/fetch-source.sh --source-dir ${WORKDIR}/source
# This `git grep` invocation in a trunk test fails in our Docker for some
# reason, so just turn it into a plain `grep` again.
perl -pi -e 's:"git",:#:' ${WORKDIR}/source/swift-project/swift/test/Misc/verify-swift-feature-testing.test-sh

# Work around swiftlang/swift-driver#1822 for now
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

# disable backtrace() for Android (needs either API33+ or libandroid-execinfo, or to manually add in backtrace backport)
perl -pi -e 's;os\(Android\);os\(AndroidDISABLED\);g' ${WORKDIR}/source/swift-project/swift-testing/Sources/Testing/SourceAttribution/Backtrace.swift

mkdir -p ${WORKDIR}/products

Expand All @@ -79,6 +69,5 @@ mkdir -p ${WORKDIR}/products
--build-dir "${WORKDIR}/build" \
--build-compiler "${BUILD_COMPILER}" \
--host-toolchain "${HOST_TOOLCHAIN}" \
--android-api "${ANDROID_API}" \
--ndk-home "${ANDROID_NDK_HOME}" \
--archs "${TARGET_ARCHS}"
4 changes: 2 additions & 2 deletions swift-ci/sdks/android/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ declare_package boringssl "boringssl" "OpenSSL AND ISC AND MIT" \
android_sdk_version=0.1
sdk_name=
archs=aarch64,armv7,x86_64
android_api=28
android_api=23
build_type=Release
parallel_jobs=$(($(nproc --all) + 2))
source_dir=
Expand Down Expand Up @@ -345,12 +345,12 @@ for arch in $archs; do
-DCMAKE_TOOLCHAIN_FILE=$ndk_home/build/cmake/android.toolchain.cmake \
-DCMAKE_BUILD_TYPE=$build_type \
-DCMAKE_EXTRA_LINK_FLAGS="-rtlib=compiler-rt -unwindlib=libunwind -stdlib=libc++ -fuse-ld=lld -lc++ -lc++abi -Wl,-z,max-page-size=16384" \
-DCMAKE_BUILD_TYPE=$build_type \
-DCMAKE_INSTALL_PREFIX=$sdk_root/usr \
-DLIBXML2_WITH_PYTHON=NO \
-DLIBXML2_WITH_ICU=NO \
-DLIBXML2_WITH_ICONV=NO \
-DLIBXML2_WITH_LZMA=NO \
-DLIBXML2_WITH_TESTS=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_STATIC_LIBS=ON

Expand Down
29 changes: 29 additions & 0 deletions swift-ci/sdks/android/scripts/fetch-source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,32 @@ pushd boringssl >/dev/null 2>&1
git checkout ${BORINGSSL_VERSION}
popd >/dev/null 2>&1
groupend

groupstart "Patching Sources"
pushd swift-project >/dev/null

# This `git grep` invocation in a trunk test fails in our Docker for some
# reason, so just turn it into a plain `grep` again.
perl -pi -e 's:"git",:#:' swift/test/Misc/verify-swift-feature-testing.test-sh

# Work around swiftlang/swift-driver#1822 for now
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

# fix optional result value in backtrace() call
perl -pi -e 's;.init\(clamping: addresses.count\)\)\);.init\(clamping: addresses.count\)\) ?? 0\);g' swift-testing/Sources/Testing/SourceAttribution/Backtrace.swift
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did this cause a problem? We're building fine everywhere without it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got an error when I initially tried it without the optional guard. Regardless, this whole line is being patched out anyway, so it could likely just be removed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's unusual, as both the official and my CI build fine without this patch.


# 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)
perl -pi -e 's;os\(Android\);os\(AndroidDISABLED\);g' swift-testing/Sources/Testing/SourceAttribution/Backtrace.swift


# Disable posix_spawnattr_* calls for Android API 23
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
perl -pi -e 's;try _throwIfPosixError\(posix_spawnattr_setflags;//try _throwIfPosixError\(posix_spawnattr_setflags;g' swift-corelibs-foundation/Sources/Foundation/Process.swift
perl -pi -e 's;posix_spawnattr_destroy;//posix_spawnattr_destroy;g' swift-corelibs-foundation/Sources/Foundation/Process.swift
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should stub this out, as it will then change this behavior and fail the associated test when we start running them, even on API 28 and above where it works. Instead, if somebody wants to push this bundle back to API 23, they should add polyfills for these methods too, as there already are for most of the posix_spawn APIs in swift-corelibs-foundation.


# Stub out getgrgid_r and getgrnam_r missing from Android API 23
perl -pi -e 's;getgrgid_r|getgrnam_r;{ _, _, _, _, _ in 0 };g' swift-foundation/Sources/FoundationEssentials/Platform.swift

popd >/dev/null 2>&1
groupend

4 changes: 2 additions & 2 deletions swift-ci/sdks/android/scripts/toolchain-vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ elif [[ $SWIFT_VERSION == scheme:* ]]; then
echo "Building $SWIFT_VERSION with prebuilt Swift $RELEASE_TAG compiler"
BUILD_COMPILER=yes
echo "Branch scheme builds always build the Swift compiler from source and take much longer."
else
echo "Invalid Swift version=${SWIFT_VERSION}"
else
echo "Invalid SWIFT_VERSION: $SWIFT_VERSION"
exit 1
fi

Expand Down
Loading