Skip to content

Commit c5979b4

Browse files
committed
Don't copy any libraries from the NDK: link the NDK's clang resource directory in the post-install script instead
1 parent 71f5fe9 commit c5979b4

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

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

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ cp -a $ndk_home $ndk_home_tmp
233233
ndk_home=$ndk_home_tmp
234234

235235
ndk_installation=$ndk_home/toolchains/llvm/prebuilt/$HOST
236+
ndk_clang_version=18
236237

237238
# ANDROID_NDK env needed by the swift-android.patch for:
238239
# call ln -sf "${SWIFT_BUILD_PATH}/lib/swift" "${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib"
@@ -521,10 +522,6 @@ cat > $swift_res_root/SDKSettings.json <<EOF
521522
}
522523
EOF
523524

524-
# Copy necessary headers and libraries from the toolchain and NDK clang resource directories
525-
mkdir -p $swift_res_root/usr/lib/swift/clang/lib
526-
cp -r $host_toolchain/lib/clang/*/include $swift_res_root/usr/lib/swift/clang
527-
528525
for arch in $archs; do
529526
quiet_pushd ${sdk_staging}/${arch}/usr
530527
rm -rf bin lib/clang local
@@ -546,14 +543,6 @@ for arch in $archs; do
546543
mv lib/lib*.a lib/swift_static-$arch/android
547544

548545
ln -sv ../swift/clang lib/swift_static-$arch/clang
549-
550-
# copy the clang libraries that we need to build for each architecture
551-
aarch=${arch/armv7/arm}
552-
mkdir -p lib/swift/clang/lib/linux/${aarch}
553-
554-
# match clang version 21, 22, etc.
555-
cp -av ${ndk_installation}/lib/clang/[0-9]*/lib/linux/libclang_rt.builtins-${aarch}-android.a lib/swift/clang/lib/linux/
556-
cp -av ${ndk_installation}/lib/clang/[0-9]*/lib/linux/${aarch}/libunwind.a lib/swift/clang/lib/linux/${aarch}/
557546
quiet_popd
558547

559548
# now sync the massaged sdk_root into the swift_res_root
@@ -562,6 +551,9 @@ done
562551

563552
rm -rf ${swift_res_root}/usr/share/{aclocal,doc,man}
564553
rm -r ${sdk_staging}
554+
# Link the local NDK's clang resource directory as a place-holder
555+
mkdir -p $swift_res_root/usr/lib/swift
556+
ln -s $ndk_installation/lib/clang/$ndk_clang_version $swift_res_root/usr/lib/swift/clang
565557

566558
# create an install script to set up the NDK links
567559
#ANDROID_NDK_HOME="/opt/homebrew/share/android-ndk"
@@ -618,6 +610,9 @@ else
618610
cp -a ${ndk_prebuilt}/*/sysroot ${ndk_sysroot}
619611
fi
620612
613+
# link the NDK's clang resource directory
614+
ln -sf ${ndk_prebuilt}/*/lib/clang/18 ${swift_resources}/usr/lib/swift/clang
615+
621616
# copy each architecture's swiftrt.o into the sysroot,
622617
# working around https://github.com/swiftlang/swift/pull/79621
623618
for folder in swift swift_static; do

0 commit comments

Comments
 (0)