From 8c825ecec3d8c1ed215d6699239b26cb3e7238ec Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Wed, 17 Apr 2024 13:22:57 +0000 Subject: [PATCH 1/5] Build libclang_rt.builtin for wasip1-threads target separately `compiler-rt/lib/builtins/atomic.c` has to be built with atomics feature enabled for wasip1-threads target. We had been sharing the same libclang_rt.builtins.a for both wasi and wasip1-threads targets, but enabling atomics feature breaks non-threaded wasi target due to unnecessary feature dependencies. https://github.com/apple/swift/pull/73077 will build libclang_rt.builtins.a separately and install wasi-sysroot under different directories for each target. --- schemes/main/build/build-target-toolchain.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/schemes/main/build/build-target-toolchain.sh b/schemes/main/build/build-target-toolchain.sh index 39658b5f..45150107 100755 --- a/schemes/main/build/build-target-toolchain.sh +++ b/schemes/main/build/build-target-toolchain.sh @@ -27,8 +27,9 @@ build_target_toolchain() { local CLANG_BIN_DIR="$2" local SWIFT_BIN_DIR="$3" local TRIPLE="$4" - local STDLIB_PRODUCT="$5" - local COMPILER_RT_OS_DIR="$6" + local SHORT_TRIPLE="$5" + local STDLIB_PRODUCT="$6" + local COMPILER_RT_OS_DIR="$7" local HOST_SUFFIX HOST_SUFFIX=$(find "$TARGET_BUILD_ROOT" -name "wasmstdlib-*" -exec basename {} \; | sed 's/wasmstdlib-//') @@ -40,7 +41,7 @@ build_target_toolchain() { rm -rf "$TRIPLE_DESTDIR/usr/lib/swift_static/clang/lib/$COMPILER_RT_OS_DIR" # XXX: Is this the right way to install compiler-rt? - cp -R "$TARGET_BUILD_ROOT/wasi-sysroot/lib/$COMPILER_RT_OS_DIR" "$TRIPLE_DESTDIR/usr/lib/swift_static/clang/lib/$COMPILER_RT_OS_DIR" + cp -R "$TARGET_BUILD_ROOT/wasi-sysroot/$SHORT_TRIPLE/lib/$COMPILER_RT_OS_DIR" "$TRIPLE_DESTDIR/usr/lib/swift_static/clang/lib/$COMPILER_RT_OS_DIR" # FIXME: Clang resource directory installation is not the best way currently. # We currently have two copies of compiler headers copied from the base toolchain in @@ -61,6 +62,7 @@ build_target_corelibs() { local CLANG_BIN_DIR="$2" local SWIFT_BIN_DIR="$3" local TRIPLE="$4" + local SHORT_TRIPLE="$5" local TRIPLE_DESTDIR="$TARGET_TOOLCHAIN_DESTDIR/$TRIPLE" local CORELIBS_ARGS=( @@ -68,7 +70,7 @@ build_target_corelibs() { "$LLVM_BIN_DIR" "$CLANG_BIN_DIR" "$SWIFT_BIN_DIR" - "$WASI_SYSROOT_PATH" + "$WASI_SYSROOT_PATH/$SHORT_TRIPLE" ) "$SCHEMES_BUILD_PATH/build-foundation.sh" "${CORELIBS_ARGS[@]}" "$TRIPLE" "$SCHEMES_BUILD_PATH/build-xctest.sh" "${CORELIBS_ARGS[@]}" "$TRIPLE" @@ -160,13 +162,13 @@ main() { "$OPTIONS_SWIFT_BIN" ) - build_target_toolchain "${BUILD_TOOLS_ARGS[@]}" "wasm32-unknown-wasi" "wasmstdlib" "wasi" - build_target_toolchain "${BUILD_TOOLS_ARGS[@]}" "wasm32-unknown-wasip1-threads" "wasmthreadsstdlib" "wasip1" + build_target_toolchain "${BUILD_TOOLS_ARGS[@]}" "wasm32-unknown-wasi" "wasm32-wasi" "wasmstdlib" "wasi" + build_target_toolchain "${BUILD_TOOLS_ARGS[@]}" "wasm32-unknown-wasip1-threads" "wasm32-wasip1-threads" "wasmthreadsstdlib" "wasip1" rsync -av "$WASI_SYSROOT_PATH/" "$PACKAGING_DIR/wasi-sysroot/" - build_target_corelibs "${BUILD_TOOLS_ARGS[@]}" "wasm32-unknown-wasi" - build_target_corelibs "${BUILD_TOOLS_ARGS[@]}" "wasm32-unknown-wasip1-threads" + build_target_corelibs "${BUILD_TOOLS_ARGS[@]}" "wasm32-unknown-wasi" "wasm32-wasi" + build_target_corelibs "${BUILD_TOOLS_ARGS[@]}" "wasm32-unknown-wasip1-threads" "wasm32-wasip1-threads" } main "$@" From e3a5627df6fd47db07a656e302c3b7b29690a81f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 23 Apr 2024 12:22:09 +0000 Subject: [PATCH 2/5] Update base tag for main to swift-DEVELOPMENT-SNAPSHOT-2024-04-22-a --- schemes/main/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schemes/main/manifest.json b/schemes/main/manifest.json index 1c0ff0d5..25f9e905 100644 --- a/schemes/main/manifest.json +++ b/schemes/main/manifest.json @@ -1,5 +1,5 @@ { - "base-tag": "swift-DEVELOPMENT-SNAPSHOT-2024-04-13-a", + "base-tag": "swift-DEVELOPMENT-SNAPSHOT-2024-04-22-a", "build-compiler": false, "icu4c": "https://github.com/swiftwasm/icu4c-wasi/releases/download/0.8.0/icu4c-wasi.tar.xz", "swift-org-download-channel": "development" From 6b15a0b3d72d464932b23d7dc36e92734c7d340c Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Tue, 23 Apr 2024 16:09:18 +0000 Subject: [PATCH 3/5] Ubuntu 18.04 is no longer supported by ci.swift.org --- .github/scripts/build-matrix.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/build-matrix.rb b/.github/scripts/build-matrix.rb index 9587b490..a27e549b 100644 --- a/.github/scripts/build-matrix.rb +++ b/.github/scripts/build-matrix.rb @@ -7,7 +7,7 @@ "agent_query": "ubuntu-20.04", "target": "ubuntu18.04_x86_64", "containers": { - "main": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-18.04", + # "main": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-18.04", # "release-5.9": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-18.04@sha256:d5d555cf48fc02f5003928a064c03b76c012fef8afbe54a1942c6bfc3d773c58", "release-5.10": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-18.04@sha256:d5d555cf48fc02f5003928a064c03b76c012fef8afbe54a1942c6bfc3d773c58" }, From 4860f492ef3e191836d06877b94ac3d04436d207 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Wed, 24 Apr 2024 12:31:54 +0000 Subject: [PATCH 4/5] Update base tag for main to swift-DEVELOPMENT-SNAPSHOT-2024-04-23-a --- schemes/main/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schemes/main/manifest.json b/schemes/main/manifest.json index 25f9e905..665ed889 100644 --- a/schemes/main/manifest.json +++ b/schemes/main/manifest.json @@ -1,5 +1,5 @@ { - "base-tag": "swift-DEVELOPMENT-SNAPSHOT-2024-04-22-a", + "base-tag": "swift-DEVELOPMENT-SNAPSHOT-2024-04-23-a", "build-compiler": false, "icu4c": "https://github.com/swiftwasm/icu4c-wasi/releases/download/0.8.0/icu4c-wasi.tar.xz", "swift-org-download-channel": "development" From fd54b0755936733c1f058d2b98ea817c900e9e82 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Thu, 25 Apr 2024 04:51:29 +0000 Subject: [PATCH 5/5] Copy wasi-sysroot from target-triple specific directory apple/swift build-script now builds wasi-sysroot for each target triple and stores them in target-triple specific directories. --- tools/build/package-toolchain | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/build/package-toolchain b/tools/build/package-toolchain index 0b8e0a1b..85dbffba 100755 --- a/tools/build/package-toolchain +++ b/tools/build/package-toolchain @@ -37,11 +37,11 @@ class SnapshotInfo: return f"{self.artifact_name}.artifactbundle.zip" -def derive_wasi_sysroot(options, packaging_dir: str) -> str: +def derive_wasi_sysroot(options, packaging_dir: str, target_triple: str) -> str: if options.download_wasi_sysroot: return os.path.join('..', 'build-sdk', 'wasi-sysroot') else: - return os.path.join(packaging_dir, 'wasi-sysroot') + return os.path.join(packaging_dir, 'wasi-sysroot', target_triple) def copy_icu_libs(build_sdk_path, dist_toolchain_path): @@ -116,7 +116,7 @@ class PackageAction(Action): os.remove(swift_driver_path) # Select wasi-sysroot - wasi_sysroot_path = derive_wasi_sysroot(self.options, packaging_dir) + wasi_sysroot_path = derive_wasi_sysroot(self.options, packaging_dir, 'wasm32-wasi') print("=====> Using wasi-sysroot from {}".format(wasi_sysroot_path)) # Now dist toolchain always has cross compiler regardless of whether @@ -439,8 +439,9 @@ def main(): os.path.dirname(__file__), '..', '..', '..', 'build', 'Packaging') toolchain_channel = derive_toolchain_channel(options.scheme) - for target_triple in [ - "wasm32-unknown-wasi", "wasm32-unknown-wasip1-threads" + for target_triple, short_triple in [ + ["wasm32-unknown-wasi", "wasm32-wasi"], + ["wasm32-unknown-wasip1-threads", "wasm32-wasip1-threads"] ]: snapshot_info = SnapshotInfo( now.year, now.month, now.day, @@ -454,7 +455,7 @@ def main(): base_toolchain_path=os.path.join(packaging_dir, 'base-snapshot'), host_toolchain_path=None, target_toolchain_path=os.path.join(packaging_dir, 'target-toolchain', target_triple), - wasi_sysroot_path=derive_wasi_sysroot(options, packaging_dir), + wasi_sysroot_path=derive_wasi_sysroot(options, packaging_dir, short_triple), swift_sdk_name=f"{snapshot_info.swift_version}-{target_triple}", target_triple=target_triple, ))