Skip to content

Commit e174127

Browse files
committed
Switch to the single-header modulemap used by glibc for Bionic and cross-compile trunk sourcekit-lsp on the CI
1 parent b50bdb3 commit e174127

File tree

5 files changed

+108
-70
lines changed

5 files changed

+108
-70
lines changed

.github/workflows/sdks.yml

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
uses: actions/cache@v2
8888
with:
8989
path: ~/swift-${{ matrix.version }}-android-${{ matrix.arch }}-*-sdk.tar.xz
90-
key: ${{ matrix.version }}-${{ steps.version.outputs.latest }}-${{ matrix.arch }}-latest-sdk
90+
key: ${{ matrix.version }}-${{ steps.version.outputs.latest }}-${{ matrix.arch }}-sdk
9191
- name: Clone
9292
uses: actions/checkout@v2
9393
with:
@@ -112,6 +112,15 @@ jobs:
112112
113113
if [ ${{ matrix.version }} = 'trunk' ]; then
114114
EXTRA_FLAGS="-b -p --install-llbuild --skip-early-swift-driver"
115+
if [ ${{ matrix.arch }} != 'armv7' ]; then
116+
EXTRA_FLAGS+=" --sourcekit-lsp"
117+
fi
118+
wget -q https://patch-diff.githubusercontent.com/raw/apple/swift/pull/35707.diff
119+
wget -q https://patch-diff.githubusercontent.com/raw/apple/swift/pull/36917.diff
120+
cd swift
121+
patch -p1 < ../35707.diff
122+
patch -p1 < ../36917.diff
123+
cd ..
115124
fi
116125
117126
./swift/utils/build-script -RA --skip-build-cmark --build-llvm=0 --android --android-ndk $ANDROID_NDK_LATEST_HOME --android-arch ${{ matrix.arch }} --android-api-level $ANDROID_API_LEVEL --android-icu-uc $SDK/usr/lib/libicuuc.so --android-icu-uc-include $SDK/usr/include --android-icu-i18n $SDK/usr/lib/libicui18n.so --android-icu-i18n-include $SDK/usr/include --android-icu-data $SDK/usr/lib/libicudata.so --build-swift-tools=0 --native-swift-tools-path=`pwd`/$SWIFT_TAG-ubuntu20.04/usr/bin --native-clang-tools-path=`pwd`/$SWIFT_TAG-ubuntu20.04/usr/bin --cross-compile-hosts=android-${{ matrix.arch }} --cross-compile-deps-path=$SDK --skip-local-build --xctest --install-swift --install-libdispatch --install-foundation --install-xctest --install-destdir=$SDK --swift-install-components='clang-resource-dir-symlink;license;stdlib;sdk-overlay' $EXTRA_FLAGS
@@ -121,20 +130,25 @@ jobs:
121130
122131
tar cJf ~/$SDK_NAME.tar.xz $SDK_NAME
123132
rm -rf $SDK_NAME
124-
- name: Patch SPM ${{ matrix.version }} config
133+
- name: Unpack ${{ matrix.version }} toolchain and SDK
134+
id: sdk-unpack
125135
run: |
126136
cd sdk-config
127137
128138
if [ ! -d ${{ steps.version.outputs.tag }}-ubuntu20.04 ]; then
129139
tar xf ~/${{ steps.version.outputs.tag }}-ubuntu20.04.tar.gz
130140
fi
131-
sed -i "s%/home/butta/swift-5.5.1-RELEASE%`pwd`/${{ steps.version.outputs.tag }}%" android-${{ matrix.arch }}.json
132141
133142
tar xf ~/swift-${{ matrix.version }}-android-${{ matrix.arch }}*-${ANDROID_API_LEVEL}-sdk.tar.xz
134143
SDK_NAME=$(ls | grep swift-${{ matrix.version }}.*-sdk)
135-
sed -i "s%/home/butta/swift-5.5-android-${{ matrix.arch }}-${ANDROID_API_LEVEL}-sdk%`pwd`/${SDK_NAME}%" android-${{ matrix.arch }}.json
136-
137-
sed -i "s%/home/butta/android-ndk-r23b%${ANDROID_NDK_LATEST_HOME}%" android-${{ matrix.arch }}.json
144+
if [ ${{ matrix.version }} = 'trunk' ]; then
145+
echo "::set-output name=sdk-name::$SDK_NAME/usr/swiftpm-android"
146+
else
147+
sed -i "s%/home/butta/swift-5.5.1-RELEASE%`pwd`/${{ steps.version.outputs.tag }}%" android-${{ matrix.arch }}.json
148+
sed -i "s%/home/butta/swift-5.5-android-${{ matrix.arch }}-${ANDROID_API_LEVEL}-sdk%`pwd`/${SDK_NAME}%" android-${{ matrix.arch }}.json
149+
sed -i "s%/home/butta/android-ndk-r23b%${ANDROID_NDK_LATEST_HOME}%" android-${{ matrix.arch }}.json
150+
echo "::set-output name=sdk-name::android"
151+
fi
138152
- name: Get Swift Argument Parser package
139153
uses: actions/checkout@v2
140154
with:
@@ -143,7 +157,7 @@ jobs:
143157
- name: Build Swift Argument Parser package
144158
run: |
145159
cd swift-argument-parser
146-
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu20.04/usr/bin/swift build --build-tests --enable-test-discovery --destination ../sdk-config/android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
160+
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu20.04/usr/bin/swift build --build-tests --enable-test-discovery --destination ../sdk-config/${{ steps.sdk-unpack.outputs.sdk-name }}-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
147161
- name: Get Swift crypto package
148162
uses: actions/checkout@v2
149163
with:
@@ -153,7 +167,7 @@ jobs:
153167
run: |
154168
cd swift-crypto
155169
sed -i "s%\\\\(testsDirectory)/.*Vectors%/data/local/tmp/pack/crypto-vectors%" Tests/CryptoTests/Utils/RFCVector.swift Tests/CryptoTests/Utils/Wycheproof.swift Tests/_CryptoExtrasTests/Utils/Wycheproof.swift
156-
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu20.04/usr/bin/swift build --build-tests --enable-test-discovery --destination ../sdk-config/android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
170+
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu20.04/usr/bin/swift build --build-tests --enable-test-discovery --destination ../sdk-config/${{ steps.sdk-unpack.outputs.sdk-name }}-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
157171
- name: Get Swift NIO package
158172
uses: actions/checkout@v2
159173
with:
@@ -163,7 +177,10 @@ jobs:
163177
run: |
164178
cd swift-nio
165179
git apply ../sdk-config/package-patches/swift-nio-change-tmp-and-disable-tests.patch
166-
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu20.04/usr/bin/swift build --build-tests --destination ../sdk-config/android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
180+
if [ ${{ matrix.version }} = 'trunk' ]; then
181+
git apply ../sdk-config/package-patches/swift-nio-trunk.patch
182+
fi
183+
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu20.04/usr/bin/swift build --build-tests --destination ../sdk-config/${{ steps.sdk-unpack.outputs.sdk-name }}-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
167184
- name: Get Swift Numerics package
168185
uses: actions/checkout@v2
169186
with:
@@ -172,7 +189,7 @@ jobs:
172189
- name: Build Swift Numerics package
173190
run: |
174191
cd sn
175-
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu20.04/usr/bin/swift build --build-tests --enable-test-discovery --destination ../sdk-config/android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android -Xlinker -lm
192+
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu20.04/usr/bin/swift build --build-tests --enable-test-discovery --destination ../sdk-config/${{ steps.sdk-unpack.outputs.sdk-name }}-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
176193
- name: Get Swift System package
177194
uses: actions/checkout@v2
178195
with:
@@ -182,7 +199,7 @@ jobs:
182199
run: |
183200
cd ss
184201
sed -i "s%/tmp%/data/local/tmp%" Tests/SystemTests/FileOperationsTest.swift
185-
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu20.04/usr/bin/swift build --build-tests --destination ../sdk-config/android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
202+
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu20.04/usr/bin/swift build --build-tests --destination ../sdk-config/${{ steps.sdk-unpack.outputs.sdk-name }}-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
186203
- name: Get Swift Collections package
187204
uses: actions/checkout@v2
188205
with:
@@ -191,7 +208,7 @@ jobs:
191208
- name: Build Swift Collections package
192209
run: |
193210
cd sco
194-
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu20.04/usr/bin/swift build -j 1 --build-tests --destination ../sdk-config/android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
211+
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu20.04/usr/bin/swift build -j 1 --build-tests --destination ../sdk-config/${{ steps.sdk-unpack.outputs.sdk-name }}-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
195212
- name: Get Swift NIO SSH package
196213
uses: actions/checkout@v2
197214
with:
@@ -202,7 +219,7 @@ jobs:
202219
cd sns
203220
sed -i "s%url: .*swift-\(\w\+\)\.git.*$%path: \"../swift-\1\"),%g" Package.swift
204221
git apply ../sdk-config/package-patches/swift-nio-ssh-package-deps.patch
205-
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu20.04/usr/bin/swift build --build-tests --enable-test-discovery --destination ../sdk-config/android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
222+
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu20.04/usr/bin/swift build --build-tests --enable-test-discovery --destination ../sdk-config/${{ steps.sdk-unpack.outputs.sdk-name }}-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
206223
- name: Get Swift NIO SSL package
207224
uses: actions/checkout@v2
208225
with:
@@ -212,7 +229,7 @@ jobs:
212229
run: |
213230
cd snl
214231
sed -i "s%url: .*$%path: \"../swift-nio\"),%" Package.swift
215-
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu20.04/usr/bin/swift build --build-tests --destination ../sdk-config/android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
232+
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu20.04/usr/bin/swift build --build-tests --destination ../sdk-config/${{ steps.sdk-unpack.outputs.sdk-name }}-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
216233
- name: Get Yams package
217234
uses: actions/checkout@v2
218235
with:
@@ -222,7 +239,7 @@ jobs:
222239
run: |
223240
cd yams
224241
sed -i "s% fixturesDirectory + \"/SourceKitten#289% \"/data/local/tmp/pack%" Tests/YamsTests/PerformanceTests.swift
225-
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu20.04/usr/bin/swift build --build-tests --destination ../sdk-config/android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
242+
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu20.04/usr/bin/swift build --build-tests --destination ../sdk-config/${{ steps.sdk-unpack.outputs.sdk-name }}-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
226243
- name: Get Swift NIO HTTP/2 package
227244
uses: actions/checkout@v2
228245
with:
@@ -233,7 +250,7 @@ jobs:
233250
run: |
234251
cd snh
235252
sed -i "s%url: .*$%path: \"../swift-nio\")%" Package.swift
236-
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu20.04/usr/bin/swift build --build-tests --destination ../sdk-config/android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
253+
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu20.04/usr/bin/swift build --build-tests --destination ../sdk-config/${{ steps.sdk-unpack.outputs.sdk-name }}-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
237254
- name: Get Swift Algorithms package
238255
uses: actions/checkout@v2
239256
with:
@@ -243,7 +260,7 @@ jobs:
243260
run: |
244261
cd sa
245262
sed -i "s%url: .*$%path: \"../sn\"),%" Package.swift
246-
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu20.04/usr/bin/swift build --build-tests --enable-test-discovery --destination ../sdk-config/android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
263+
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu20.04/usr/bin/swift build --build-tests --enable-test-discovery --destination ../sdk-config/${{ steps.sdk-unpack.outputs.sdk-name }}-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
247264
- name: Get cached Termux debug app for NIO tests
248265
if: ${{ matrix.arch == 'x86_64' }}
249266
id: cache-termux
@@ -255,24 +272,28 @@ jobs:
255272
if: ${{ matrix.arch == 'x86_64' }}
256273
run: |
257274
mkdir -p pack/lib/swift/android
258-
cp swift-argument-parser/.build/x86_64-unknown-linux-android/debug/{math,repeat,roll,swift-argument-parserPackageTests.xctest} pack
275+
TARGET="x86_64-unknown-linux-android"
276+
if [ ${{ matrix.version }} = 'trunk' ]; then
277+
TARGET+="$ANDROID_API_LEVEL"
278+
fi
279+
cp swift-argument-parser/.build/$TARGET/debug/{math,repeat,roll,swift-argument-parserPackageTests.xctest} pack
259280
260281
wget -q https://raw.githubusercontent.com/termux/termux-elf-cleaner/master/termux-elf-cleaner.cpp
261282
wget -q https://raw.githubusercontent.com/termux/termux-elf-cleaner/master/elf.h
262283
clang -D__ANDROID_API__=$ANDROID_API_LEVEL -o termux-elf-cleaner termux-elf-cleaner.cpp
263284
264285
./termux-elf-cleaner pack/{math,repeat,roll} || true
265286
266-
cp swift-crypto/.build/x86_64-unknown-linux-android/debug/swift-cryptoPackageTests.xctest pack
267-
cp swift-nio/.build/x86_64-unknown-linux-android/debug/swift-nioPackageTests.xctest pack
268-
cp sn/.build/x86_64-unknown-linux-android/debug/swift-numericsPackageTests.xctest pack
269-
cp ss/.build/x86_64-unknown-linux-android/debug/swift-systemPackageTests.xctest pack
270-
cp sco/.build/x86_64-unknown-linux-android/debug/swift-collectionsPackageTests.xctest pack
271-
cp sns/.build/x86_64-unknown-linux-android/debug/swift-nio-sshPackageTests.xctest pack
272-
cp snl/.build/x86_64-unknown-linux-android/debug/swift-nio-sslPackageTests.xctest pack
273-
cp yams/.build/x86_64-unknown-linux-android/debug/YamsPackageTests.xctest pack
274-
cp snh/.build/x86_64-unknown-linux-android/debug/swift-nio-http2PackageTests.xctest pack
275-
cp sa/.build/x86_64-unknown-linux-android/debug/swift-algorithmsPackageTests.xctest pack
287+
cp swift-crypto/.build/$TARGET/debug/swift-cryptoPackageTests.xctest pack
288+
cp swift-nio/.build/$TARGET/debug/swift-nioPackageTests.xctest pack
289+
cp sn/.build/$TARGET/debug/swift-numericsPackageTests.xctest pack
290+
cp ss/.build/$TARGET/debug/swift-systemPackageTests.xctest pack
291+
cp sco/.build/$TARGET/debug/swift-collectionsPackageTests.xctest pack
292+
cp sns/.build/$TARGET/debug/swift-nio-sshPackageTests.xctest pack
293+
cp snl/.build/$TARGET/debug/swift-nio-sslPackageTests.xctest pack
294+
cp yams/.build/$TARGET/debug/YamsPackageTests.xctest pack
295+
cp snh/.build/$TARGET/debug/swift-nio-http2PackageTests.xctest pack
296+
cp sa/.build/$TARGET/debug/swift-algorithmsPackageTests.xctest pack
276297
277298
mkdir pack/crypto-vectors
278299
cp swift-crypto/Tests/Test\ Vectors/* swift-crypto/Tests/_CryptoExtrasVectors/* pack/crypto-vectors

get-packages-and-swift-source.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ let swiftRepos = ["llvm-project", "swift", "swift-corelibs-libdispatch",
88

99
let extraSwiftRepos = ["swift-llbuild", "swift-package-manager", "swift-driver",
1010
"swift-tools-support-core", "swift-argument-parser", "swift-crypto",
11-
"Yams"]
11+
"Yams", "indexstore-db", "sourcekit-lsp"]
1212
let renameRepos = ["swift-llbuild" : "llbuild", "swift-package-manager" : "swiftpm", "Yams" : "yams"]
1313
let repoTags = ["swift-argument-parser" : "1.0.1", "swift-crypto" : "1.1.5", "Yams" : "4.0.2"]
1414
if ProcessInfo.processInfo.environment["BUILD_SWIFT_PM"] != nil {

package-patches/swift-nio-trunk.patch

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
diff --git a/Sources/NIOCore/BSDSocketAPI.swift b/Sources/NIOCore/BSDSocketAPI.swift
2+
index 777a3c25..8e7f12f0 100644
3+
--- a/Sources/NIOCore/BSDSocketAPI.swift
4+
+++ b/Sources/NIOCore/BSDSocketAPI.swift
5+
@@ -69,9 +69,9 @@ private let sysInet_pton: @convention(c) (CInt, UnsafePointer<CChar>?, UnsafeMut
6+
7+
// Work around SO_TIMESTAMP/SO_RCVTIMEO being awkwardly defined in glibc.
8+
#if os(Android)
9+
-let IFF_BROADCAST: CUnsignedInt = numericCast(CNIOLinux.IFF_BROADCAST.rawValue)
10+
-let IFF_POINTOPOINT: CUnsignedInt = numericCast(CNIOLinux.IFF_POINTOPOINT.rawValue)
11+
-let IFF_MULTICAST: CUnsignedInt = numericCast(CNIOLinux.IFF_MULTICAST.rawValue)
12+
+let IFF_BROADCAST: CUnsignedInt = numericCast(IFF_BROADCAST)
13+
+let IFF_POINTOPOINT: CUnsignedInt = numericCast(IFF_POINTOPOINT)
14+
+let IFF_MULTICAST: CUnsignedInt = numericCast(IFF_MULTICAST)
15+
#if arch(arm)
16+
let SO_RCVTIMEO = SO_RCVTIMEO_OLD
17+
let SO_TIMESTAMP = SO_TIMESTAMP_OLD
18+
diff --git a/Sources/NIOPosix/System.swift b/Sources/NIOPosix/System.swift
19+
index 64d2cda7..7effa47c 100644
20+
--- a/Sources/NIOPosix/System.swift
21+
+++ b/Sources/NIOPosix/System.swift
22+
@@ -36,9 +36,9 @@ let badOS = { fatalError("unsupported OS") }()
23+
24+
#if os(Android)
25+
let INADDR_ANY = UInt32(0) // #define INADDR_ANY ((unsigned long int) 0x00000000)
26+
-let IFF_BROADCAST: CUnsignedInt = numericCast(CNIOLinux.IFF_BROADCAST.rawValue)
27+
-let IFF_POINTOPOINT: CUnsignedInt = numericCast(CNIOLinux.IFF_POINTOPOINT.rawValue)
28+
-let IFF_MULTICAST: CUnsignedInt = numericCast(CNIOLinux.IFF_MULTICAST.rawValue)
29+
+let IFF_BROADCAST: CUnsignedInt = numericCast(IFF_BROADCAST)
30+
+let IFF_POINTOPOINT: CUnsignedInt = numericCast(IFF_POINTOPOINT)
31+
+let IFF_MULTICAST: CUnsignedInt = numericCast(IFF_MULTICAST)
32+
internal typealias in_port_t = UInt16
33+
extension ipv6_mreq { // http://lkml.iu.edu/hypermail/linux/kernel/0106.1/0080.html
34+
init (ipv6mr_multiaddr: in6_addr, ipv6mr_interface: UInt32) {

swift-android-5.5.patch

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,9 @@ diff --git a/swift-corelibs-foundation/Sources/Foundation/CMakeLists.txt b/swift
110110
index 016bf294..5c42986a 100644
111111
--- a/swift-corelibs-foundation/Sources/Foundation/CMakeLists.txt
112112
+++ b/swift-corelibs-foundation/Sources/Foundation/CMakeLists.txt
113-
@@ -166,7 +166,15 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
114-
target_link_options(Foundation PRIVATE
113+
@@ -166,6 +166,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
115114
$<TARGET_OBJECTS:CoreFoundationResources>)
116115
elseif(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
117-
+ if(NOT BUILD_SHARED_LIBS)
118-
+ target_compile_options(Foundation PRIVATE "SHELL:-disallow-use-new-driver")
119-
+ endif()
120116
target_link_options(Foundation PRIVATE "SHELL:-no-toolchain-stdlib-rpath")
121117
+ if(${CMAKE_SYSTEM_NAME} STREQUAL Android)
122118
+ target_link_libraries(Foundation PRIVATE android-spawn)

0 commit comments

Comments
 (0)