13
13
14
14
set -eu
15
15
16
- export PATH=" /bin:/usr/bin"
17
- VERSION=${VERSION:- 4.1 -RELEASE}
16
+ export PATH=" /bin:/usr/bin: $( brew --prefix ) /bin "
17
+ VERSION=${VERSION:- 5.7 -RELEASE}
18
18
if [[ -z " ${VERSION##* RELEASE* } " ]]; then
19
19
branch=swift-${VERSION%% RELEASE} release
20
20
elif [[ -z " ${VERSION## DEVELOPMENT-SNAPSHOT* } " ]]; then
26
26
function usage() {
27
27
echo >&2 " Usage: $0 TMP-DIR SWIFT-FOR-MACOS.pkg SWIFT-FOR-LINUX.tar.gz"
28
28
echo >&2
29
- echo >&2 " Example: $0 /tmp/ ~/Downloads/swift-${VERSION} -osx.pkg ~/Downloads/swift-${VERSION} -ubuntu16 .04.tar.gz"
29
+ echo >&2 " Example: $0 /tmp/ ~/Downloads/swift-${VERSION} -osx.pkg ~/Downloads/swift-${VERSION} -ubuntu22 .04.tar.gz"
30
30
echo >&2
31
31
echo >&2 " Complete example:"
32
32
echo >&2 " # Download the Swift binaries for Ubuntu and macOS"
33
- echo >&2 " curl -o ~/Downloads/swift-${VERSION} -ubuntu16 .04.tar.gz https://swift.org/builds/${branch} /ubuntu1604 /swift-${VERSION} /swift-${VERSION} -ubuntu16 .04.tar.gz"
33
+ echo >&2 " curl -o ~/Downloads/swift-${VERSION} -ubuntu22 .04.tar.gz https://swift.org/builds/${branch} /ubuntu2204 /swift-${VERSION} /swift-${VERSION} -ubuntu22 .04.tar.gz"
34
34
echo >&2 " curl -o ~/Downloads/swift-${VERSION} -osx.pkg https://swift.org/builds/${branch} /xcode/swift-${VERSION} /swift-${VERSION} -osx.pkg"
35
35
echo >&2 " # Compile the SDK and toolchain from that"
36
- echo >&2 " $0 /tmp/ ~/Downloads/swift-${VERSION} -osx.pkg ~/Downloads/swift-${VERSION} -ubuntu16 .04.tar.gz"
36
+ echo >&2 " $0 /tmp/ ~/Downloads/swift-${VERSION} -osx.pkg ~/Downloads/swift-${VERSION} -ubuntu22 .04.tar.gz"
37
37
echo >&2 " # Create a test application"
38
38
echo >&2 " mkdir my-test-app"
39
39
echo >&2 " cd my-test-app"
40
40
echo >&2 " swift package init --type=executable"
41
41
echo >&2 " # Build it for Ubuntu"
42
- echo >&2 " swift build --destination /tmp/cross-toolchain/ubuntu-xenial-destination.json"
43
-
42
+ echo >&2 " swift build --destination /tmp/cross-toolchain/ubuntu-jammy-destination.json"
44
43
}
45
44
46
45
if [[ $# -ne 3 ]]; then
@@ -112,12 +111,12 @@ test -f "$linux_swift_pkg"
112
111
# config
113
112
blocks_h_url=" https://raw.githubusercontent.com/apple/swift-corelibs-libdispatch/main/src/BlocksRuntime/Block.h"
114
113
xc_tc_name=" swift.xctoolchain"
115
- linux_sdk_name=" ubuntu-xenial .sdk"
114
+ linux_sdk_name=" ubuntu-jammy .sdk"
116
115
cross_tc_basename=" cross-toolchain"
117
- clang_package_url=" https://releases. llvm.org/6 .0.0 /clang+llvm-6 .0.0 -x86_64-apple-darwin.tar.xz"
116
+ clang_package_url=" https://github.com/ llvm/llvm-project/releases/download/llvmorg-13 .0.1 /clang+llvm-13 .0.1 -x86_64-apple-darwin.tar.xz"
118
117
ubuntu_mirror=" http://gb.archive.ubuntu.com/ubuntu"
119
- packages_file=" $ubuntu_mirror /dists/xenial /main/binary-amd64/Packages.gz"
120
- pkg_names=( libc6-dev linux-libc-dev libicu55 libgcc-5 -dev libicu-dev libc6 libgcc1 libstdc++-5 -dev libstdc++6 zlib1g-dev )
118
+ packages_file=" $ubuntu_mirror /dists/jammy /main/binary-amd64/Packages.gz"
119
+ pkg_names=( libc6-dev linux-libc-dev libicu70 libgcc-12 -dev libicu-dev libc6 libgcc-s1 libstdc++-12 -dev libstdc++6 zlib1g-dev )
121
120
pkgs=()
122
121
123
122
# url
@@ -131,7 +130,8 @@ function download_with_cache() {
131
130
local out
132
131
out=" $dest /cache/$2 "
133
132
if [[ ! -f " $out " ]]; then
134
- curl --fail -s -o " $out " " $1 "
133
+ # Download with curl, also follow redirects.
134
+ curl -L --fail -s -o " $out " " $1 "
135
135
fi
136
136
echo " $out "
137
137
}
@@ -221,7 +221,7 @@ find "$linux_sdk_name" -type l | while read -r line; do
221
221
ln -s " ${fixedlink# ./ } " " ${line# ./ } "
222
222
fi
223
223
done
224
- ln -s 5 " $linux_sdk_name /usr/lib/gcc/x86_64-linux-gnu/5.4.0 "
224
+ ln -s 5 " $linux_sdk_name /usr/lib/gcc/x86_64-linux-gnu/9 "
225
225
226
226
tmp=$( mktemp -d " $dest /tmp_pkgs_XXXXXX" )
227
227
unpack " $tmp " " $macos_swift_pkg "
244
244
# fix up glibc modulemap
245
245
fix_glibc_modulemap " $cross_tc_basename /$xc_tc_name /usr/lib/swift/linux/x86_64/glibc.modulemap"
246
246
247
- cat > " $cross_tc_basename /ubuntu-xenial -destination.json" << EOF
247
+ cat > " $cross_tc_basename /ubuntu-jammy -destination.json" << EOF
248
248
{
249
249
"version": 1,
250
250
"sdk": "$( pwd) /$cross_tc_basename /$linux_sdk_name ",
251
251
"toolchain-bin-dir": "$( pwd) /$cross_tc_basename /$xc_tc_name /usr/bin",
252
- "target": "x86_64-unknown-linux",
252
+ "target": "x86_64-unknown-linux-gnu ",
253
253
"extra-cc-flags": [
254
254
"-fPIC"
255
255
],
256
256
"extra-swiftc-flags": [
257
- "-use-ld=lld", "-tools-directory", "$( pwd) /$cross_tc_basename /$xc_tc_name /usr/bin"
257
+ "-use-ld=lld",
258
+ "-tools-directory", "$( pwd) /$cross_tc_basename /$xc_tc_name /usr/bin",
259
+ "-sdk", "$( pwd) /$cross_tc_basename /$linux_sdk_name ",
258
260
],
259
261
"extra-cpp-flags": [
260
262
"-lstdc++"
@@ -263,7 +265,7 @@ cat > "$cross_tc_basename/ubuntu-xenial-destination.json" <<EOF
263
265
EOF
264
266
265
267
echo
266
- echo " OK, your cross compilation toolchain for Ubuntu Xenial is now ready to be used"
268
+ echo " OK, your cross compilation toolchain for Ubuntu Jammy is now ready to be used"
267
269
echo " - SDK: $( pwd) /$cross_tc_basename /$linux_sdk_name "
268
270
echo " - toolchain: $( pwd) /$cross_tc_basename /$xc_tc_name "
269
- echo " - SwiftPM destination.json: $( pwd) /$cross_tc_basename /ubuntu-xenial -destination.json"
271
+ echo " - SwiftPM destination.json: $( pwd) /$cross_tc_basename /ubuntu-jammy -destination.json"
0 commit comments