@@ -9,11 +9,11 @@ WASI_SDK_PATH=$SOURCE_PATH/wasi-sdk
9
9
case $( uname -s) in
10
10
Darwin)
11
11
OS_SUFFIX=osx
12
- PRESET_NAME=webassembly-macos-installable
12
+ PRESET_NAME=webassembly-macos
13
13
;;
14
14
Linux)
15
15
OS_SUFFIX=linux
16
- PRESET_NAME=webassembly-linux-installable
16
+ PRESET_NAME=webassembly-linux
17
17
;;
18
18
* )
19
19
echo " Unrecognised platform $( uname -s) "
@@ -35,47 +35,50 @@ BUNDLE_IDENTIFIER="swiftwasm.${YEAR}${MONTH}${DAY}"
35
35
DISPLAY_NAME_SHORT=" Swift for WebAssembly Development Snapshot"
36
36
DISPLAY_NAME=" ${DISPLAY_NAME_SHORT} ${YEAR} -${MONTH} -${DAY} "
37
37
38
- $SOURCE_PATH /swift/utils/build-script --preset=$PRESET_NAME \
38
+ HOST_TOOLCHAIN_DESTDIR=$SOURCE_PATH /host-toolchain-sdk
39
+ HOST_TOOLCHAIN_SDK=$HOST_TOOLCHAIN_DESTDIR /$TOOLCHAIN_NAME
40
+
41
+ # Build the host toolchain and SDK first.
42
+ $SOURCE_PATH /swift/utils/build-script --preset=webassembly-host \
43
+ INSTALL_DESTDIR=" $HOST_TOOLCHAIN_DESTDIR " \
44
+ TOOLCHAIN_NAME=" $TOOLCHAIN_NAME " \
45
+ C_CXX_LAUNCHER=" $( which sccache) "
46
+
47
+ # Clean up the host toolchain build directory so that the next
48
+ # `build-script` invocation doesn't pick up wrong CMake config files.
49
+ # For some reason passing `--reconfigure` to `build-script` won't do this.
50
+ rm -rf $SOURCE_PATH /build/Ninja-ReleaseAssert/swift-macosx-x86_64
51
+
52
+ # build the cross-compilled toolchain
53
+ $SOURCE_PATH /swift/utils/build-script \
54
+ --preset=$PRESET_NAME \
55
+ INSTALL_DESTDIR=" $SOURCE_PATH /install" \
39
56
SOURCE_PATH=" $SOURCE_PATH " \
40
- INSTALLABLE_PACKAGE=" $INSTALLABLE_PACKAGE " \
41
57
BUNDLE_IDENTIFIER=" ${BUNDLE_IDENTIFIER} " \
42
58
DISPLAY_NAME=" ${DISPLAY_NAME} " \
43
59
DISPLAY_NAME_SHORT=" ${DISPLAY_NAME_SHORT} " \
44
60
TOOLCHAIN_NAME=" ${TOOLCHAIN_NAME} " \
45
61
TOOLCHAIN_VERSION=" ${TOOLCHAIN_VERSION} " \
46
62
C_CXX_LAUNCHER=" $( which sccache) "
47
63
48
-
49
- NIGHTLY_TOOLCHAIN=$SOURCE_PATH /swift-nightly-toolchain
50
- if [ ! -e $NIGHTLY_TOOLCHAIN ]; then
51
- $UTILS_PATH /install-nightly-toolchain.sh
52
- fi
53
-
54
- TMP_DIR=$( mktemp -d)
55
- cd $TMP_DIR
56
- tar xfz $INSTALLABLE_PACKAGE $TOOLCHAIN_NAME
57
- cd $TMP_DIR /$TOOLCHAIN_NAME
58
-
59
- # Merge wasi-sdk and toolchain
60
- cp -r $WASI_SDK_PATH /lib/clang usr/lib
61
- cp -a $WASI_SDK_PATH /bin/{* ld,llvm-ar} usr/bin
62
- cp -r $WASI_SDK_PATH /share/wasi-sysroot usr/share
63
-
64
- # Build SwiftPM and install it into toolchain
65
- $UTILS_PATH /build-swiftpm.sh $TMP_DIR /$TOOLCHAIN_NAME
64
+ # Merge wasi-sdk and the toolchain
65
+ cp -a $WASI_SDK_PATH /lib/clang $HOST_TOOLCHAIN_SDK /usr/lib
66
+ cp -a $WASI_SDK_PATH /bin/{clang* ,* ld,llvm-ar} $HOST_TOOLCHAIN_SDK /usr/bin
67
+ cp -r $WASI_SDK_PATH /share/wasi-sysroot $HOST_TOOLCHAIN_SDK /usr/share
66
68
67
69
# Replace absolute sysroot path with relative path
68
- sed -i -e " s@\" .*/include@\" ../../../../share/wasi-sysroot/include@g" $TMP_DIR /$TOOLCHAIN_NAME /usr/lib/swift/wasi/wasm32/glibc.modulemap
70
+ sed -i -e " s@\" .*/include@\" ../../../../share/wasi-sysroot/include@g" $SOURCE_PATH /install /$TOOLCHAIN_NAME /usr/lib/swift/wasi/wasm32/glibc.modulemap
69
71
70
- # Copy nightly-toolchain's host environment stdlib into toolchain
72
+ # Copy host environment stdlib into toolchain
71
73
72
74
if [[ " $( uname) " == " Linux" ]]; then
73
- # Avoid to copy usr/lib/swift/clang because our toolchain's one is a directory
74
- # but nightly's one is symbolic link, so fail to merge them.
75
- rsync -a $NIGHTLY_TOOLCHAIN / usr/lib/ $TMP_DIR / $TOOLCHAIN_NAME /usr/lib/ --exclude ' swift/clang'
75
+ # Avoid copying usr/lib/swift/clang because our toolchain's one is a directory
76
+ # but nightly's one is symbolic link. A simple copy fails to merge them.
77
+ rsync -a $SOURCE_PATH /install/ $TOOLCHAIN_NAME / usr/lib $HOST_TOOLCHAIN_SDK /usr/lib/ --exclude ' swift/clang'
76
78
else
77
- cp -r $NIGHTLY_TOOLCHAIN /usr/lib/swift/macosx $TMP_DIR /$TOOLCHAIN_NAME /usr/lib/swift
79
+ cp -a $SOURCE_PATH /install/$TOOLCHAIN_NAME /usr/lib/swift_static $HOST_TOOLCHAIN_SDK /usr/lib/swift_static
80
+ cp -a $SOURCE_PATH /install/$TOOLCHAIN_NAME /usr/lib/swift/wasi $HOST_TOOLCHAIN_SDK /usr/lib/swift
78
81
fi
79
82
80
- cd $TMP_DIR
83
+ cd $HOST_TOOLCHAIN_DESTDIR
81
84
tar cfz $PACKAGE_ARTIFACT $TOOLCHAIN_NAME
0 commit comments