Skip to content

Build libclang_rt.builtin for wasip1-threads target separately #288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/build-matrix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
18 changes: 10 additions & 8 deletions schemes/main/build/build-target-toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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-//')
Expand All @@ -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
Expand All @@ -61,14 +62,15 @@ 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=(
"$TRIPLE_DESTDIR"
"$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"
Expand Down Expand Up @@ -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 "$@"
2 changes: 1 addition & 1 deletion schemes/main/manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"base-tag": "swift-DEVELOPMENT-SNAPSHOT-2024-04-13-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"
Expand Down
13 changes: 7 additions & 6 deletions tools/build/package-toolchain
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
))
Expand Down