From 56de29b5bbf436b76078be0711cd8fe6f21d805f Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Sun, 2 Mar 2025 08:42:15 +0000 Subject: [PATCH] Drop 5.9 and 5.10 support from build system --- schemes/main/manifest.json | 1 - .../build/build-target-toolchain.sh | 205 -------- schemes/release-5.10/build/build-xctest.sh | 31 -- schemes/release-5.10/build/run-test.sh | 8 - schemes/release-5.10/manifest.json | 12 - ...ASILibc-module-and-its-build-support.patch | 438 ------------------ ...pport-wasi-libc.modulemap-import-wit.patch | 91 ---- ...ibc-specific-naming-in-libc-like-mod.patch | 195 -------- ...-Add-wasi-sysroot-layout-and-auto-de.patch | 53 --- ...-Add-use-static-resource-dir-by-defa.patch | 76 --- ...-IRGen-HACK-Disable-stack-protection.patch | 29 -- ...ACK-Always-forward-extra-argument-to.patch | 246 ---------- ...dd-WASI-specific-stdlib-dependencies.patch | 79 ---- ...-convention-mismatch-for-swift_deman.patch | 30 -- ...ng-convention-mismatch-for-swift_COW.patch | 32 -- ...ng-convention-mismatch-for-runtime-f.patch | 161 ------- ...-Workaround-for-the-bad-stacksave-co.patch | 32 -- ...isable-os_stdlib-tests-due-to-no-dyn.patch | 26 -- ...isable-PrintStruct.swift-test-for-un.patch | 29 -- ...-Add-pthread-stub-to-avoid-linking-e.patch | 215 --------- ...Add-SwiftWasm-compiler-vendor-suppor.patch | 78 ---- ...-follow-an-existing-symbolic-link-wh.patch | 41 -- ...ng-convention-mismatch-for-debugger-.patch | 42 -- ...t-Repair-tests-for-stdlib-only-build.patch | 41 -- .../build/build-target-toolchain.sh | 205 -------- schemes/release-5.9/build/build-xctest.sh | 31 -- schemes/release-5.9/build/run-test.sh | 8 - schemes/release-5.9/manifest.json | 12 - ...etadata-registration-for-WebAssembly.patch | 131 ------ ...Skip-building-swift-reflection-test-.patch | 44 -- ...Tweak-standalone-stdlib-build-config.patch | 44 -- ...link-wasi-emulated-mman-to-host-exec.patch | 27 -- ...ASILibc-module-and-its-build-support.patch | 438 ------------------ ...pport-wasi-libc.modulemap-import-wit.patch | 91 ---- ...ibc-specific-naming-in-libc-like-mod.patch | 195 -------- ...-Add-wasi-sysroot-layout-and-auto-de.patch | 53 --- ...-Add-use-static-resource-dir-by-defa.patch | 76 --- ...-IRGen-HACK-Disable-stack-protection.patch | 29 -- ...ACK-Always-forward-extra-argument-to.patch | 246 ---------- ...le-wasi-libc-emulations-to-build-std.patch | 42 -- ...-SWIFT_STDLIB_SINGLE_THREADED_RUNTIM.patch | 28 -- ...ing-unnecessary-targets-when-cross-c.patch | 27 -- ...dd-WASI-specific-stdlib-dependencies.patch | 105 ----- ...-Fix-build-of-StdlibUnittest-on-WASI.patch | 141 ------ ...ib-Fix-build-of-SwiftPrivate-on-WASI.patch | 37 -- ...calling-convention-mismatch-in-Async.patch | 79 ---- ...-including-stdint.h-in-wasi-libc-for.patch | 28 -- ...ng-convention-mismatch-for-debugger-.patch | 42 -- ...ll-ICU-static-libraries-under-swift_.patch | 77 --- ...static-stdlib-args.lnk-generation-fo.patch | 42 -- ...-convention-mismatch-for-swift_deman.patch | 30 -- ...ng-convention-mismatch-for-swift_COW.patch | 32 -- ...b-Add-wasi-libc-support-for-Heap.cpp.patch | 33 -- ...ng-convention-mismatch-for-runtime-f.patch | 161 ------- ...-Workaround-for-the-bad-stacksave-co.patch | 32 -- ...dd-checks-for-swift-autolink-extract.patch | 57 --- ...ize-WASI-as-a-supported-SDK-in-test-.patch | 26 -- ...ib-Test-with-swift_static-when-build.patch | 36 -- ...est-Skip-crash-tests-on-WASI-for-now.patch | 344 -------------- ...asm-test-Add-missing-WASILibc-import.patch | 25 - ...st-case-for-WebAssembly-object-file-.patch | 25 - ...isable-objc-interop-and-lldb-related.patch | 50 -- ...st-Prefer-sdk-instead-of-Xcc-sysroot.patch | 37 -- ...static-library-to-avoid-unsupported-.patch | 29 -- ...ssing-target-specific-lit-properties.patch | 33 -- ...sm-test-harness-to-propagate-environ.patch | 98 ---- ...isable-os_stdlib-tests-due-to-no-dyn.patch | 26 -- ...t-stdlib-Duration.swift-on-32bit-pla.patch | 27 -- ...bAssembly-test-case-for-FloatingPoin.patch | 24 - ...e-KeyPath-test-pointer-size-agnostic.patch | 27 -- ...isable-PrintStruct.swift-test-for-un.patch | 29 -- ...ve-static-executable-args.lnk-under-.patch | 46 -- ...C-Generalize-the-static-executable-a.patch | 75 --- ...d-static-executable-support-for-WASI.patch | 45 -- ...-Add-pthread-stub-to-avoid-linking-e.patch | 215 --------- ...upport-for-WebAssembly-in-build-scri.patch | 61 --- ...Add-SwiftWasm-compiler-vendor-suppor.patch | 78 ---- ...-follow-an-existing-symbolic-link-wh.patch | 41 -- ...signature-mismatch-of-_startTaskOnMa.patch | 27 -- ...ix-return-address-strategy-selection.patch | 37 -- ...ebAssembly-toolchain-for-WASI-target.patch | 83 ---- ...nk-entries-from-custom-section-inste.patch | 57 --- ...-runtime-signature-mismatch-for-stat.patch | 31 -- ...-default-value-for-target_run_with_l.patch | 27 -- ...th-test-pointer-size-agnostic-part-2.patch | 25 - ...t-Repair-tests-for-stdlib-only-build.patch | 41 -- ...disable_part_modules_for_cxx_interop.patch | 75 --- schemes/release-6.0/manifest.json | 1 - schemes/release-6.1/manifest.json | 1 - tools/build/build-host-toolchain.sh | 47 -- tools/build/build-toolchain.sh | 46 +- 91 files changed, 2 insertions(+), 6707 deletions(-) delete mode 100755 schemes/release-5.10/build/build-target-toolchain.sh delete mode 100755 schemes/release-5.10/build/build-xctest.sh delete mode 100755 schemes/release-5.10/build/run-test.sh delete mode 100644 schemes/release-5.10/manifest.json delete mode 100644 schemes/release-5.10/swift/0001-wasm-build-Add-WASILibc-module-and-its-build-support.patch delete mode 100644 schemes/release-5.10/swift/0002-ClangImporter-Support-wasi-libc.modulemap-import-wit.patch delete mode 100644 schemes/release-5.10/swift/0003-build-Replace-glibc-specific-naming-in-libc-like-mod.patch delete mode 100644 schemes/release-5.10/swift/0004-wasm-Driver-HACK-Add-wasi-sysroot-layout-and-auto-de.patch delete mode 100644 schemes/release-5.10/swift/0005-wasm-Driver-HACK-Add-use-static-resource-dir-by-defa.patch delete mode 100644 schemes/release-5.10/swift/0006-wasm-IRGen-HACK-Disable-stack-protection.patch delete mode 100644 schemes/release-5.10/swift/0007-wasm-SIL-IRGen-HACK-Always-forward-extra-argument-to.patch delete mode 100644 schemes/release-5.10/swift/0008-wasm-cmake-Add-WASI-specific-stdlib-dependencies.patch delete mode 100644 schemes/release-5.10/swift/0009-test-Fix-calling-convention-mismatch-for-swift_deman.patch delete mode 100644 schemes/release-5.10/swift/0010-stdlib-Fix-calling-convention-mismatch-for-swift_COW.patch delete mode 100644 schemes/release-5.10/swift/0011-stdlib-Fix-calling-convention-mismatch-for-runtime-f.patch delete mode 100644 schemes/release-5.10/swift/0012-wasm-stdlib-HACK-Workaround-for-the-bad-stacksave-co.patch delete mode 100644 schemes/release-5.10/swift/0013-wasm-test-HACK-Disable-os_stdlib-tests-due-to-no-dyn.patch delete mode 100644 schemes/release-5.10/swift/0014-wasm-test-HACK-Disable-PrintStruct.swift-test-for-un.patch delete mode 100644 schemes/release-5.10/swift/0015-wasm-stdlib-HACK-Add-pthread-stub-to-avoid-linking-e.patch delete mode 100644 schemes/release-5.10/swift/0016-wasm-build-HACK-Add-SwiftWasm-compiler-vendor-suppor.patch delete mode 100644 schemes/release-5.10/swift/0017-installer-Do-not-follow-an-existing-symbolic-link-wh.patch delete mode 100644 schemes/release-5.10/swift/0018-stdlib-Fix-calling-convention-mismatch-for-debugger-.patch delete mode 100644 schemes/release-5.10/swift/0019-lit-Repair-tests-for-stdlib-only-build.patch delete mode 100755 schemes/release-5.9/build/build-target-toolchain.sh delete mode 100755 schemes/release-5.9/build/build-xctest.sh delete mode 100755 schemes/release-5.9/build/run-test.sh delete mode 100644 schemes/release-5.9/manifest.json delete mode 100644 schemes/release-5.9/swift/0001-wasm-Add-metadata-registration-for-WebAssembly.patch delete mode 100644 schemes/release-5.9/swift/0002-wasm-cmake-HACK-Skip-building-swift-reflection-test-.patch delete mode 100644 schemes/release-5.9/swift/0003-wasm-cmake-HACK-Tweak-standalone-stdlib-build-config.patch delete mode 100644 schemes/release-5.9/swift/0004-wasm-cmake-HACK-link-wasi-emulated-mman-to-host-exec.patch delete mode 100644 schemes/release-5.9/swift/0005-wasm-build-Add-WASILibc-module-and-its-build-support.patch delete mode 100644 schemes/release-5.9/swift/0006-ClangImporter-Support-wasi-libc.modulemap-import-wit.patch delete mode 100644 schemes/release-5.9/swift/0007-build-Replace-glibc-specific-naming-in-libc-like-mod.patch delete mode 100644 schemes/release-5.9/swift/0008-wasm-Driver-HACK-Add-wasi-sysroot-layout-and-auto-de.patch delete mode 100644 schemes/release-5.9/swift/0009-wasm-Driver-HACK-Add-use-static-resource-dir-by-defa.patch delete mode 100644 schemes/release-5.9/swift/0010-wasm-IRGen-HACK-Disable-stack-protection.patch delete mode 100644 schemes/release-5.9/swift/0011-wasm-SIL-IRGen-HACK-Always-forward-extra-argument-to.patch delete mode 100644 schemes/release-5.9/swift/0012-wasm-stdlib-Enable-wasi-libc-emulations-to-build-std.patch delete mode 100644 schemes/release-5.9/swift/0013-stdlib-Propagate-SWIFT_STDLIB_SINGLE_THREADED_RUNTIM.patch delete mode 100644 schemes/release-5.9/swift/0014-test-Avoid-building-unnecessary-targets-when-cross-c.patch delete mode 100644 schemes/release-5.9/swift/0015-wasm-cmake-Add-WASI-specific-stdlib-dependencies.patch delete mode 100644 schemes/release-5.9/swift/0016-wasm-test-Fix-build-of-StdlibUnittest-on-WASI.patch delete mode 100644 schemes/release-5.9/swift/0017-wasm-stdlib-Fix-build-of-SwiftPrivate-on-WASI.patch delete mode 100644 schemes/release-5.9/swift/0018-Concurrency-Fix-calling-convention-mismatch-in-Async.patch delete mode 100644 schemes/release-5.9/swift/0019-wasm-stdlib-Stop-including-stdint.h-in-wasi-libc-for.patch delete mode 100644 schemes/release-5.9/swift/0020-stdlib-Fix-calling-convention-mismatch-for-debugger-.patch delete mode 100644 schemes/release-5.9/swift/0021-wasm-build-Install-ICU-static-libraries-under-swift_.patch delete mode 100644 schemes/release-5.9/swift/0022-wasm-stdlib-Add-static-stdlib-args.lnk-generation-fo.patch delete mode 100644 schemes/release-5.9/swift/0023-test-Fix-calling-convention-mismatch-for-swift_deman.patch delete mode 100644 schemes/release-5.9/swift/0024-stdlib-Fix-calling-convention-mismatch-for-swift_COW.patch delete mode 100644 schemes/release-5.9/swift/0025-wasm-stdlib-Add-wasi-libc-support-for-Heap.cpp.patch delete mode 100644 schemes/release-5.9/swift/0026-stdlib-Fix-calling-convention-mismatch-for-runtime-f.patch delete mode 100644 schemes/release-5.9/swift/0027-wasm-stdlib-HACK-Workaround-for-the-bad-stacksave-co.patch delete mode 100644 schemes/release-5.9/swift/0028-wasm-test-Add-checks-for-swift-autolink-extract.patch delete mode 100644 schemes/release-5.9/swift/0029-wasm-test-Recognize-WASI-as-a-supported-SDK-in-test-.patch delete mode 100644 schemes/release-5.9/swift/0030-test-static-stdlib-Test-with-swift_static-when-build.patch delete mode 100644 schemes/release-5.9/swift/0031-wasm-test-Skip-crash-tests-on-WASI-for-now.patch delete mode 100644 schemes/release-5.9/swift/0032-wasm-test-Add-missing-WASILibc-import.patch delete mode 100644 schemes/release-5.9/swift/0033-wasm-test-Add-test-case-for-WebAssembly-object-file-.patch delete mode 100644 schemes/release-5.9/swift/0034-wasm-test-HACK-Disable-objc-interop-and-lldb-related.patch delete mode 100644 schemes/release-5.9/swift/0035-wasm-test-Prefer-sdk-instead-of-Xcc-sysroot.patch delete mode 100644 schemes/release-5.9/swift/0036-wasm-test-Force-static-library-to-avoid-unsupported-.patch delete mode 100644 schemes/release-5.9/swift/0037-wasm-test-Add-missing-target-specific-lit-properties.patch delete mode 100644 schemes/release-5.9/swift/0038-wasm-test-Add-wasm-test-harness-to-propagate-environ.patch delete mode 100644 schemes/release-5.9/swift/0039-wasm-test-HACK-Disable-os_stdlib-tests-due-to-no-dyn.patch delete mode 100644 schemes/release-5.9/swift/0040-test-Disable-test-stdlib-Duration.swift-on-32bit-pla.patch delete mode 100644 schemes/release-5.9/swift/0041-wasm-test-Add-WebAssembly-test-case-for-FloatingPoin.patch delete mode 100644 schemes/release-5.9/swift/0042-test-Make-KeyPath-test-pointer-size-agnostic.patch delete mode 100644 schemes/release-5.9/swift/0043-wasm-test-HACK-Disable-PrintStruct.swift-test-for-un.patch delete mode 100644 schemes/release-5.9/swift/0044-static-stdlib-Move-static-executable-args.lnk-under-.patch delete mode 100644 schemes/release-5.9/swift/0045-static-stdlib-NFC-Generalize-the-static-executable-a.patch delete mode 100644 schemes/release-5.9/swift/0046-static-stdlib-Add-static-executable-support-for-WASI.patch delete mode 100644 schemes/release-5.9/swift/0047-wasm-stdlib-HACK-Add-pthread-stub-to-avoid-linking-e.patch delete mode 100644 schemes/release-5.9/swift/0048-wasm-build-Add-support-for-WebAssembly-in-build-scri.patch delete mode 100644 schemes/release-5.9/swift/0049-wasm-build-HACK-Add-SwiftWasm-compiler-vendor-suppor.patch delete mode 100644 schemes/release-5.9/swift/0050-installer-Do-not-follow-an-existing-symbolic-link-wh.patch delete mode 100644 schemes/release-5.9/swift/0051-Concurrency-Fix-signature-mismatch-of-_startTaskOnMa.patch delete mode 100644 schemes/release-5.9/swift/0052-wasm-stdlib-Fix-return-address-strategy-selection.patch delete mode 100644 schemes/release-5.9/swift/0053-Driver-Use-WebAssembly-toolchain-for-WASI-target.patch delete mode 100644 schemes/release-5.9/swift/0054-wasm-Read-autolink-entries-from-custom-section-inste.patch delete mode 100644 schemes/release-5.9/swift/0055-DiscardingTG-Fix-runtime-signature-mismatch-for-stat.patch delete mode 100644 schemes/release-5.9/swift/0056-test-Add-missing-default-value-for-target_run_with_l.patch delete mode 100644 schemes/release-5.9/swift/0057-test-Make-KeyPath-test-pointer-size-agnostic-part-2.patch delete mode 100644 schemes/release-5.9/swift/0058-lit-Repair-tests-for-stdlib-only-build.patch delete mode 100644 schemes/release-5.9/wasi-sysroot/disable_part_modules_for_cxx_interop.patch delete mode 100755 tools/build/build-host-toolchain.sh diff --git a/schemes/main/manifest.json b/schemes/main/manifest.json index bd7ad0a7..b163b12f 100644 --- a/schemes/main/manifest.json +++ b/schemes/main/manifest.json @@ -1,6 +1,5 @@ { "base-tag": "swift-DEVELOPMENT-SNAPSHOT-2025-02-28-a", - "build-compiler": false, "icu4c": [], "libxml2": [ "https://github.com/swiftwasm/libxml2-wasm/releases/download/2.0.0/libxml2-wasm32-unknown-wasi.tar.gz", diff --git a/schemes/release-5.10/build/build-target-toolchain.sh b/schemes/release-5.10/build/build-target-toolchain.sh deleted file mode 100755 index b71e3caf..00000000 --- a/schemes/release-5.10/build/build-target-toolchain.sh +++ /dev/null @@ -1,205 +0,0 @@ -#!/bin/bash -# -# Build the Swift standard library. - -set -euo pipefail -set -x - -print_help() { - echo "Usage: $0 [options]" - echo "" - echo "Options:" - echo " --help Display this help message." - echo " --llvm-bin Path to LLVM bin directory." - echo " --swift-bin Path to Swift bin directory." -} - -SCHEMES_BUILD_PATH="$(cd "$(dirname "$0")" && pwd)" -SOURCE_PATH="$(cd "$(dirname "$0")/../../../.." && pwd)" -TOOLS_BUILD_PATH="$(cd "$(dirname "$0")/../../../tools/build" && pwd)" -TARGET_BUILD_ROOT=$SOURCE_PATH/build/WebAssembly -PACKAGING_DIR="$SOURCE_PATH/build/Packaging" -TARGET_TOOLCHAIN_DESTDIR=$PACKAGING_DIR/target-toolchain/wasm32-unknown-wasi -BUILD_SDK_PATH="$SOURCE_PATH/build-sdk" -WASI_SYSROOT_PATH="$BUILD_SDK_PATH/wasi-sysroot" - -build_target_toolchain() { - - local LLVM_BIN_DIR="$1" - local CLANG_BIN_DIR="$2" - local SWIFT_BIN_DIR="$3" - local SCHEME="$4" - - local COMPILER_RT_BUILD_DIR="$TARGET_BUILD_ROOT/compiler-rt-wasi-wasm32" - local CLANG_VERSION - CLANG_VERSION="$(basename "$($CLANG_BIN_DIR/clang -print-resource-dir)")" - - cmake -B "$COMPILER_RT_BUILD_DIR" \ - -D CMAKE_TOOLCHAIN_FILE="$TOOLS_BUILD_PATH/compiler-rt-cache.cmake" \ - -D CMAKE_BUILD_TYPE=Release \ - -D CMAKE_C_COMPILER="$CLANG_BIN_DIR/clang" \ - -D CMAKE_CXX_COMPILER="$CLANG_BIN_DIR/clang++" \ - -D CMAKE_RANLIB="$LLVM_BIN_DIR/llvm-ranlib" \ - -D CMAKE_AR="$LLVM_BIN_DIR/llvm-ar" \ - -D CMAKE_C_COMPILER_LAUNCHER="$(which sccache)" \ - -D CMAKE_CXX_COMPILER_LAUNCHER="$(which sccache)" \ - -D CMAKE_INSTALL_PREFIX="$TARGET_TOOLCHAIN_DESTDIR/usr/lib/clang/$CLANG_VERSION/" \ - -D CMAKE_SYSROOT="${WASI_SYSROOT_PATH}" \ - -G Ninja \ - -S "$SOURCE_PATH/llvm-project/compiler-rt" - - ninja install -C "$COMPILER_RT_BUILD_DIR" - - local LLVM_TARGET_BUILD_DIR - - if [ -f "$SOURCE_PATH/build/llvm-tools/CMakeCache.txt" ]; then - LLVM_TARGET_BUILD_DIR="$SOURCE_PATH/build/llvm-tools" - else - LLVM_TARGET_BUILD_DIR="$TARGET_BUILD_ROOT/llvm-wasi-wasm32" - if [ ! -f "$LLVM_TARGET_BUILD_DIR/CMakeCache.txt" ]; then - # Only configure LLVM to use CMake functionalities in LLVM - cmake -B "$LLVM_TARGET_BUILD_DIR" \ - -D CMAKE_BUILD_TYPE=Release \ - -D LLVM_ENABLE_ZLIB=NO \ - -D LLVM_ENABLE_LIBXML2=NO \ - -D CMAKE_C_COMPILER="$CLANG_BIN_DIR/clang" \ - -D CMAKE_CXX_COMPILER="$CLANG_BIN_DIR/clang++" \ - -G Ninja \ - -S "$SOURCE_PATH/llvm-project/llvm" - fi - fi - - local SWIFT_STDLIB_BUILD_DIR="$TARGET_BUILD_ROOT/swift-stdlib-wasi-wasm32" - - # FIXME(katei): Platform/WASI is not recognized as a platform in LLVM, so it reports - # "Unable to determine platform" while handling LLVM options. - # Set WASI as a UNIX platform to spoof LLVM - # FIXME(katei): host-build clang's libcxx is capable with LLVM, but it somehow - # fails libcxx version check. So activate LLVM_COMPILER_CHECKED to spoof the checker - # SWIFT_DRIVER_TEST_OPTIONS is used to specify clang resource dir for wasm32-unknown-wasi - # because it's not built beside clang - # TODO(katei): Move SWIFT_STDLIB_HAS_ASL and SWIFT_RUNTIME_CRASH_REPORTER_CLIENT - # to cmake/caches/Runtime-WASI-wasm32.cmake - cmake -B "$SWIFT_STDLIB_BUILD_DIR" \ - -C "$SOURCE_PATH/swift/cmake/caches/Runtime-WASI-wasm32.cmake" \ - -D CMAKE_BUILD_TYPE=Release \ - -D CMAKE_C_COMPILER_LAUNCHER="$(which sccache)" \ - -D CMAKE_CXX_COMPILER_LAUNCHER="$(which sccache)" \ - -D CMAKE_C_COMPILER="$CLANG_BIN_DIR/clang" \ - -D CMAKE_CXX_COMPILER="$CLANG_BIN_DIR/clang++" \ - -D CMAKE_RANLIB="$LLVM_BIN_DIR/llvm-ranlib" \ - -D CMAKE_AR="$LLVM_BIN_DIR/llvm-ar" \ - -D CMAKE_INSTALL_PREFIX="$TARGET_TOOLCHAIN_DESTDIR/usr" \ - -D LLVM_DIR="$LLVM_TARGET_BUILD_DIR/lib/cmake/llvm/" \ - -D LLVM_COMPILER_CHECKED=YES \ - -D UNIX=1 \ - -D SWIFT_NATIVE_SWIFT_TOOLS_PATH="$SWIFT_BIN_DIR" \ - -D SWIFT_NATIVE_CLANG_TOOLS_PATH="$CLANG_BIN_DIR" \ - -D SWIFT_NATIVE_LLVM_TOOLS_PATH="$LLVM_BIN_DIR" \ - -D SWIFT_LIT_TEST_PATHS="$SWIFT_STDLIB_BUILD_DIR/test-wasi-wasm32/stdlib;$SWIFT_STDLIB_BUILD_DIR/test-wasi-wasm32/Concurrency/Runtime" \ - -D SWIFT_DRIVER_TEST_OPTIONS=" -Xclang-linker -resource-dir -Xclang-linker $COMPILER_RT_BUILD_DIR" \ - -D SWIFT_WASI_SYSROOT_PATH="$WASI_SYSROOT_PATH" \ - -D SWIFT_WASI_wasm32_ICU_UC_INCLUDE="$BUILD_SDK_PATH/icu/include" \ - -D SWIFT_WASI_wasm32_ICU_UC="$BUILD_SDK_PATH/icu/lib/libicuuc.a" \ - -D SWIFT_WASI_wasm32_ICU_I18N_INCLUDE="$BUILD_SDK_PATH/icu/include" \ - -D SWIFT_WASI_wasm32_ICU_I18N="$BUILD_SDK_PATH/icu/lib/libicui18n.a" \ - -D SWIFT_WASI_wasm32_ICU_DATA="$BUILD_SDK_PATH/icu/lib/libicudata.a" \ - -D SWIFT_ENABLE_DISPATCH=NO \ - -D SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING=YES \ - -D SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED=YES \ - -D SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING=YES \ - -D SWIFT_ENABLE_EXPERIMENTAL_REFLECTION=YES \ - -D SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP=YES \ - -D SWIFT_PRIMARY_VARIANT_SDK=WASI \ - -D SWIFT_PRIMARY_VARIANT_ARCH=wasm32 \ - -D SWIFT_SDKS:STRING=WASI \ - -D SWIFT_STDLIB_HAS_ASL=NO \ - -D SWIFT_STDLIB_TRACING=NO \ - -D SWIFT_STDLIB_CONCURRENCY_TRACING=NO \ - -D SWIFT_RUNTIME_CRASH_REPORTER_CLIENT=NO \ - -D SWIFT_STDLIB_INSTALL_PARENT_MODULE_FOR_SHIMS=NO \ - -D SWIFT_BUILD_DYNAMIC_SDK_OVERLAY=NO \ - -D SWIFT_BUILD_STATIC_SDK_OVERLAY=NO \ - -D SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE="$SOURCE_PATH/swift-syntax" \ - -D SWIFT_PATH_TO_STRING_PROCESSING_SOURCE="$SOURCE_PATH/swift-experimental-string-processing" \ - -G Ninja \ - -S "$SOURCE_PATH/swift" - - # FIXME(katei): 'sdk-overlay' is explicitly used to build libcxxshim.modulemap - # which is used only in tests, so 'ninja install' doesn't build it - # the header and modulemap custom targets should be added as dependency of install - ninja sdk-overlay install -C "$SWIFT_STDLIB_BUILD_DIR" - - # Remove host CoreFoundation module directory to avoid module conflict - # while building Foundation - rm -rf "$TARGET_TOOLCHAIN_DESTDIR/usr/lib/swift_static/CoreFoundation" - - ln -fs "../../../clang/$CLANG_VERSION/lib/wasi" "$TARGET_TOOLCHAIN_DESTDIR/usr/lib/swift/clang/lib/wasi" - ln -fs "../../../clang/$CLANG_VERSION/lib/wasi" "$TARGET_TOOLCHAIN_DESTDIR/usr/lib/swift_static/clang/lib/wasi" - - local CORELIBS_ARGS=( - "$TARGET_TOOLCHAIN_DESTDIR" - "$LLVM_BIN_DIR" - "$CLANG_BIN_DIR" - "$SWIFT_BIN_DIR" - "$WASI_SYSROOT_PATH" - ) - "$TOOLS_BUILD_PATH/build-foundation.sh" "${CORELIBS_ARGS[@]}" - "$SCHEMES_BUILD_PATH/build-xctest.sh" "${CORELIBS_ARGS[@]}" -} - -main() { - local OPTIONS_LLVM_BIN="" - local OPTIONS_CLANG_BIN="" - local OPTIONS_SWIFT_BIN="" - - while [[ $# -gt 0 ]]; do - case "$1" in - --llvm-bin) - OPTIONS_LLVM_BIN="$2" - shift 2 - ;; - --clang-bin) - OPTIONS_CLANG_BIN="$2" - shift 2 - ;; - --swift-bin) - OPTIONS_SWIFT_BIN="$2" - shift 2 - ;; - --scheme) - OPTIONS_SCHEME="$2" - shift 2 - ;; - --help) - print_help - exit 0 - ;; - *) - echo "Unknown option: $1" - print_help - exit 1 - ;; - esac - done - - if [[ -z "$OPTIONS_LLVM_BIN" ]]; then - echo "Missing --llvm-bin option" - print_help - exit 1 - fi - - if [[ -z "$OPTIONS_SWIFT_BIN" ]]; then - echo "Missing --swift-bin option" - print_help - exit 1 - fi - - if [[ -z "$OPTIONS_CLANG_BIN" ]]; then - OPTIONS_CLANG_BIN="$OPTIONS_LLVM_BIN" - fi - - build_target_toolchain "$OPTIONS_LLVM_BIN" "$OPTIONS_CLANG_BIN" "$OPTIONS_SWIFT_BIN" "$OPTIONS_SCHEME" -} - -main "$@" diff --git a/schemes/release-5.10/build/build-xctest.sh b/schemes/release-5.10/build/build-xctest.sh deleted file mode 100755 index fdbedb58..00000000 --- a/schemes/release-5.10/build/build-xctest.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -set -ex -DESTINATION_TOOLCHAIN=$1 -LLVM_BIN_DIR=$2 -CLANG_BIN_DIR=$3 -SWIFT_BIN_DIR=$4 -WASI_SYSROOT_PATH=$5 - -SOURCE_PATH="$(cd "$(dirname $0)/../../../../" && pwd)" -TOOLS_BUILD_PATH="$(cd "$(dirname "$0")/../../../tools/build" && pwd)" - -BUILD_DIR="$SOURCE_PATH/build/WebAssembly/xctest-wasi-wasm32" - -mkdir -p $BUILD_DIR -cd $BUILD_DIR - -cmake -G Ninja \ - -DCMAKE_BUILD_TYPE="Release" \ - -DCMAKE_SYSROOT="$WASI_SYSROOT_PATH" \ - -DCMAKE_Swift_COMPILER="$SWIFT_BIN_DIR/swiftc" \ - -DCMAKE_TOOLCHAIN_FILE="$TOOLS_BUILD_PATH/toolchain-wasi.cmake" \ - -DLLVM_BIN="$LLVM_BIN_DIR" \ - -DCLANG_BIN="$CLANG_BIN_DIR" \ - -DBUILD_SHARED_LIBS=OFF \ - -DCMAKE_Swift_COMPILER_FORCED=ON \ - -DCMAKE_Swift_FLAGS="-resource-dir $DESTINATION_TOOLCHAIN/usr/lib/swift_static" \ - -DSWIFT_FOUNDATION_PATH=$DESTINATION_TOOLCHAIN/usr/lib/swift_static/wasi/wasm32 \ - "${SOURCE_PATH}/swift-corelibs-xctest" - -ninja -v -DESTDIR="$DESTINATION_TOOLCHAIN/usr/lib" ninja -v install diff --git a/schemes/release-5.10/build/run-test.sh b/schemes/release-5.10/build/run-test.sh deleted file mode 100755 index 5d48e403..00000000 --- a/schemes/release-5.10/build/run-test.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -set -euxo pipefail - -SOURCE_PATH="$(cd "$(dirname "$0")/../../../.." && pwd)" -TARGET_BUILD_ROOT="$SOURCE_PATH/build/WebAssembly" - -ninja check-swift-wasi-wasm32-custom -C "$TARGET_BUILD_ROOT/swift-stdlib-wasi-wasm32" diff --git a/schemes/release-5.10/manifest.json b/schemes/release-5.10/manifest.json deleted file mode 100644 index fc219e31..00000000 --- a/schemes/release-5.10/manifest.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "update-checkout-scheme": "release/5.10", - "base-tag": "swift-5.10-DEVELOPMENT-SNAPSHOT-2024-05-31-a", - "repos": { - "swift-corelibs-foundation": "197278295ffeae13f91d6299c2bb43bf4ca93e83", - "swift-corelibs-xctest": "77bc9f5386ee8a2a4e8da5ac30e846b451d101b6" - }, - "icu4c": ["https://github.com/swiftwasm/icu4c-wasi/releases/download/0.5.0/icu4c-wasi.tar.xz"], - "libxml2": ["https://github.com/swiftwasm/libxml2-wasm/releases/download/2.0.0/libxml2-wasm32-unknown-wasi.tar.gz"], - "wasi-sysroot": "https://github.com/swiftwasm/wasi-sdk-build/releases/download/wasi-sdk-14%2Bswiftwasm-2022-03-13/wasi-sysroot.tar.gz", - "swift-org-download-channel": "swift-5.10-branch" -} diff --git a/schemes/release-5.10/swift/0001-wasm-build-Add-WASILibc-module-and-its-build-support.patch b/schemes/release-5.10/swift/0001-wasm-build-Add-WASILibc-module-and-its-build-support.patch deleted file mode 100644 index 5bca9bda..00000000 --- a/schemes/release-5.10/swift/0001-wasm-build-Add-WASILibc-module-and-its-build-support.patch +++ /dev/null @@ -1,438 +0,0 @@ -From 9b77b175da79caf00b80dc15310f8bcd46a485c1 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Wed, 7 Jun 2023 17:58:49 +0000 -Subject: [PATCH] [wasm][build] Add WASILibc module and its build support - -[wasi-libc](https://github.com/WebAssembly/wasi-libc) is a libc -implementation widely used in WASI toolchains. This patch adds a new -Swift and C module for it to import and use it in Swift code. This -module is intentionally separate from the existing `Glibc` module -because wasi-libc is actually based on musl libc. ---- - stdlib/public/Platform/CMakeLists.txt | 51 ++++-- - stdlib/public/Platform/SwiftWASILibc.h.gyb | 126 ++++++++++++++ - stdlib/public/Platform/WASILibc.swift.gyb | 161 ++++++++++++++++++ - .../public/Platform/wasi-libc.modulemap.gyb | 18 ++ - 4 files changed, 343 insertions(+), 13 deletions(-) - create mode 100644 stdlib/public/Platform/SwiftWASILibc.h.gyb - create mode 100644 stdlib/public/Platform/WASILibc.swift.gyb - create mode 100644 stdlib/public/Platform/wasi-libc.modulemap.gyb - -diff --git a/stdlib/public/Platform/CMakeLists.txt b/stdlib/public/Platform/CMakeLists.txt -index 18be6412cf3..e0ee5283fc5 100644 ---- a/stdlib/public/Platform/CMakeLists.txt -+++ b/stdlib/public/Platform/CMakeLists.txt -@@ -114,6 +114,23 @@ add_swift_target_library(swiftMusl ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OV - TARGET_SDKS MUSL - INSTALL_IN_COMPONENT sdk-overlay) - -+add_swift_target_library(swiftWASILibc ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY -+ ${swift_platform_sources} -+ POSIXError.swift -+ -+ GYB_SOURCES -+ ${swift_platform_gyb_sources} -+ WASILibc.swift.gyb -+ -+ SWIFT_COMPILE_FLAGS -+ ${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS} -+ ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS} -+ ${swift_platform_compile_flags} -+ LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}" -+ TARGET_SDKS WASI -+ INSTALL_IN_COMPONENT sdk-overlay -+ DEPENDS glibc_modulemap) -+ - add_swift_target_library(swiftCRT ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY - ucrt.swift - ${swift_platform_sources} -@@ -133,23 +150,31 @@ add_swift_target_library(swiftCRT ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVE - - set(glibc_modulemap_target_list) - foreach(sdk ${SWIFT_SDKS}) -- if(NOT "${sdk}" STREQUAL "LINUX" AND -- NOT "${sdk}" STREQUAL "FREEBSD" AND -- NOT "${sdk}" STREQUAL "OPENBSD" AND -- NOT "${sdk}" STREQUAL "ANDROID" AND -- NOT "${sdk}" STREQUAL "CYGWIN" AND -- NOT "${sdk}" STREQUAL "HAIKU") -+ if("${sdk}" STREQUAL "LINUX" OR -+ "${sdk}" STREQUAL "FREEBSD" OR -+ "${sdk}" STREQUAL "OPENBSD" OR -+ "${sdk}" STREQUAL "ANDROID" OR -+ "${sdk}" STREQUAL "CYGWIN" OR -+ "${sdk}" STREQUAL "HAIKU") -+ set(glibc_modulemap_source "glibc.modulemap.gyb") -+ set(glibc_header_source "SwiftGlibc.h.gyb") -+ elseif("${sdk}" STREQUAL "WASI") -+ set(glibc_modulemap_source "wasi-libc.modulemap.gyb") -+ set(glibc_header_source "SwiftWASILibc.h.gyb") -+ else() - continue() - endif() - -+ string(REGEX REPLACE "\\.gyb$" "" glibc_modulemap_outname "${glibc_modulemap_source}") -+ string(REGEX REPLACE "\\.gyb$" "" glibc_header_outname "${glibc_header_source}") -+ - foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES}) - set(arch_subdir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}") - set(module_dir "${SWIFTLIB_DIR}/${arch_subdir}") - set(module_dir_static "${SWIFTSTATICLIB_DIR}/${arch_subdir}") - -- set(glibc_modulemap_source "glibc.modulemap.gyb") -- set(glibc_modulemap_out "${module_dir}/glibc.modulemap") -- set(glibc_modulemap_out_static "${module_dir_static}/glibc.modulemap") -+ set(glibc_modulemap_out "${module_dir}/${glibc_modulemap_outname}") -+ set(glibc_modulemap_out_static "${module_dir_static}/${glibc_modulemap_outname}") - - # Configure the module map based on the target. Each platform needs to - # reference different headers, based on what's available in their glibc. -@@ -163,10 +188,10 @@ foreach(sdk ${SWIFT_SDKS}) - - list(APPEND glibc_modulemap_target_list ${glibc_modulemap_target}) - -- set(glibc_header_out "${module_dir}/SwiftGlibc.h") -- set(glibc_header_out_static "${module_dir_static}/SwiftGlibc.h") -+ set(glibc_header_out "${module_dir}/${glibc_header_outname}") -+ set(glibc_header_out_static "${module_dir_static}/${glibc_header_outname}") - handle_gyb_source_single(glibc_header_target -- SOURCE "SwiftGlibc.h.gyb" -+ SOURCE "${glibc_header_source}" - OUTPUT "${glibc_header_out}" - FLAGS "-DCMAKE_SDK=${sdk}") - list(APPEND glibc_modulemap_target_list ${glibc_header_target}) -@@ -197,7 +222,7 @@ foreach(sdk ${SWIFT_SDKS}) - # prefix. This is the one we'll install instead. - if(NOT "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${arch}_PATH}" STREQUAL "/" AND - NOT (sdk STREQUAL "ANDROID" AND NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")) -- set(glibc_sysroot_relative_modulemap_out "${module_dir}/sysroot-relative-modulemaps/glibc.modulemap") -+ set(glibc_sysroot_relative_modulemap_out "${module_dir}/sysroot-relative-modulemaps/${glibc_modulemap_outname}") - - handle_gyb_source_single(glibc_modulemap_native_target - SOURCE "${glibc_modulemap_source}" -diff --git a/stdlib/public/Platform/SwiftWASILibc.h.gyb b/stdlib/public/Platform/SwiftWASILibc.h.gyb -new file mode 100644 -index 00000000000..c051627f2b7 ---- /dev/null -+++ b/stdlib/public/Platform/SwiftWASILibc.h.gyb -@@ -0,0 +1,126 @@ -+%{ -+headers = [ -+ 'stdc-predef.h', -+ 'features.h', -+ -+ # C standard library -+ 'complex.h', -+ 'ctype.h', -+ 'errno.h', -+ 'fenv.h', -+ 'float.h', -+ 'inttypes.h', -+ 'iso646.h', -+ 'libutil.h', -+ 'limits.h', -+ 'locale.h', -+ 'math.h', -+ 'pty.h', -+ # setjmp/longjmp is not available -+ # 'setjmp.h', -+ 'signal.h', -+ 'stdarg.h', -+ 'stdbool.h', -+ 'stddef.h', -+ 'stdint.h', -+ 'stdio.h', -+ 'stdlib.h', -+ 'string.h', -+ 'tgmath.h', -+ 'time.h', -+ 'util.h', -+ 'utmp.h', -+ -+ # POSIX -+ 'aio.h', -+ 'arpa/inet.h', -+ 'bsd/ifaddrs.h', -+ 'bsd/pty.h', -+ 'cpio.h', -+ 'dirent.h', -+ 'dlfcn.h', -+ 'fcntl.h', -+ 'fmtmsg.h', -+ 'fnmatch.h', -+ 'ftw.h', -+ 'glob.h', -+ 'grp.h', -+ 'iconv.h', -+ 'ifaddrs.h', -+ 'langinfo.h', -+ 'libgen.h', -+ 'link.h', -+ 'monetary.h', -+ 'net/if.h', -+ 'netdb.h', -+ 'netinet/in.h', -+ 'netinet/tcp.h', -+ 'nl_types.h', -+ 'poll.h', -+ 'pthread.h', -+ 'pwd.h', -+ 'regex.h', -+ 'sched.h', -+ 'search.h', -+ 'semaphore.h', -+ 'spawn.h', -+ 'strings.h', -+ 'sys/event.h', -+ 'sys/file.h', -+ 'sys/inotify.h', -+ 'sys/ioctl.h', -+ 'sys/ipc.h', -+ 'sys/mman.h', -+ 'sys/mount.h', -+ 'sys/msg.h', -+ 'sys/resource.h', -+ 'sys/select.h', -+ 'sys/sem.h', -+ 'sys/sendfile.h', -+ 'sys/shm.h', -+ 'sys/socket.h', -+ 'sys/stat.h', -+ 'sys/statvfs.h', -+ 'sys/time.h', -+ 'sys/times.h', -+ 'sys/types.h', -+ 'sys/uio.h', -+ 'sys/un.h', -+ 'sys/user.h', -+ 'sys/utsname.h', -+ 'sys/wait.h', -+ 'sysexits.h', -+ 'syslog.h', -+ 'tar.h', -+ 'termios.h', -+ 'ulimit.h', -+ 'unistd.h', -+ 'utime.h', -+ 'utmpx.h', -+ 'wait.h', -+ 'wordexp.h', -+ -+ # WASI specific -+ 'wasi/api.h', -+] -+}% -+ -+// FIXME?(katei): -+// Those emulations are now enabled by default to have compatibility -+// with other platforms as much as possible without any extra modification. -+// But we should consider moving them into their own submodules. -+#ifndef _WASI_EMULATED_MMAN -+# define _WASI_EMULATED_MMAN -+#endif -+#ifndef _WASI_EMULATED_SIGNAL -+# define _WASI_EMULATED_SIGNAL -+#endif -+#ifndef _WASI_EMULATED_PROCESS_CLOCKS -+# define _WASI_EMULATED_PROCESS_CLOCKS -+#endif -+ -+% for header in headers: -+#if __has_include(<${header}>) -+#include <${header}> -+#endif -+% end -diff --git a/stdlib/public/Platform/WASILibc.swift.gyb b/stdlib/public/Platform/WASILibc.swift.gyb -new file mode 100644 -index 00000000000..bd6e03ed3c4 ---- /dev/null -+++ b/stdlib/public/Platform/WASILibc.swift.gyb -@@ -0,0 +1,161 @@ -+//===----------------------------------------------------------------------===// -+// -+// This source file is part of the Swift.org open source project -+// -+// Copyright (c) 2020 Apple Inc. and the Swift project authors -+// Licensed under Apache License v2.0 with Runtime Library Exception -+// -+// See https://swift.org/LICENSE.txt for license information -+// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -+// -+//===----------------------------------------------------------------------===// -+ -+@_exported import SwiftWASILibc // Clang module -+ -+// Constants defined by -+@available(swift, deprecated: 3.0, message: "Please use 'Double.pi' or '.pi' to get the value of correct type and avoid casting.") -+public let M_PI = Double.pi -+ -+@available(swift, deprecated: 3.0, message: "Please use 'Double.pi / 2' or '.pi / 2' to get the value of correct type and avoid casting.") -+public let M_PI_2 = Double.pi / 2 -+ -+@available(swift, deprecated: 3.0, message: "Please use 'Double.pi / 4' or '.pi / 4' to get the value of correct type and avoid casting.") -+public let M_PI_4 = Double.pi / 4 -+ -+@available(swift, deprecated: 3.0, message: "Please use '2.squareRoot()'.") -+public let M_SQRT2 = 2.squareRoot() -+ -+@available(swift, deprecated: 3.0, message: "Please use '0.5.squareRoot()'.") -+public let M_SQRT1_2 = 0.5.squareRoot() -+ -+// Constants defined by -+@available(swift, deprecated: 3.0, message: "Please use 'T.radix' to get the radix of a FloatingPoint type 'T'.") -+public let FLT_RADIX = Double.radix -+ -+%for type, prefix in [('Float', 'FLT'), ('Double', 'DBL')]: -+// Where does the 1 come from? C counts the usually-implicit leading -+// significand bit, but Swift does not. Neither is really right or wrong. -+@available(swift, deprecated: 3.0, message: "Please use '${type}.significandBitCount + 1'.") -+public let ${prefix}_MANT_DIG = ${type}.significandBitCount + 1 -+ -+// Where does the 1 come from? C models floating-point numbers as having a -+// significand in [0.5, 1), but Swift (following IEEE 754) considers the -+// significand to be in [1, 2). This rationale applies to ${prefix}_MIN_EXP -+// as well. -+@available(swift, deprecated: 3.0, message: "Please use '${type}.greatestFiniteMagnitude.exponent + 1'.") -+public let ${prefix}_MAX_EXP = ${type}.greatestFiniteMagnitude.exponent + 1 -+ -+@available(swift, deprecated: 3.0, message: "Please use '${type}.leastNormalMagnitude.exponent + 1'.") -+public let ${prefix}_MIN_EXP = ${type}.leastNormalMagnitude.exponent + 1 -+ -+@available(swift, deprecated: 3.0, message: "Please use '${type}.greatestFiniteMagnitude' or '.greatestFiniteMagnitude'.") -+public let ${prefix}_MAX = ${type}.greatestFiniteMagnitude -+ -+@available(swift, deprecated: 3.0, message: "Please use '${type}.ulpOfOne' or '.ulpOfOne'.") -+public let ${prefix}_EPSILON = ${type}.ulpOfOne -+ -+@available(swift, deprecated: 3.0, message: "Please use '${type}.leastNormalMagnitude' or '.leastNormalMagnitude'.") -+public let ${prefix}_MIN = ${type}.leastNormalMagnitude -+ -+@available(swift, deprecated: 3.0, message: "Please use '${type}.leastNonzeroMagnitude' or '.leastNonzeroMagnitude'.") -+public let ${prefix}_TRUE_MIN = ${type}.leastNonzeroMagnitude -+ -+%end -+ -+public let MAP_FAILED: UnsafeMutableRawPointer! = UnsafeMutableRawPointer(bitPattern: -1) -+ -+// TODO: wasi-libc's error.h defines these macros as function-like macros, which -+// Swift can't import for now. -+%{ -+posix_error_codes = [ -+ "E2BIG", -+ "EACCES", -+ "EADDRINUSE", -+ "EADDRNOTAVAIL", -+ "EAFNOSUPPORT", -+ "EAGAIN", -+ "EALREADY", -+ "EBADF", -+ "EBADMSG", -+ "EBUSY", -+ "ECANCELED", -+ "ECHILD", -+ "ECONNABORTED", -+ "ECONNREFUSED", -+ "ECONNRESET", -+ "EDEADLK", -+ "EDESTADDRREQ", -+ "EDOM", -+ "EDQUOT", -+ "EEXIST", -+ "EFAULT", -+ "EFBIG", -+ "EHOSTUNREACH", -+ "EIDRM", -+ "EILSEQ", -+ "EINPROGRESS", -+ "EINTR", -+ "EINVAL", -+ "EIO", -+ "EISCONN", -+ "EISDIR", -+ "ELOOP", -+ "EMFILE", -+ "EMLINK", -+ "EMSGSIZE", -+ "EMULTIHOP", -+ "ENAMETOOLONG", -+ "ENETDOWN", -+ "ENETRESET", -+ "ENETUNREACH", -+ "ENFILE", -+ "ENOBUFS", -+ "ENODEV", -+ "ENOENT", -+ "ENOEXEC", -+ "ENOLCK", -+ "ENOLINK", -+ "ENOMEM", -+ "ENOMSG", -+ "ENOPROTOOPT", -+ "ENOSPC", -+ "ENOSYS", -+ "ENOTCONN", -+ "ENOTDIR", -+ "ENOTEMPTY", -+ "ENOTRECOVERABLE", -+ "ENOTSOCK", -+ "ENOTSUP", -+ "ENOTTY", -+ "ENXIO", -+ "EOVERFLOW", -+ "EOWNERDEAD", -+ "EPERM", -+ "EPIPE", -+ "EPROTO", -+ "EPROTONOSUPPORT", -+ "EPROTOTYPE", -+ "ERANGE", -+ "EROFS", -+ "ESPIPE", -+ "ESRCH", -+ "ESTALE", -+ "ETIMEDOUT", -+ "ETXTBSY", -+ "EXDEV", -+ "ENOTCAPABLE", -+] -+}% -+ -+%for ecode in posix_error_codes: -+ -+@available(*, deprecated, message: "Please use 'POSIXErrorCode.${ecode}'.") -+public let ${ecode} = POSIXErrorCode.${ecode}.rawValue -+ -+%end -+ -+// TODO: wasi-libc's _seek.h defines these macros as function-like macros, which -+// Swift can't import for now. -+public let SEEK_SET: Int32 = 0 -+public let SEEK_CUR: Int32 = 1 -+public let SEEK_END: Int32 = 2 -diff --git a/stdlib/public/Platform/wasi-libc.modulemap.gyb b/stdlib/public/Platform/wasi-libc.modulemap.gyb -new file mode 100644 -index 00000000000..59be5d56499 ---- /dev/null -+++ b/stdlib/public/Platform/wasi-libc.modulemap.gyb -@@ -0,0 +1,18 @@ -+//===--- wasi-libc.modulemap.gyb ------------------------------------------===// -+// -+// This source file is part of the Swift.org open source project -+// -+// Copyright (c) 2020 Apple Inc. and the Swift project authors -+// Licensed under Apache License v2.0 with Runtime Library Exception -+// -+// See https://swift.org/LICENSE.txt for license information -+// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -+// -+//===----------------------------------------------------------------------===// -+ -+module SwiftWASILibc [system] { -+ // C standard library -+ header "SwiftWASILibc.h" -+ -+ export * -+} --- -2.40.0 - diff --git a/schemes/release-5.10/swift/0002-ClangImporter-Support-wasi-libc.modulemap-import-wit.patch b/schemes/release-5.10/swift/0002-ClangImporter-Support-wasi-libc.modulemap-import-wit.patch deleted file mode 100644 index a13dabe6..00000000 --- a/schemes/release-5.10/swift/0002-ClangImporter-Support-wasi-libc.modulemap-import-wit.patch +++ /dev/null @@ -1,91 +0,0 @@ -From a11041f37625d9b81b6ff03b8b523967b9bc55ed Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Sat, 10 Jun 2023 14:51:49 +0000 -Subject: [PATCH] [ClangImporter] Support wasi-libc.modulemap import with VFS - ---- - lib/ClangImporter/ClangIncludePaths.cpp | 41 +++++++++++++++++++------ - 1 file changed, 31 insertions(+), 10 deletions(-) - -diff --git a/lib/ClangImporter/ClangIncludePaths.cpp b/lib/ClangImporter/ClangIncludePaths.cpp -index 697c53b91c1..8faf184a472 100644 ---- a/lib/ClangImporter/ClangIncludePaths.cpp -+++ b/lib/ClangImporter/ClangIncludePaths.cpp -@@ -101,6 +101,13 @@ static llvm::Optional getGlibcModuleMapPath( - /*isArchSpecific*/ true, vfs); - } - -+static llvm::Optional getWASILibcModuleMapPath( -+ SearchPathOptions &Opts, const llvm::Triple &triple, -+ const llvm::IntrusiveRefCntPtr &vfs) { -+ return getActualModuleMapPath("wasi-libc.modulemap", Opts, triple, -+ /*isArchSpecific*/ true, vfs); -+} -+ - static llvm::Optional getLibStdCxxModuleMapPath( - SearchPathOptions &opts, const llvm::Triple &triple, - const llvm::IntrusiveRefCntPtr &vfs) { -@@ -195,11 +202,32 @@ static bool shouldInjectGlibcModulemap(const llvm::Triple &triple) { - triple.isAndroid(); - } - -+static bool shouldInjectWASILibcModulemap(const llvm::Triple &triple) { -+ return triple.isOSWASI(); -+} -+ - static SmallVector, 2> getGlibcFileMapping( - ASTContext &ctx, - const llvm::IntrusiveRefCntPtr &vfs) { - const llvm::Triple &triple = ctx.LangOpts.Target; -- if (!shouldInjectGlibcModulemap(triple)) -+ -+ std::string auxiliaryHeaderName; -+ llvm::Optional maybeActualModuleMapPath; -+ if (shouldInjectGlibcModulemap(triple)) { -+ auxiliaryHeaderName = "SwiftGlibc.h"; -+ maybeActualModuleMapPath = getGlibcModuleMapPath(ctx.SearchPathOpts, triple, vfs); -+ } else if (shouldInjectWASILibcModulemap(triple)) { -+ auxiliaryHeaderName = "SwiftWASILibc.h"; -+ maybeActualModuleMapPath = getWASILibcModuleMapPath(ctx.SearchPathOpts, triple, vfs); -+ } else { -+ return {}; -+ } -+ -+ Path actualModuleMapPath; -+ if (auto path = maybeActualModuleMapPath) -+ actualModuleMapPath = path.value(); -+ else -+ // FIXME: Emit a warning of some kind. - return {}; - - // Extract the Glibc path from Clang driver. -@@ -225,24 +253,17 @@ static SmallVector, 2> getGlibcFileMapping( - return {}; - } - -- Path actualModuleMapPath; -- if (auto path = getGlibcModuleMapPath(ctx.SearchPathOpts, triple, vfs)) -- actualModuleMapPath = path.value(); -- else -- // FIXME: Emit a warning of some kind. -- return {}; -- - // TODO: remove the SwiftGlibc.h header and reference all Glibc headers - // directly from the modulemap. - Path actualHeaderPath = actualModuleMapPath; - llvm::sys::path::remove_filename(actualHeaderPath); -- llvm::sys::path::append(actualHeaderPath, "SwiftGlibc.h"); -+ llvm::sys::path::append(actualHeaderPath, auxiliaryHeaderName); - - Path injectedModuleMapPath(glibcDir); - llvm::sys::path::append(injectedModuleMapPath, "module.modulemap"); - - Path injectedHeaderPath(glibcDir); -- llvm::sys::path::append(injectedHeaderPath, "SwiftGlibc.h"); -+ llvm::sys::path::append(injectedHeaderPath, auxiliaryHeaderName); - - return { - {std::string(injectedModuleMapPath), std::string(actualModuleMapPath)}, --- -2.40.0 - diff --git a/schemes/release-5.10/swift/0003-build-Replace-glibc-specific-naming-in-libc-like-mod.patch b/schemes/release-5.10/swift/0003-build-Replace-glibc-specific-naming-in-libc-like-mod.patch deleted file mode 100644 index 0cfdc2d4..00000000 --- a/schemes/release-5.10/swift/0003-build-Replace-glibc-specific-naming-in-libc-like-mod.patch +++ /dev/null @@ -1,195 +0,0 @@ -From 8d736a6ed61eee209eb1416b73087cbaf833dcda Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Sat, 10 Jun 2023 12:57:10 +0000 -Subject: [PATCH] [build] Replace glibc specific naming in libc-like modulemap - generation loop - ---- - stdlib/public/Platform/CMakeLists.txt | 90 +++++++++++++-------------- - 1 file changed, 45 insertions(+), 45 deletions(-) - -diff --git a/stdlib/public/Platform/CMakeLists.txt b/stdlib/public/Platform/CMakeLists.txt -index e0ee5283fc5..a3f090e28ea 100644 ---- a/stdlib/public/Platform/CMakeLists.txt -+++ b/stdlib/public/Platform/CMakeLists.txt -@@ -96,7 +96,7 @@ add_swift_target_library(swiftGlibc ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_O - LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}" - TARGET_SDKS "${swiftGlibc_target_sdks}" - INSTALL_IN_COMPONENT sdk-overlay -- DEPENDS glibc_modulemap) -+ DEPENDS libc_modulemap) - - add_swift_target_library(swiftMusl ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY - ${swift_platform_sources} -@@ -129,7 +129,7 @@ add_swift_target_library(swiftWASILibc ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SD - LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}" - TARGET_SDKS WASI - INSTALL_IN_COMPONENT sdk-overlay -- DEPENDS glibc_modulemap) -+ DEPENDS libc_modulemap) - - add_swift_target_library(swiftCRT ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY - ucrt.swift -@@ -148,7 +148,7 @@ add_swift_target_library(swiftCRT ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVE - TARGET_SDKS WINDOWS - INSTALL_IN_COMPONENT sdk-overlay) - --set(glibc_modulemap_target_list) -+set(libc_modulemap_target_list) - foreach(sdk ${SWIFT_SDKS}) - if("${sdk}" STREQUAL "LINUX" OR - "${sdk}" STREQUAL "FREEBSD" OR -@@ -156,65 +156,65 @@ foreach(sdk ${SWIFT_SDKS}) - "${sdk}" STREQUAL "ANDROID" OR - "${sdk}" STREQUAL "CYGWIN" OR - "${sdk}" STREQUAL "HAIKU") -- set(glibc_modulemap_source "glibc.modulemap.gyb") -- set(glibc_header_source "SwiftGlibc.h.gyb") -+ set(libc_modulemap_source "glibc.modulemap.gyb") -+ set(libc_header_source "SwiftGlibc.h.gyb") - elseif("${sdk}" STREQUAL "WASI") -- set(glibc_modulemap_source "wasi-libc.modulemap.gyb") -- set(glibc_header_source "SwiftWASILibc.h.gyb") -+ set(libc_modulemap_source "wasi-libc.modulemap.gyb") -+ set(libc_header_source "SwiftWASILibc.h.gyb") - else() - continue() - endif() - -- string(REGEX REPLACE "\\.gyb$" "" glibc_modulemap_outname "${glibc_modulemap_source}") -- string(REGEX REPLACE "\\.gyb$" "" glibc_header_outname "${glibc_header_source}") -+ string(REGEX REPLACE "\\.gyb$" "" libc_modulemap_outname "${libc_modulemap_source}") -+ string(REGEX REPLACE "\\.gyb$" "" libc_header_outname "${libc_header_source}") - - foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES}) - set(arch_subdir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}") - set(module_dir "${SWIFTLIB_DIR}/${arch_subdir}") - set(module_dir_static "${SWIFTSTATICLIB_DIR}/${arch_subdir}") - -- set(glibc_modulemap_out "${module_dir}/${glibc_modulemap_outname}") -- set(glibc_modulemap_out_static "${module_dir_static}/${glibc_modulemap_outname}") -+ set(libc_modulemap_out "${module_dir}/${libc_modulemap_outname}") -+ set(libc_modulemap_out_static "${module_dir_static}/${libc_modulemap_outname}") - - # Configure the module map based on the target. Each platform needs to -- # reference different headers, based on what's available in their glibc. -- # This is the 'glibc.modulemap' in the 'resource-dir', so -+ # reference different headers, based on what's available in their libc. -+ # This is the .modulemap in the 'resource-dir', so - # it's the one we'll look at during the build process. -- handle_gyb_source_single(glibc_modulemap_target -- SOURCE "${glibc_modulemap_source}" -- OUTPUT "${glibc_modulemap_out}" -+ handle_gyb_source_single(libc_modulemap_target -+ SOURCE "${libc_modulemap_source}" -+ OUTPUT "${libc_modulemap_out}" - FLAGS - "-DCMAKE_SDK=${sdk}") - -- list(APPEND glibc_modulemap_target_list ${glibc_modulemap_target}) -+ list(APPEND libc_modulemap_target_list ${libc_modulemap_target}) - -- set(glibc_header_out "${module_dir}/${glibc_header_outname}") -- set(glibc_header_out_static "${module_dir_static}/${glibc_header_outname}") -- handle_gyb_source_single(glibc_header_target -- SOURCE "${glibc_header_source}" -- OUTPUT "${glibc_header_out}" -+ set(libc_header_out "${module_dir}/${libc_header_outname}") -+ set(libc_header_out_static "${module_dir_static}/${libc_header_outname}") -+ handle_gyb_source_single(libc_header_target -+ SOURCE "${libc_header_source}" -+ OUTPUT "${libc_header_out}" - FLAGS "-DCMAKE_SDK=${sdk}") -- list(APPEND glibc_modulemap_target_list ${glibc_header_target}) -+ list(APPEND libc_modulemap_target_list ${libc_header_target}) - - if(SWIFT_BUILD_STATIC_STDLIB) - add_custom_command_target( -- copy_glibc_modulemap_header_static -+ copy_libc_modulemap_header_static - COMMAND - "${CMAKE_COMMAND}" "-E" "make_directory" ${module_dir_static} - COMMAND - "${CMAKE_COMMAND}" "-E" "copy" -- ${glibc_modulemap_out} ${glibc_modulemap_out_static} -+ ${libc_modulemap_out} ${libc_modulemap_out_static} - COMMAND - "${CMAKE_COMMAND}" "-E" "copy" -- ${glibc_header_out} ${glibc_header_out_static} -- OUTPUT ${glibc_modulemap_out_static} ${glibc_header_out_static} -+ ${libc_header_out} ${libc_header_out_static} -+ OUTPUT ${libc_modulemap_out_static} ${libc_header_out_static} - DEPENDS -- "${glibc_modulemap_target}" -- "${glibc_header_target}" -- COMMENT "Copying Glibc modulemap and header to static resources") -+ "${libc_modulemap_target}" -+ "${libc_header_target}" -+ COMMENT "Copying libc modulemap and header to static resources") - -- list(APPEND glibc_modulemap_target_list -- ${copy_glibc_modulemap_header_static}) -+ list(APPEND libc_modulemap_target_list -+ ${copy_libc_modulemap_header_static}) - endif() - - # If this SDK is a target for a non-native host, except if it's for Android -@@ -222,15 +222,15 @@ foreach(sdk ${SWIFT_SDKS}) - # prefix. This is the one we'll install instead. - if(NOT "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${arch}_PATH}" STREQUAL "/" AND - NOT (sdk STREQUAL "ANDROID" AND NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")) -- set(glibc_sysroot_relative_modulemap_out "${module_dir}/sysroot-relative-modulemaps/${glibc_modulemap_outname}") -+ set(libc_sysroot_relative_modulemap_out "${module_dir}/sysroot-relative-modulemaps/${libc_modulemap_outname}") - -- handle_gyb_source_single(glibc_modulemap_native_target -- SOURCE "${glibc_modulemap_source}" -- OUTPUT "${glibc_sysroot_relative_modulemap_out}" -+ handle_gyb_source_single(libc_modulemap_native_target -+ SOURCE "${libc_modulemap_source}" -+ OUTPUT "${libc_sysroot_relative_modulemap_out}" - FLAGS "-DCMAKE_SDK=${sdk}") - -- list(APPEND glibc_modulemap_target_list ${glibc_modulemap_native_target}) -- set(glibc_modulemap_out ${glibc_sysroot_relative_modulemap_out}) -+ list(APPEND libc_modulemap_target_list ${libc_modulemap_native_target}) -+ set(libc_modulemap_out ${libc_sysroot_relative_modulemap_out}) - endif() - - # FIXME: When SDK is a cross-compile target (SDK != Host), the generated -@@ -238,26 +238,26 @@ foreach(sdk ${SWIFT_SDKS}) - # It is not relocatable to the target platform itself. - # This affects any cross-compiled targets that use glibc.modulemap. - -- swift_install_in_component(FILES "${glibc_modulemap_out}" -+ swift_install_in_component(FILES "${libc_modulemap_out}" - DESTINATION "lib/swift/${arch_subdir}" - COMPONENT sdk-overlay) -- swift_install_in_component(FILES "${glibc_header_out}" -+ swift_install_in_component(FILES "${libc_header_out}" - DESTINATION "lib/swift/${arch_subdir}" - COMPONENT sdk-overlay) - - if(SWIFT_BUILD_STATIC_STDLIB) -- swift_install_in_component(FILES "${glibc_modulemap_out}" -+ swift_install_in_component(FILES "${libc_modulemap_out}" - DESTINATION "lib/swift_static/${arch_subdir}" - COMPONENT sdk-overlay) -- swift_install_in_component(FILES "${glibc_header_out}" -+ swift_install_in_component(FILES "${libc_header_out}" - DESTINATION "lib/swift_static/${arch_subdir}" - COMPONENT sdk-overlay) - endif() - endforeach() - endforeach() --add_custom_target(glibc_modulemap DEPENDS ${glibc_modulemap_target_list}) --set_property(TARGET glibc_modulemap PROPERTY FOLDER "Miscellaneous") --add_dependencies(sdk-overlay glibc_modulemap) -+add_custom_target(libc_modulemap DEPENDS ${libc_modulemap_target_list}) -+set_property(TARGET libc_modulemap PROPERTY FOLDER "Miscellaneous") -+add_dependencies(sdk-overlay libc_modulemap) - - if(WINDOWS IN_LIST SWIFT_SDKS) - swift_install_in_component(FILES --- -2.40.0 - diff --git a/schemes/release-5.10/swift/0004-wasm-Driver-HACK-Add-wasi-sysroot-layout-and-auto-de.patch b/schemes/release-5.10/swift/0004-wasm-Driver-HACK-Add-wasi-sysroot-layout-and-auto-de.patch deleted file mode 100644 index fdf3f48f..00000000 --- a/schemes/release-5.10/swift/0004-wasm-Driver-HACK-Add-wasi-sysroot-layout-and-auto-de.patch +++ /dev/null @@ -1,53 +0,0 @@ -From befdc1040d40bf33aa74bcdfc95a76401c41dcc8 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 07:11:04 +0000 -Subject: [PATCH] [wasm][Driver] HACK: Add wasi-sysroot layout and - auto-detection support - -Currenty, SwiftWasm toolchain contains wasi-sysroot under -`./usr/share/wasi-sysroot` directory in the toolchain package, but we -don't have a good consensus on the location of wasi-sysroot yet. So this -patch is a temporary solution just to avoid the need to specify `-sdk` -option manually. That being said, SwiftPM already passes `-sdk` option -to the driver, so the option is only needed when the driver is invoked -directly. ---- - lib/Driver/Driver.cpp | 7 +++++++ - lib/Driver/ToolChains.cpp | 3 ++- - 2 files changed, 9 insertions(+), 1 deletion(-) - -diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp -index 04f9684eb85..56e0d8cec43 100644 ---- a/lib/Driver/Driver.cpp -+++ b/lib/Driver/Driver.cpp -@@ -1794,6 +1794,13 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args, - }); - } - } -+ } if (OI.SDKPath.empty() && TC.getTriple().isOSWASI()) { -+ llvm::SmallString<128> SDKPath; -+ llvm::sys::path::append(SDKPath, getSwiftProgramPath()); -+ llvm::sys::path::remove_filename(SDKPath); // 'swift' -+ llvm::sys::path::remove_filename(SDKPath); // 'bin' -+ llvm::sys::path::append(SDKPath, "share", "wasi-sysroot"); -+ OI.SDKPath = SDKPath.str().str(); - } - - if (!OI.SDKPath.empty()) { -diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp -index eb1c8a0ade5..a1aecdc6d84 100644 ---- a/lib/Driver/ToolChains.cpp -+++ b/lib/Driver/ToolChains.cpp -@@ -1472,7 +1472,8 @@ void ToolChain::getResourceDirPath(SmallVectorImpl &resourceDirPath, - if (const Arg *A = args.getLastArg(options::OPT_resource_dir)) { - StringRef value = A->getValue(); - resourceDirPath.append(value.begin(), value.end()); -- } else if (!getTriple().isOSDarwin() && args.hasArg(options::OPT_sdk)) { -+ } else if (!getTriple().isOSDarwin() && !getTriple().isOSWASI() && args.hasArg(options::OPT_sdk)) { -+ // for WASI, sdk option points to wasi-sysroot which doesn't have Swift toolchain - StringRef value = args.getLastArg(options::OPT_sdk)->getValue(); - resourceDirPath.append(value.begin(), value.end()); - llvm::sys::path::append(resourceDirPath, "usr"); --- -2.40.0 - diff --git a/schemes/release-5.10/swift/0005-wasm-Driver-HACK-Add-use-static-resource-dir-by-defa.patch b/schemes/release-5.10/swift/0005-wasm-Driver-HACK-Add-use-static-resource-dir-by-defa.patch deleted file mode 100644 index 3cc05cdb..00000000 --- a/schemes/release-5.10/swift/0005-wasm-Driver-HACK-Add-use-static-resource-dir-by-defa.patch +++ /dev/null @@ -1,76 +0,0 @@ -From af29fc6c8897c036d61d94e86dade390245a5a80 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 07:17:38 +0000 -Subject: [PATCH] [wasm][Driver] HACK: Add `-use-static-resource-dir` by - default for wasm target - -Currently, wasm target only supports static linking mode, so we add -`-use-static-resource-dir` by default for wasm target. This patch is not -an essential change because we can also add `-use-static-resource-dir` -in the driver invocation. But it is a convenient change for users. ---- - lib/Driver/Driver.cpp | 3 ++- - lib/Driver/ToolChains.cpp | 19 +++++++++++++++++-- - 2 files changed, 19 insertions(+), 3 deletions(-) - -diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp -index 56e0d8cec43..20c8571ff07 100644 ---- a/lib/Driver/Driver.cpp -+++ b/lib/Driver/Driver.cpp -@@ -2402,7 +2402,8 @@ bool Driver::handleImmediateArgs(const ArgList &Args, const ToolChain &TC) { - if (Args.hasFlag(options::OPT_static_executable, - options::OPT_no_static_executable, false) || - Args.hasFlag(options::OPT_static_stdlib, options::OPT_no_static_stdlib, -- false)) { -+ false) || -+ TC.getTriple().isOSBinFormatWasm()) { - commandLine.push_back("-use-static-resource-dir"); - } - -diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp -index a1aecdc6d84..8e27d7d3410 100644 ---- a/lib/Driver/ToolChains.cpp -+++ b/lib/Driver/ToolChains.cpp -@@ -660,7 +660,8 @@ ToolChain::constructInvocation(const CompileJobAction &job, - if (context.Args.hasFlag(options::OPT_static_executable, - options::OPT_no_static_executable, false) || - context.Args.hasFlag(options::OPT_static_stdlib, -- options::OPT_no_static_stdlib, false)) { -+ options::OPT_no_static_stdlib, false) || -+ getTriple().isOSBinFormatWasm()) { - Arguments.push_back("-use-static-resource-dir"); - } - -@@ -1188,7 +1189,13 @@ ToolChain::constructInvocation(const MergeModuleJobAction &job, - context.Args.AddLastArg(Arguments, options::OPT_import_objc_header); - - context.Args.AddLastArg(Arguments, options::OPT_disable_incremental_imports); -- -+ if (context.Args.hasFlag(options::OPT_static_executable, -+ options::OPT_no_static_executable, false) || -+ context.Args.hasFlag(options::OPT_static_stdlib, -+ options::OPT_no_static_stdlib, false) || -+ getTriple().isOSBinFormatWasm()) { -+ Arguments.push_back("-use-static-resource-dir"); -+ } - Arguments.push_back("-module-name"); - Arguments.push_back(context.Args.MakeArgString(context.OI.ModuleName)); - -@@ -1388,6 +1395,14 @@ ToolChain::constructInvocation(const GeneratePCHJobAction &job, - addInputsOfType(Arguments, context.InputActions, file_types::TY_ClangHeader); - context.Args.AddLastArg(Arguments, options::OPT_index_store_path); - -+ if (context.Args.hasFlag(options::OPT_static_executable, -+ options::OPT_no_static_executable, false) || -+ context.Args.hasFlag(options::OPT_static_stdlib, options::OPT_no_static_stdlib, -+ false) || -+ getTriple().isOSBinFormatWasm()) { -+ Arguments.push_back("-use-static-resource-dir"); -+ } -+ - if (job.isPersistentPCH()) { - Arguments.push_back("-emit-pch"); - Arguments.push_back("-pch-output-dir"); --- -2.40.0 - diff --git a/schemes/release-5.10/swift/0006-wasm-IRGen-HACK-Disable-stack-protection.patch b/schemes/release-5.10/swift/0006-wasm-IRGen-HACK-Disable-stack-protection.patch deleted file mode 100644 index 7d018530..00000000 --- a/schemes/release-5.10/swift/0006-wasm-IRGen-HACK-Disable-stack-protection.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 108aa743a52681aca1e2c914840ee10d6f8d189b Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 07:21:31 +0000 -Subject: [PATCH] [wasm][IRGen] HACK: Disable stack protection - -This is a temporary workaround until we can update wasi-sdk to version -17 or later, which includes stack protection support in wasi-libc. -https://github.com/WebAssembly/wasi-libc/commit/8b7148f69ae241a2749b3defe4606da8143b72e0 ---- - lib/IRGen/GenDecl.cpp | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/lib/IRGen/GenDecl.cpp b/lib/IRGen/GenDecl.cpp -index 8062188cf4c..11edf34c0c1 100644 ---- a/lib/IRGen/GenDecl.cpp -+++ b/lib/IRGen/GenDecl.cpp -@@ -3358,7 +3358,8 @@ llvm::CallBase *swift::irgen::emitCXXConstructorCall( - - StackProtectorMode IRGenModule::shouldEmitStackProtector(SILFunction *f) { - const SILOptions &opts = IRGen.SIL.getOptions(); -- return (opts.EnableStackProtection && f->needsStackProtection()) ? -+ // FIXME(katei): stack protection support will be added by https://github.com/WebAssembly/wasi-libc/pull/351 -+ return (opts.EnableStackProtection && f->needsStackProtection() && Triple.getObjectFormat() != llvm::Triple::Wasm) ? - StackProtectorMode::StackProtector : StackProtectorMode::NoStackProtector; - } - --- -2.40.0 - diff --git a/schemes/release-5.10/swift/0007-wasm-SIL-IRGen-HACK-Always-forward-extra-argument-to.patch b/schemes/release-5.10/swift/0007-wasm-SIL-IRGen-HACK-Always-forward-extra-argument-to.patch deleted file mode 100644 index 6178fbf6..00000000 --- a/schemes/release-5.10/swift/0007-wasm-SIL-IRGen-HACK-Always-forward-extra-argument-to.patch +++ /dev/null @@ -1,246 +0,0 @@ -From 4f84234b8ca23a37b32ef5666489e6cbe400c7d6 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 07:25:35 +0000 -Subject: [PATCH] [wasm][SIL/IRGen] HACK: Always forward extra argument to - match callee and caller signature - -This is a legacy solution for the KeyPath calling convention problem -described in https://forums.swift.org/t/wasm-support/16087/21. This -patch will be replaced by https://github.com/apple/swift/pull/66273 ---- - lib/IRGen/GenKeyPath.cpp | 7 +++- - lib/SIL/Verifier/SILVerifier.cpp | 10 +++-- - lib/SILGen/SILGenExpr.cpp | 39 +++++++++++++++++-- - .../SILCombiner/SILCombinerApplyVisitors.cpp | 14 +++++++ - lib/SILOptimizer/Utils/KeyPathProjector.cpp | 17 +++++++- - 5 files changed, 77 insertions(+), 10 deletions(-) - -diff --git a/lib/IRGen/GenKeyPath.cpp b/lib/IRGen/GenKeyPath.cpp -index d23a53e822c..dfd37ec2830 100644 ---- a/lib/IRGen/GenKeyPath.cpp -+++ b/lib/IRGen/GenKeyPath.cpp -@@ -224,7 +224,8 @@ getAccessorForComputedComponent(IRGenModule &IGM, - componentArgsBuf = params.claimNext(); - // Pass the argument pointer down to the underlying function, if it - // wants it. -- if (hasSubscriptIndices) { -+ // Always forward extra argument to match callee and caller signature on WebAssembly -+ if (hasSubscriptIndices || IGM.TargetInfo.OutputObjectFormat == llvm::Triple::Wasm) { - forwardedArgs.add(componentArgsBuf); - } - break; -@@ -250,6 +251,10 @@ getAccessorForComputedComponent(IRGenModule &IGM, - forwardingSubs, - &ignoreWitnessMetadata, - forwardedArgs); -+ } else if (IGM.Triple.isOSBinFormatWasm()) { -+ // wasm: Add null swift.type pointer to match signature even when there is -+ // no generic environment. -+ forwardedArgs.add(llvm::ConstantPointerNull::get(IGM.TypeMetadataPtrTy)); - } - auto fnPtr = - FunctionPointer::forDirect(IGM, accessorFn, /*secondaryValue*/ nullptr, -diff --git a/lib/SIL/Verifier/SILVerifier.cpp b/lib/SIL/Verifier/SILVerifier.cpp -index 0bf3941d6a3..9ef2761cfed 100644 ---- a/lib/SIL/Verifier/SILVerifier.cpp -+++ b/lib/SIL/Verifier/SILVerifier.cpp -@@ -304,8 +304,9 @@ void verifyKeyPathComponent(SILModule &M, - SILFunctionTypeRepresentation::Thin, - "getter should be a thin function"); - -- require(substGetterType->getNumParameters() == 1 + hasIndices, -- "getter should have one parameter"); -+ // FIXME(katei): Disabled for now. Will be replaced by keypath cc -+ // require(substGetterType->getNumParameters() == 1 + hasIndices, -+ // "getter should have one parameter"); - auto baseParam = substGetterType->getParameters()[0]; - require(baseParam.getConvention() == normalArgConvention, - "getter base parameter should have normal arg convention"); -@@ -356,8 +357,9 @@ void verifyKeyPathComponent(SILModule &M, - SILFunctionTypeRepresentation::Thin, - "setter should be a thin function"); - -- require(substSetterType->getNumParameters() == 2 + hasIndices, -- "setter should have two parameters"); -+ // FIXME(katei): Disabled for now. Will be replaced by keypath cc -+ // require(substSetterType->getNumParameters() == 2 + hasIndices, -+ // "setter should have two parameters"); - - auto newValueParam = substSetterType->getParameters()[0]; - // TODO: This should probably be unconditionally +1 when we -diff --git a/lib/SILGen/SILGenExpr.cpp b/lib/SILGen/SILGenExpr.cpp -index d09f4974b7b..71d63a34f3d 100644 ---- a/lib/SILGen/SILGenExpr.cpp -+++ b/lib/SILGen/SILGenExpr.cpp -@@ -2987,6 +2987,7 @@ static SILFunction *getOrCreateKeyPathGetter(SILGenModule &SGM, - } - } - -+ auto Target = SGM.getASTContext().LangOpts.Target; - auto genericSig = - genericEnv ? genericEnv->getGenericSignature().getCanonicalSignature() - : nullptr; -@@ -2995,6 +2996,14 @@ static SILFunction *getOrCreateKeyPathGetter(SILGenModule &SGM, - genericEnv = nullptr; - } - -+ // Add empty generic type parameter to match function signature on WebAssembly -+ if (!genericSig && Target.isOSBinFormatWasm()) { -+ auto param = GenericTypeParamType::get(false, 0, 0, SGM.getASTContext()); -+ auto sig = GenericSignature::get(param, { }); -+ genericSig = CanGenericSignature(sig); -+ genericEnv = sig.getGenericEnvironment(); -+ } -+ - // Build the signature of the thunk as expected by the keypath runtime. - auto signature = [&]() { - CanType loweredBaseTy, loweredPropTy; -@@ -3010,7 +3019,8 @@ static SILFunction *getOrCreateKeyPathGetter(SILGenModule &SGM, - SmallVector params; - params.push_back({loweredBaseTy, paramConvention}); - auto &C = SGM.getASTContext(); -- if (!indexes.empty()) -+ // Always take indexes parameter to match callee and caller signature on WebAssembly -+ if (!indexes.empty() || C.LangOpts.Target.isOSBinFormatWasm()) - params.push_back({C.getUnsafeRawPointerType()->getCanonicalType(), - ParameterConvention::Direct_Unowned}); - -@@ -3070,7 +3080,8 @@ static SILFunction *getOrCreateKeyPathGetter(SILGenModule &SGM, - } - auto baseArg = entry->createFunctionArgument(baseArgTy); - SILValue indexPtrArg; -- if (!indexes.empty()) { -+ // Always take indexes parameter to match callee and caller signature on WebAssembly -+ if (!indexes.empty() || Target.isOSBinFormatWasm()) { - auto indexArgTy = - subSGF.silConv.getSILType(signature->getParameters()[1], signature, - subSGF.F.getTypeExpansionContext()); -@@ -3160,6 +3171,7 @@ static SILFunction *getOrCreateKeyPathSetter(SILGenModule &SGM, - } - } - -+ auto Target = SGM.getASTContext().LangOpts.Target; - auto genericSig = - genericEnv ? genericEnv->getGenericSignature().getCanonicalSignature() - : nullptr; -@@ -3168,6 +3180,14 @@ static SILFunction *getOrCreateKeyPathSetter(SILGenModule &SGM, - genericEnv = nullptr; - } - -+ // Add empty generic type parameter to match function signature on WebAssembly -+ if (!genericSig && Target.isOSBinFormatWasm()) { -+ auto param = GenericTypeParamType::get(false, 0, 0, SGM.getASTContext()); -+ auto sig = GenericSignature::get(param, { }); -+ genericSig = CanGenericSignature(sig); -+ genericEnv = sig.getGenericEnvironment(); -+ } -+ - // Build the signature of the thunk as expected by the keypath runtime. - auto signature = [&]() { - CanType loweredBaseTy, loweredPropTy; -@@ -3193,7 +3213,8 @@ static SILFunction *getOrCreateKeyPathSetter(SILGenModule &SGM, - ? ParameterConvention::Indirect_Inout - : paramConvention}); - // indexes -- if (!indexes.empty()) -+ // Always take indexes parameter to match callee and caller signature on WebAssembly -+ if (!indexes.empty() || C.LangOpts.Target.isOSBinFormatWasm()) - params.push_back({C.getUnsafeRawPointerType()->getCanonicalType(), - ParameterConvention::Direct_Unowned}); - -@@ -3249,7 +3270,8 @@ static SILFunction *getOrCreateKeyPathSetter(SILGenModule &SGM, - auto baseArg = entry->createFunctionArgument(baseArgTy); - SILValue indexPtrArg; - -- if (!indexes.empty()) { -+ // Always take indexes parameter to match callee and caller signature on WebAssembly -+ if (!indexes.empty() || Target.isOSBinFormatWasm()) { - auto indexArgTy = - subSGF.silConv.getSILType(signature->getParameters()[2], signature, - subSGF.getTypeExpansionContext()); -@@ -3342,6 +3364,7 @@ getOrCreateKeyPathEqualsAndHash(SILGenModule &SGM, - return; - } - -+ auto Target = SGM.getASTContext().LangOpts.Target; - auto genericSig = - genericEnv ? genericEnv->getGenericSignature().getCanonicalSignature() - : nullptr; -@@ -3351,6 +3374,14 @@ getOrCreateKeyPathEqualsAndHash(SILGenModule &SGM, - genericEnv = nullptr; - } - -+ // Add empty generic type parameter to match function signature on WebAssembly -+ if (!genericSig && Target.isOSBinFormatWasm()) { -+ auto param = GenericTypeParamType::get(false, 0, 0, SGM.getASTContext()); -+ auto sig = GenericSignature::get(param, { }); -+ genericSig = CanGenericSignature(sig); -+ genericEnv = sig.getGenericEnvironment(); -+ } -+ - auto &C = SGM.getASTContext(); - auto unsafeRawPointerTy = C.getUnsafeRawPointerType()->getCanonicalType(); - auto boolTy = C.getBoolType()->getCanonicalType(); -diff --git a/lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp b/lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp -index 6bf48c3d7f1..9b89e9d78e4 100644 ---- a/lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp -+++ b/lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp -@@ -505,6 +505,13 @@ bool SILCombiner::tryOptimizeKeypathKVCString(ApplyInst *AI, - } - - bool SILCombiner::tryOptimizeKeypath(ApplyInst *AI) { -+ // FIXME(katei): Disable for WebAssembly for now because -+ // KeyPath cc is unstable and KeyPathProjector hask violates -+ // some assert assumptions -+ SILModule &M = AI->getModule(); -+ if (M.getASTContext().LangOpts.Target.isOSBinFormatWasm()) -+ return false; -+ - if (SILFunction *callee = AI->getReferencedFunctionOrNull()) { - return tryOptimizeKeypathApplication(AI, callee); - } -@@ -550,6 +557,13 @@ bool SILCombiner::tryOptimizeKeypath(ApplyInst *AI) { - /// %addr = struct_element_addr/ref_element_addr %root_object - /// // use %inout_addr - bool SILCombiner::tryOptimizeInoutKeypath(BeginApplyInst *AI) { -+ // FIXME(katei): Disable for WebAssembly for now because -+ // KeyPath cc is unstable and KeyPathProjector hask violates -+ // some assert assumptions -+ SILModule &M = AI->getModule(); -+ if (M.getASTContext().LangOpts.Target.isOSBinFormatWasm()) -+ return false; -+ - // Disable in OSSA because KeyPathProjector is not fully ported - if (AI->getFunction()->hasOwnership()) - return false; -diff --git a/lib/SILOptimizer/Utils/KeyPathProjector.cpp b/lib/SILOptimizer/Utils/KeyPathProjector.cpp -index 073ba49a563..6950ab4ae10 100644 ---- a/lib/SILOptimizer/Utils/KeyPathProjector.cpp -+++ b/lib/SILOptimizer/Utils/KeyPathProjector.cpp -@@ -233,7 +233,22 @@ public: - assert(getter->getConventions().getNumSILArguments()); - - auto ref = builder.createFunctionRef(loc, getter); -- builder.createApply(loc, ref, subs, {addr, parentValue}); -+ -+ std::vector args{addr, parentValue}; -+ // FIXME(wasm): For wasm, KeyPath getter always take indices parameter -+ // to match callee and caller signature. So need to pass stub pointer. -+ // See also: getOrCreateKeyPathSetter and getOrCreateKeyPathGetter -+ if (builder.getASTContext().LangOpts.Target.isOSBinFormatWasm()) { -+ auto IntTy = SILType::getBuiltinIntegerType(32, builder.getASTContext()); -+ auto UnsafeRawPointerTy = SILType::getRawPointerType(builder.getASTContext()); -+ auto zeroVal = SILValue(builder.createIntegerLiteral(loc, IntTy, 0)); -+ auto stackBuffer = SILValue(builder.createAllocStack(loc, IntTy)); -+ builder.createStore(loc, zeroVal, stackBuffer, StoreOwnershipQualifier::Unqualified); -+ auto nonePointer = builder.createUncheckedAddrCast(loc, stackBuffer, UnsafeRawPointerTy); -+ args.push_back(SILValue(nonePointer)); -+ } -+ -+ builder.createApply(loc, ref, subs, args); - - // If we were previously accessing a class member, we're done now. - insertEndAccess(beginAccess, builder); --- -2.40.0 - diff --git a/schemes/release-5.10/swift/0008-wasm-cmake-Add-WASI-specific-stdlib-dependencies.patch b/schemes/release-5.10/swift/0008-wasm-cmake-Add-WASI-specific-stdlib-dependencies.patch deleted file mode 100644 index 2a28d867..00000000 --- a/schemes/release-5.10/swift/0008-wasm-cmake-Add-WASI-specific-stdlib-dependencies.patch +++ /dev/null @@ -1,79 +0,0 @@ -From 42890ba393098a717e9ebd9dfda42045e954dbcf Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 07:50:16 +0000 -Subject: [PATCH] [wasm][cmake] Add WASI specific stdlib dependencies - -Currently WASI target doesn't support SwiftPrivateThreadExtras, so we -need to remove it from the common dependencies. Also WASI target has its -own libc module WASILibc, so we need to add it as well as other libc modules. ---- - stdlib/private/StdlibUnittest/CMakeLists.txt | 1 + - stdlib/private/SwiftPrivate/CMakeLists.txt | 1 + - stdlib/private/SwiftPrivateLibcExtras/CMakeLists.txt | 1 + - stdlib/private/SwiftPrivateThreadExtras/CMakeLists.txt | 1 + - stdlib/public/Differentiation/CMakeLists.txt | 1 + - 5 files changed, 5 insertions(+) - -diff --git a/stdlib/private/StdlibUnittest/CMakeLists.txt b/stdlib/private/StdlibUnittest/CMakeLists.txt -index a8a3f17b60b..574b4aeea36 100644 ---- a/stdlib/private/StdlibUnittest/CMakeLists.txt -+++ b/stdlib/private/StdlibUnittest/CMakeLists.txt -@@ -61,6 +61,7 @@ add_swift_target_library(swiftStdlibUnittest ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} - SWIFT_MODULE_DEPENDS_OPENBSD Glibc - SWIFT_MODULE_DEPENDS_CYGWIN Glibc - SWIFT_MODULE_DEPENDS_HAIKU Glibc -+ SWIFT_MODULE_DEPENDS_WASI WASILibc - SWIFT_MODULE_DEPENDS_WINDOWS CRT WinSDK - C_COMPILE_FLAGS -I${SWIFT_SOURCE_DIR}/stdlib/include - SWIFT_COMPILE_FLAGS ${swift_stdlib_unittest_compile_flags} ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS} -diff --git a/stdlib/private/SwiftPrivate/CMakeLists.txt b/stdlib/private/SwiftPrivate/CMakeLists.txt -index a1fc412a156..f1e7d461d0e 100644 ---- a/stdlib/private/SwiftPrivate/CMakeLists.txt -+++ b/stdlib/private/SwiftPrivate/CMakeLists.txt -@@ -26,6 +26,7 @@ add_swift_target_library(swiftSwiftPrivate ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I - SWIFT_MODULE_DEPENDS_OPENBSD Glibc - SWIFT_MODULE_DEPENDS_CYGWIN Glibc - SWIFT_MODULE_DEPENDS_HAIKU Glibc -+ SWIFT_MODULE_DEPENDS_WASI WASILibc - SWIFT_MODULE_DEPENDS_WINDOWS CRT WinSDK - SWIFT_COMPILE_FLAGS ${swift_swiftprivate_compile_flags} ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS} - INSTALL_IN_COMPONENT stdlib-experimental -diff --git a/stdlib/private/SwiftPrivateLibcExtras/CMakeLists.txt b/stdlib/private/SwiftPrivateLibcExtras/CMakeLists.txt -index 9095a700838..b8058031de8 100644 ---- a/stdlib/private/SwiftPrivateLibcExtras/CMakeLists.txt -+++ b/stdlib/private/SwiftPrivateLibcExtras/CMakeLists.txt -@@ -36,6 +36,7 @@ add_swift_target_library(swiftSwiftPrivateLibcExtras ${SWIFT_STDLIB_LIBRARY_BUIL - SWIFT_MODULE_DEPENDS_OPENBSD Glibc - SWIFT_MODULE_DEPENDS_CYGWIN Glibc - SWIFT_MODULE_DEPENDS_HAIKU Glibc -+ SWIFT_MODULE_DEPENDS_WASI WASILibc - SWIFT_MODULE_DEPENDS_WINDOWS CRT WinSDK - INCORPORATE_OBJECT_LIBRARIES ${swift_private_libc_extras_incorporate_object_libraries} - INSTALL_IN_COMPONENT stdlib-experimental -diff --git a/stdlib/private/SwiftPrivateThreadExtras/CMakeLists.txt b/stdlib/private/SwiftPrivateThreadExtras/CMakeLists.txt -index 35fcf24881c..52d2e28b9f5 100644 ---- a/stdlib/private/SwiftPrivateThreadExtras/CMakeLists.txt -+++ b/stdlib/private/SwiftPrivateThreadExtras/CMakeLists.txt -@@ -17,6 +17,7 @@ add_swift_target_library(swiftSwiftPrivateThreadExtras ${SWIFT_STDLIB_LIBRARY_BU - SWIFT_MODULE_DEPENDS_OPENBSD Glibc - SWIFT_MODULE_DEPENDS_CYGWIN Glibc - SWIFT_MODULE_DEPENDS_HAIKU Glibc -+ SWIFT_MODULE_DEPENDS_WASI WASILibc - SWIFT_MODULE_DEPENDS_WINDOWS CRT WinSDK - SWIFT_COMPILE_FLAGS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS} - INSTALL_IN_COMPONENT stdlib-experimental -diff --git a/stdlib/public/Differentiation/CMakeLists.txt b/stdlib/public/Differentiation/CMakeLists.txt -index aa895c02bc8..30ad34900c7 100644 ---- a/stdlib/public/Differentiation/CMakeLists.txt -+++ b/stdlib/public/Differentiation/CMakeLists.txt -@@ -40,6 +40,7 @@ add_swift_target_library(swift_Differentiation ${SWIFT_STDLIB_LIBRARY_BUILD_TYPE - SWIFT_MODULE_DEPENDS_OPENBSD Glibc - SWIFT_MODULE_DEPENDS_CYGWIN Glibc - SWIFT_MODULE_DEPENDS_HAIKU Glibc -+ SWIFT_MODULE_DEPENDS_WASI WASILibc - SWIFT_MODULE_DEPENDS_WINDOWS CRT - - C_COMPILE_FLAGS --- -2.40.0 - diff --git a/schemes/release-5.10/swift/0009-test-Fix-calling-convention-mismatch-for-swift_deman.patch b/schemes/release-5.10/swift/0009-test-Fix-calling-convention-mismatch-for-swift_deman.patch deleted file mode 100644 index 29e4eb51..00000000 --- a/schemes/release-5.10/swift/0009-test-Fix-calling-convention-mismatch-for-swift_deman.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 55babf002797f1a0ba10a04dacda9e7214d45e2e Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 08:17:12 +0000 -Subject: [PATCH] [test] Fix calling convention mismatch for swift_demangle - -`test/stdlib/Runtime.swift.gyb` calls `swift_demangle` with the Swift -calling convention, but the functions is defined with the C calling -convention. But this does not cause a problem other than testing, and -ideal fix would be to put `@_cdecl` on the function declared in -Swift-side to choose the correct calling convention. `@cdecl` without -body is not supported yet but discussed in https://forums.swift.org/t/formalizing-cdecl/40677 ---- - stdlib/public/runtime/Demangle.cpp | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/stdlib/public/runtime/Demangle.cpp b/stdlib/public/runtime/Demangle.cpp -index 7b593612949..0f614cbb889 100644 ---- a/stdlib/public/runtime/Demangle.cpp -+++ b/stdlib/public/runtime/Demangle.cpp -@@ -910,6 +910,7 @@ swift::_swift_buildDemanglingForMetadata(const Metadata *type, - /// \returns the demangled name. Returns nullptr if the input String is not a - /// Swift mangled name. - SWIFT_RUNTIME_EXPORT -+SWIFT_CC(swift) - char *swift_demangle(const char *mangledName, - size_t mangledNameLength, - char *outputBuffer, --- -2.40.0 - diff --git a/schemes/release-5.10/swift/0010-stdlib-Fix-calling-convention-mismatch-for-swift_COW.patch b/schemes/release-5.10/swift/0010-stdlib-Fix-calling-convention-mismatch-for-swift_COW.patch deleted file mode 100644 index 2ec325ad..00000000 --- a/schemes/release-5.10/swift/0010-stdlib-Fix-calling-convention-mismatch-for-swift_COW.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 4e62fc36885b5ea6f1567c75c48e755aa269c49c Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 08:26:32 +0000 -Subject: [PATCH] [stdlib] Fix calling convention mismatch for - swift_COWChecksEnabled - -`ContiguousArrayBuffer.swift` calls `swift_COWChecksEnabled` with the -Swift calling convention, but the functions is defined with the C calling -convention. This mismatch actually happens only when building with -`enable-array-cow-checks` (which is not enabled by default). -Also ideal fix would be to put `@_cdecl` on the function declared in -Swift-side to choose the correct calling convention. `@cdecl` without -body is not supported yet but discussed in https://forums.swift.org/t/formalizing-cdecl/40677 ---- - stdlib/public/runtime/EnvironmentVariables.cpp | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/stdlib/public/runtime/EnvironmentVariables.cpp b/stdlib/public/runtime/EnvironmentVariables.cpp -index 264e44a4db6..3a04eb9c928 100644 ---- a/stdlib/public/runtime/EnvironmentVariables.cpp -+++ b/stdlib/public/runtime/EnvironmentVariables.cpp -@@ -253,6 +253,7 @@ void swift::runtime::environment::initialize(void *context) { - } - #endif - -+SWIFT_CC(swift) - SWIFT_RUNTIME_EXPORT - bool swift_COWChecksEnabled() { - return runtime::environment::SWIFT_DEBUG_ENABLE_COW_CHECKS(); --- -2.40.0 - diff --git a/schemes/release-5.10/swift/0011-stdlib-Fix-calling-convention-mismatch-for-runtime-f.patch b/schemes/release-5.10/swift/0011-stdlib-Fix-calling-convention-mismatch-for-runtime-f.patch deleted file mode 100644 index 77d11090..00000000 --- a/schemes/release-5.10/swift/0011-stdlib-Fix-calling-convention-mismatch-for-runtime-f.patch +++ /dev/null @@ -1,161 +0,0 @@ -From 0fbd2f2c680ec6e61f33fc2dcc59475f089c5f2b Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 08:44:04 +0000 -Subject: [PATCH] [stdlib] Fix calling convention mismatch for runtime function - tracking - -Runtime function tracking APIs are defined with the C calling convention -but they are called from Swift through `@_silgen_name`, so they are -called with the Swift calling convention. This patch fixes the mismatch -by adding `SWIFT_CC(swift)` to the definitions, but ideally we should be -able to call these APIs with the C calling convention with `@_cdecl`. -`@cdecl` without body is not supported yet but discussed in -https://forums.swift.org/t/formalizing-cdecl/40677 ---- - .../runtime/RuntimeInvocationsTracking.cpp | 16 +++++++++------- - .../runtime/RuntimeInvocationsTracking.h | 18 +++++++++--------- - 2 files changed, 18 insertions(+), 16 deletions(-) - -diff --git a/stdlib/public/runtime/RuntimeInvocationsTracking.cpp b/stdlib/public/runtime/RuntimeInvocationsTracking.cpp -index bf5812b4ba1..51a9ab16b11 100644 ---- a/stdlib/public/runtime/RuntimeInvocationsTracking.cpp -+++ b/stdlib/public/runtime/RuntimeInvocationsTracking.cpp -@@ -130,7 +130,7 @@ static std::uint16_t RuntimeFunctionCountersOffsets[] = { - /// Public APIs - - /// Get the runtime object state associated with an object. --void _swift_getObjectRuntimeFunctionCounters( -+SWIFT_CC(swift) void _swift_getObjectRuntimeFunctionCounters( - HeapObject *object, RuntimeFunctionCountersState *result) { - auto &theSentinel = RuntimeObjectStateCache.get(); - Mutex::ScopedLock lock(theSentinel.Lock); -@@ -139,7 +139,7 @@ void _swift_getObjectRuntimeFunctionCounters( - - /// Set the runtime object state associated with an object from a provided - /// state. --void _swift_setObjectRuntimeFunctionCounters( -+SWIFT_CC(swift) void _swift_setObjectRuntimeFunctionCounters( - HeapObject *object, RuntimeFunctionCountersState *state) { - auto &theSentinel = RuntimeObjectStateCache.get(); - Mutex::ScopedLock lock(theSentinel.Lock); -@@ -148,14 +148,14 @@ void _swift_setObjectRuntimeFunctionCounters( - - /// Get the global runtime state containing the total numbers of invocations for - /// each runtime function of interest. --void _swift_getGlobalRuntimeFunctionCounters( -+SWIFT_CC(swift) void _swift_getGlobalRuntimeFunctionCounters( - RuntimeFunctionCountersState *result) { - LazyMutex::ScopedLock lock(RuntimeGlobalFunctionCountersState.Lock); - *result = RuntimeGlobalFunctionCountersState.State; - } - - /// Set the global runtime state of function pointers from a provided state. --void _swift_setGlobalRuntimeFunctionCounters( -+SWIFT_CC(swift) void _swift_setGlobalRuntimeFunctionCounters( - RuntimeFunctionCountersState *state) { - LazyMutex::ScopedLock lock(RuntimeGlobalFunctionCountersState.Lock); - RuntimeGlobalFunctionCountersState.State = *state; -@@ -164,18 +164,20 @@ void _swift_setGlobalRuntimeFunctionCounters( - /// Return the names of the runtime functions being tracked. - /// Their order is the same as the order of the counters in the - /// RuntimeObjectState structure. All these strings are null terminated. --const char **_swift_getRuntimeFunctionNames() { -+SWIFT_CC(swift) const char **_swift_getRuntimeFunctionNames() { - return RuntimeFunctionNames; - } - - /// Return the offsets of the runtime function counters being tracked. - /// Their order is the same as the order of the counters in the - /// RuntimeObjectState structure. -+SWIFT_CC(swift) - const std::uint16_t *_swift_getRuntimeFunctionCountersOffsets() { - return RuntimeFunctionCountersOffsets; - } - - /// Return the number of runtime functions being tracked. -+SWIFT_CC(swift) - std::uint64_t _swift_getNumRuntimeFunctionCounters() { - return ID_LastRuntimeFunctionName; - } -@@ -204,7 +206,7 @@ void _swift_dumpObjectsRuntimeFunctionPointers() { - - /// Set mode for global runtime function counters. - /// Return the old value of this flag. --int _swift_setGlobalRuntimeFunctionCountersMode(int mode) { -+SWIFT_CC(swift) int _swift_setGlobalRuntimeFunctionCountersMode(int mode) { - int oldMode = UpdateGlobalRuntimeFunctionCounters; - UpdateGlobalRuntimeFunctionCounters = mode ? 1 : 0; - return oldMode; -@@ -212,7 +214,7 @@ int _swift_setGlobalRuntimeFunctionCountersMode(int mode) { - - /// Set mode for per object runtime function counters. - /// Return the old value of this flag. --int _swift_setPerObjectRuntimeFunctionCountersMode(int mode) { -+SWIFT_CC(swift) int _swift_setPerObjectRuntimeFunctionCountersMode(int mode) { - int oldMode = UpdatePerObjectRuntimeFunctionCounters; - UpdatePerObjectRuntimeFunctionCounters = mode ? 1 : 0; - return oldMode; -diff --git a/stdlib/public/runtime/RuntimeInvocationsTracking.h b/stdlib/public/runtime/RuntimeInvocationsTracking.h -index 74d60917656..3005df2b79c 100644 ---- a/stdlib/public/runtime/RuntimeInvocationsTracking.h -+++ b/stdlib/public/runtime/RuntimeInvocationsTracking.h -@@ -61,47 +61,47 @@ using RuntimeFunctionCountersUpdateHandler = - - /// Get the runtime object state associated with an object and store it - /// into the result. --SWIFT_RUNTIME_EXPORT void -+SWIFT_CC(swift) SWIFT_RUNTIME_EXPORT void - _swift_getObjectRuntimeFunctionCounters(HeapObject *object, - RuntimeFunctionCountersState *result); - - /// Get the global runtime state containing the total numbers of invocations for - /// each runtime function of interest and store it into the result. --SWIFT_RUNTIME_EXPORT void _swift_getGlobalRuntimeFunctionCounters( -+SWIFT_CC(swift) SWIFT_RUNTIME_EXPORT void _swift_getGlobalRuntimeFunctionCounters( - swift::RuntimeFunctionCountersState *result); - - /// Return the names of the runtime functions being tracked. - /// Their order is the same as the order of the counters in the - /// RuntimeObjectState structure. --SWIFT_RUNTIME_EXPORT const char **_swift_getRuntimeFunctionNames(); -+SWIFT_CC(swift) SWIFT_RUNTIME_EXPORT const char **_swift_getRuntimeFunctionNames(); - - /// Return the offsets of the runtime function counters being tracked. - /// Their order is the same as the order of the counters in the - /// RuntimeFunctionCountersState structure. --SWIFT_RUNTIME_EXPORT const uint16_t *_swift_getRuntimeFunctionCountersOffsets(); -+SWIFT_CC(swift) SWIFT_RUNTIME_EXPORT const uint16_t *_swift_getRuntimeFunctionCountersOffsets(); - - /// Return the number of runtime functions being tracked. --SWIFT_RUNTIME_EXPORT uint64_t _swift_getNumRuntimeFunctionCounters(); -+SWIFT_CC(swift) SWIFT_RUNTIME_EXPORT uint64_t _swift_getNumRuntimeFunctionCounters(); - - /// Dump all per-object runtime function pointers. - SWIFT_RUNTIME_EXPORT void _swift_dumpObjectsRuntimeFunctionPointers(); - - /// Set mode for global runtime function counters. - /// Return the old value of this flag. --SWIFT_RUNTIME_EXPORT int -+SWIFT_CC(swift) SWIFT_RUNTIME_EXPORT int - _swift_setPerObjectRuntimeFunctionCountersMode(int mode); - - /// Set mode for per object runtime function counters. - /// Return the old value of this flag. --SWIFT_RUNTIME_EXPORT int _swift_setGlobalRuntimeFunctionCountersMode(int mode); -+SWIFT_CC(swift) SWIFT_RUNTIME_EXPORT int _swift_setGlobalRuntimeFunctionCountersMode(int mode); - - /// Set the global runtime state of function pointers from a provided state. --SWIFT_RUNTIME_EXPORT void _swift_setGlobalRuntimeFunctionCounters( -+SWIFT_CC(swift) SWIFT_RUNTIME_EXPORT void _swift_setGlobalRuntimeFunctionCounters( - swift::RuntimeFunctionCountersState *state); - - /// Set the runtime object state associated with an object from a provided - /// state. --SWIFT_RUNTIME_EXPORT void -+SWIFT_CC(swift) SWIFT_RUNTIME_EXPORT void - _swift_setObjectRuntimeFunctionCounters(HeapObject *object, - RuntimeFunctionCountersState *state); - --- -2.40.0 - diff --git a/schemes/release-5.10/swift/0012-wasm-stdlib-HACK-Workaround-for-the-bad-stacksave-co.patch b/schemes/release-5.10/swift/0012-wasm-stdlib-HACK-Workaround-for-the-bad-stacksave-co.patch deleted file mode 100644 index 2f232284..00000000 --- a/schemes/release-5.10/swift/0012-wasm-stdlib-HACK-Workaround-for-the-bad-stacksave-co.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 23bcb6fe2c629e82d9fc4f66b25fe99fc8851207 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Wed, 19 Apr 2023 13:14:46 +0000 -Subject: [PATCH] [wasm][stdlib] HACK: Workaround for the bad stacksave codegen - in LLVM - -The LLVM backend generates bad code for some code using `llvm.stacksave` -intrinsics. This patch works around the issue by avoiding such code -generation. See https://github.com/llvm/llvm-project/issues/62235 ---- - stdlib/public/core/ValidUTF8Buffer.swift | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/stdlib/public/core/ValidUTF8Buffer.swift b/stdlib/public/core/ValidUTF8Buffer.swift -index 38799a2a86a..7dd7ca38bee 100644 ---- a/stdlib/public/core/ValidUTF8Buffer.swift -+++ b/stdlib/public/core/ValidUTF8Buffer.swift -@@ -127,7 +127,10 @@ extension _ValidUTF8Buffer: RandomAccessCollection { - @inlinable - @inline(__always) - public func distance(from i: Index, to j: Index) -> Int { -- _debugPrecondition(_isValid(i)) -+ // FIXME(katei): The precondition check is commented out because it -+ // causes bad codegen for `stacksave` on WebAssembly. -+ // See https://github.com/llvm/llvm-project/issues/62235 -+ // _debugPrecondition(_isValid(i)) - _debugPrecondition(_isValid(j)) - return ( - i._biasedBits.leadingZeroBitCount - j._biasedBits.leadingZeroBitCount --- -2.40.0 - diff --git a/schemes/release-5.10/swift/0013-wasm-test-HACK-Disable-os_stdlib-tests-due-to-no-dyn.patch b/schemes/release-5.10/swift/0013-wasm-test-HACK-Disable-os_stdlib-tests-due-to-no-dyn.patch deleted file mode 100644 index 16a9d5c0..00000000 --- a/schemes/release-5.10/swift/0013-wasm-test-HACK-Disable-os_stdlib-tests-due-to-no-dyn.patch +++ /dev/null @@ -1,26 +0,0 @@ -From be417141009e42c3191a715465c4f60d48a18860 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 09:27:38 +0000 -Subject: [PATCH] [wasm][test] HACK: Disable os_stdlib tests due to no dynamic - loading - ---- - test/lit.cfg | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/test/lit.cfg b/test/lit.cfg -index acc64536990..90a25334f7d 100644 ---- a/test/lit.cfg -+++ b/test/lit.cfg -@@ -2281,7 +2281,7 @@ if run_vendor != 'apple': - - if 'remote_run_host' in lit_config.params: - configure_remote_run() --elif not kIsWindows: -+elif not kIsWindows and not run_os == 'wasi': - if 'use_os_stdlib' in lit_config.params: - config.available_features.add('use_os_stdlib') - --- -2.40.0 - diff --git a/schemes/release-5.10/swift/0014-wasm-test-HACK-Disable-PrintStruct.swift-test-for-un.patch b/schemes/release-5.10/swift/0014-wasm-test-HACK-Disable-PrintStruct.swift-test-for-un.patch deleted file mode 100644 index 3ad9a93e..00000000 --- a/schemes/release-5.10/swift/0014-wasm-test-HACK-Disable-PrintStruct.swift-test-for-un.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 838b7c756c3d2e1329528cc9b6fc4a8be2effb4e Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 09:40:00 +0000 -Subject: [PATCH] [wasm][test] HACK: Disable PrintStruct.swift test for unclear - reason - ---- - test/stdlib/PrintStruct.swift | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/test/stdlib/PrintStruct.swift b/test/stdlib/PrintStruct.swift -index 9ecac235539..b616e61f517 100644 ---- a/test/stdlib/PrintStruct.swift -+++ b/test/stdlib/PrintStruct.swift -@@ -4,7 +4,10 @@ - // RUN: %target-codesign %t/main - // RUN: %target-run %t/main - // REQUIRES: executable_test --// REQUIRES: reflection -+// -+// FIXME Disable this case because this failed on only CI. -+// Failed with 'Caught exception of type "CallIndirectOOB"' -+// UNSUPPORTED: CPU=wasm32 - - import StdlibUnittest - import PrintTestTypes --- -2.40.0 - diff --git a/schemes/release-5.10/swift/0015-wasm-stdlib-HACK-Add-pthread-stub-to-avoid-linking-e.patch b/schemes/release-5.10/swift/0015-wasm-stdlib-HACK-Add-pthread-stub-to-avoid-linking-e.patch deleted file mode 100644 index 302bb663..00000000 --- a/schemes/release-5.10/swift/0015-wasm-stdlib-HACK-Add-pthread-stub-to-avoid-linking-e.patch +++ /dev/null @@ -1,215 +0,0 @@ -From da933f595b3699de354421242bb3c15671786299 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 09:45:10 +0000 -Subject: [PATCH] [wasm][stdlib] HACK: Add pthread stub to avoid linking error - -This is a hack to avoid missing pthread symbols error when linking. But -we now have `SWIFT_STDLIB_SINGLE_THREADED_RUNTIME` mode so the hack should -not be necessary anymore. ---- - stdlib/public/CMakeLists.txt | 4 + - .../Resources/wasi/static-executable-args.lnk | 1 + - stdlib/public/WASI/CMakeLists.txt | 4 + - stdlib/public/WASI/Pthread.cpp | 153 ++++++++++++++++++ - 4 files changed, 162 insertions(+) - create mode 100644 stdlib/public/WASI/CMakeLists.txt - create mode 100644 stdlib/public/WASI/Pthread.cpp - -diff --git a/stdlib/public/CMakeLists.txt b/stdlib/public/CMakeLists.txt -index a080c874711..6c6883a6475 100644 ---- a/stdlib/public/CMakeLists.txt -+++ b/stdlib/public/CMakeLists.txt -@@ -142,6 +142,10 @@ if(SWIFT_BUILD_STDLIB) - add_subdirectory(core) - add_subdirectory(SwiftOnoneSupport) - -+ if(WASI IN_LIST SWIFT_SDKS) -+ add_subdirectory(WASI) -+ endif() -+ - if(SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING) - add_subdirectory(Differentiation) - endif() -diff --git a/stdlib/public/Resources/wasi/static-executable-args.lnk b/stdlib/public/Resources/wasi/static-executable-args.lnk -index 1500f94f891..a18d5fc3668 100644 ---- a/stdlib/public/Resources/wasi/static-executable-args.lnk -+++ b/stdlib/public/Resources/wasi/static-executable-args.lnk -@@ -1,5 +1,6 @@ - -static - -lswiftSwiftOnoneSupport -+-lswiftWasiPthread - -ldl - -lstdc++ - -lm -diff --git a/stdlib/public/WASI/CMakeLists.txt b/stdlib/public/WASI/CMakeLists.txt -new file mode 100644 -index 00000000000..0d088443ad7 ---- /dev/null -+++ b/stdlib/public/WASI/CMakeLists.txt -@@ -0,0 +1,4 @@ -+add_swift_target_library(swiftWasiPthread STATIC IS_STDLIB -+ Pthread.cpp -+ TARGET_SDKS WASI -+ INSTALL_IN_COMPONENT stdlib) -diff --git a/stdlib/public/WASI/Pthread.cpp b/stdlib/public/WASI/Pthread.cpp -new file mode 100644 -index 00000000000..5a64d9bdb4c ---- /dev/null -+++ b/stdlib/public/WASI/Pthread.cpp -@@ -0,0 +1,153 @@ -+// SPDX-License-Identifier: 0BSD -+// prototypes taken from opengroup -+#include -+#include -+#include -+#include -+ -+#define STUB() do {fprintf(stderr, "FakePthread: unsupported %s\n", __func__);abort();}while(0) -+ -+// mutexes: just no-ops -+ -+int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) { -+ return 0; -+} -+ -+int pthread_mutex_destroy(pthread_mutex_t *mutex) { -+ return 0; -+} -+ -+int pthread_mutexattr_init(pthread_mutexattr_t *attr) { -+ return 0; -+} -+ -+int pthread_mutexattr_destroy(pthread_mutexattr_t *attr) { -+ return 0; -+} -+ -+int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type) { -+ return 0; -+} -+ -+int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) { -+ return 0; -+} -+ -+int pthread_mutex_lock(pthread_mutex_t *mutex) { -+ return 0; -+} -+ -+int pthread_mutex_trylock(pthread_mutex_t *mutex) { -+ return 0; -+} -+ -+int pthread_mutex_unlock(pthread_mutex_t *mutex) { -+ return 0; -+} -+ -+// pthread_cond: STUB -+ -+int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) { -+ return 0; -+} -+ -+int pthread_cond_destroy(pthread_cond_t *cond) { -+ return 0; -+} -+ -+int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) { -+ STUB(); -+} -+ -+int pthread_cond_timedwait(pthread_cond_t *cond, -+ pthread_mutex_t *mutex, const struct timespec *abstime) { -+ STUB(); -+} -+ -+int pthread_cond_broadcast(pthread_cond_t *cond) { -+ return 0; -+} -+ -+int pthread_cond_signal(pthread_cond_t *cond) { -+ return 0; -+} -+ -+// tls -+ -+int pthread_key_create(pthread_key_t *key, void (*destructor)(void*)) { -+ STUB(); -+} -+ -+void *pthread_getspecific(pthread_key_t key) { -+ STUB(); -+} -+ -+int pthread_setspecific(pthread_key_t key, const void *value) { -+ STUB(); -+} -+ -+// threads -+ -+pthread_t pthread_self() { -+ return (pthread_t)1234; -+} -+ -+#undef pthread_equal -+ -+int pthread_equal(pthread_t t1, pthread_t t2) { -+ return t1 == t2; -+} -+ -+int pthread_join(pthread_t thread, void **value_ptr) { -+ STUB(); -+} -+ -+int pthread_detach(pthread_t thread) { -+ STUB(); -+} -+ -+int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg) { -+ return 0; -+} -+ -+// once -+ -+int pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) { -+ STUB(); -+} -+ -+// rwlock -+ -+int pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) { -+ return 0; -+} -+ -+int pthread_rwlock_destroy(pthread_rwlock_t *rwlock) { -+ return 0; -+} -+ -+int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock) { -+ return 0; -+} -+ -+int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock) { -+ return 0; -+} -+ -+int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock) { -+ return 0; -+} -+ -+int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock) { -+ return 0; -+} -+ -+int pthread_rwlock_unlock(pthread_rwlock_t *rwlock) { -+ return 0; -+} -+ -+// named semaphores -+ -+sem_t *sem_open(const char *name, int oflag, ...) { -+ STUB(); -+} --- -2.40.0 - diff --git a/schemes/release-5.10/swift/0016-wasm-build-HACK-Add-SwiftWasm-compiler-vendor-suppor.patch b/schemes/release-5.10/swift/0016-wasm-build-HACK-Add-SwiftWasm-compiler-vendor-suppor.patch deleted file mode 100644 index 5b7e373b..00000000 --- a/schemes/release-5.10/swift/0016-wasm-build-HACK-Add-SwiftWasm-compiler-vendor-suppor.patch +++ /dev/null @@ -1,78 +0,0 @@ -From 9fda3abde7289e2a5dd3801443ac90c0f8d95aa6 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 09:51:29 +0000 -Subject: [PATCH] [wasm][build] HACK: Add SwiftWasm compiler vendor support - -This patch should not be upstreamed. Maybe we can use -`--compiler-vendor=none` to avoid hardcoding specific downstream names. ---- - .../build_swift/build_swift/driver_arguments.py | 2 +- - .../swift_build_support/products/llvm.py | 7 +++++++ - .../swift_build_support/products/swift.py | 16 ++++++++++++---- - 3 files changed, 20 insertions(+), 5 deletions(-) - -diff --git a/utils/build_swift/build_swift/driver_arguments.py b/utils/build_swift/build_swift/driver_arguments.py -index 28bc9a9c3b5..e0546d03625 100644 ---- a/utils/build_swift/build_swift/driver_arguments.py -+++ b/utils/build_swift/build_swift/driver_arguments.py -@@ -459,7 +459,7 @@ def create_argument_parser(): - help='if set, provide a fixed path for the Swift backtracer') - - option('--compiler-vendor', store, -- choices=['none', 'apple'], -+ choices=['none', 'apple', 'swiftwasm'], - default=defaults.COMPILER_VENDOR, - help='Compiler vendor name') - option('--clang-compiler-version', store, -diff --git a/utils/swift_build_support/swift_build_support/products/llvm.py b/utils/swift_build_support/swift_build_support/products/llvm.py -index c0011248316..f38040ae21a 100644 ---- a/utils/swift_build_support/swift_build_support/products/llvm.py -+++ b/utils/swift_build_support/swift_build_support/products/llvm.py -@@ -64,6 +64,13 @@ class LLVM(cmake_product.CMakeProduct): - if self.args.compiler_vendor == "none": - return [] - -+ if self.args.compiler_vendor == "swiftwasm": -+ return [ -+ ('CLANG_VENDOR', 'SwiftWasm'), -+ ('CLANG_VENDOR_UTI', 'org.swiftwasm.compilers.llvm.clang'), -+ ('PACKAGE_VERSION', str(self.args.clang_user_visible_version)) -+ ] -+ - if self.args.compiler_vendor != "apple": - raise RuntimeError("Unknown compiler vendor?!") - -diff --git a/utils/swift_build_support/swift_build_support/products/swift.py b/utils/swift_build_support/swift_build_support/products/swift.py -index de6843b06a1..2e8d1caf41f 100644 ---- a/utils/swift_build_support/swift_build_support/products/swift.py -+++ b/utils/swift_build_support/swift_build_support/products/swift.py -@@ -104,14 +104,22 @@ class Swift(product.Product): - if self.args.compiler_vendor == "none": - return [] - -- if self.args.compiler_vendor != "apple": -- raise RuntimeError("Unknown compiler vendor?! Was build-script \ --updated without updating swift.py?") -- - swift_compiler_version = "" - if self.args.swift_compiler_version is not None: - swift_compiler_version = self.args.swift_compiler_version - -+ if self.args.compiler_vendor == "swiftwasm": -+ return [ -+ ('SWIFT_VENDOR', 'SwiftWasm'), -+ ('SWIFT_VENDOR_UTI', 'org.swiftwasm.compilers.llvm.swift'), -+ ('SWIFT_VERSION', str(self.args.swift_user_visible_version)), -+ ('SWIFT_COMPILER_VERSION', str(swift_compiler_version)), -+ ] -+ -+ if self.args.compiler_vendor != "apple": -+ raise RuntimeError("Unknown compiler vendor?! Was build-script \ -+updated without updating swift.py?") -+ - return [ - ('SWIFT_VENDOR', 'Apple'), - ('SWIFT_VENDOR_UTI', 'com.apple.compilers.llvm.swift'), --- -2.40.0 - diff --git a/schemes/release-5.10/swift/0017-installer-Do-not-follow-an-existing-symbolic-link-wh.patch b/schemes/release-5.10/swift/0017-installer-Do-not-follow-an-existing-symbolic-link-wh.patch deleted file mode 100644 index c90aece3..00000000 --- a/schemes/release-5.10/swift/0017-installer-Do-not-follow-an-existing-symbolic-link-wh.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 6b97b2d581ab626fa95faab5b67ec204a46ea4cb Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 24 Nov 2020 13:16:58 +0900 -Subject: [PATCH] [installer] Do not follow an existing symbolic link when - overwriting -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Without `-h` option, `ln` command makes a symbolic link under the existing -link destination like `Toolchains/swift-DEVELOPMENT-SNAPSHOT-XX.xctoolchain/`. - -``` -$ ln -fs swift-DEVELOPMENT-SNAPSHOT-XX.xctoolchain swift-latest.xctoolchain -$ ln -fs swift-DEVELOPMENT-SNAPSHOT-YY.xctoolchain swift-latest.xctoolchain -$ tree -|-- swift-DEVELOPMENT-SNAPSHOT-XX.xctoolchain -|   |-- swift-DEVELOPMENT-SNAPSHOT-YY.xctoolchain -> swift-DEVELOPMENT-SNAPSHOT-YY.xctoolchain -|-- swift-DEVELOPMENT-SNAPSHOT-YY.xctoolchain -|-- swift-latest.xctoolchain -> swift-DEVELOPMENT-SNAPSHOT-XX.xctoolchain -``` - -So we should not follow the existing symbolic link even if it already -exists. ---- - utils/darwin-installer-scripts/postinstall | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/utils/darwin-installer-scripts/postinstall b/utils/darwin-installer-scripts/postinstall -index 8f00806645e..e9750f04e95 100755 ---- a/utils/darwin-installer-scripts/postinstall -+++ b/utils/darwin-installer-scripts/postinstall -@@ -13,4 +13,4 @@ - - INSTALLED_TOOLCHAIN=$2 - --ln -fs "${INSTALLED_TOOLCHAIN}" "${INSTALLED_TOOLCHAIN%/*}/swift-latest.xctoolchain" -+ln -fhs "${INSTALLED_TOOLCHAIN}" "${INSTALLED_TOOLCHAIN%/*}/swift-latest.xctoolchain" --- -2.40.0 - diff --git a/schemes/release-5.10/swift/0018-stdlib-Fix-calling-convention-mismatch-for-debugger-.patch b/schemes/release-5.10/swift/0018-stdlib-Fix-calling-convention-mismatch-for-debugger-.patch deleted file mode 100644 index aa337f3e..00000000 --- a/schemes/release-5.10/swift/0018-stdlib-Fix-calling-convention-mismatch-for-debugger-.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 9bfdb13784bbe36f2b616dbef4a8d16882715fb9 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Fri, 9 Jun 2023 16:23:39 +0000 -Subject: [PATCH] [stdlib] Fix calling convention mismatch for debugger utility - functions - -The functions `swift_retainCount`, `swift_unownedRetainCount`, and -`swift_weakRetainCount` are declared in `HeapObject.h` as using -the C calling convention, but the Swift declarations referenced them -by `@_silgen_name`, which uses the Swift calling convention. This -patch fixes the mismatch without any ABI/API breakage by calling the -utility functions through C interop. ---- - stdlib/public/core/DebuggerSupport.swift | 15 +++++++++------ - 1 file changed, 9 insertions(+), 6 deletions(-) - -diff --git a/stdlib/public/core/DebuggerSupport.swift b/stdlib/public/core/DebuggerSupport.swift -index ef9eafeab81..c8c77d26400 100644 ---- a/stdlib/public/core/DebuggerSupport.swift -+++ b/stdlib/public/core/DebuggerSupport.swift -@@ -269,9 +269,12 @@ public func _stringForPrintObject(_ value: Any) -> String { - public func _debuggerTestingCheckExpect(_: String, _: String) { } - - // Utilities to get refcount(s) of class objects. --@_silgen_name("swift_retainCount") --public func _getRetainCount(_ Value: AnyObject) -> UInt --@_silgen_name("swift_unownedRetainCount") --public func _getUnownedRetainCount(_ Value: AnyObject) -> UInt --@_silgen_name("swift_weakRetainCount") --public func _getWeakRetainCount(_ Value: AnyObject) -> UInt -+public func _getRetainCount(_ Value: AnyObject) -> UInt { -+ return UInt(swift_retainCount(unsafeBitCast(Value, to: UnsafeMutablePointer.self))) -+} -+public func _getUnownedRetainCount(_ Value: AnyObject) -> UInt { -+ return UInt(swift_unownedRetainCount(unsafeBitCast(Value, to: UnsafeMutablePointer.self))) -+} -+public func _getWeakRetainCount(_ Value: AnyObject) -> UInt { -+ return UInt(swift_weakRetainCount(unsafeBitCast(Value, to: UnsafeMutablePointer.self))) -+} --- -2.40.0 - diff --git a/schemes/release-5.10/swift/0019-lit-Repair-tests-for-stdlib-only-build.patch b/schemes/release-5.10/swift/0019-lit-Repair-tests-for-stdlib-only-build.patch deleted file mode 100644 index f30d2597..00000000 --- a/schemes/release-5.10/swift/0019-lit-Repair-tests-for-stdlib-only-build.patch +++ /dev/null @@ -1,41 +0,0 @@ -From b42bf448f82ff197b742f7d85a4e15dba72037e7 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Sun, 29 Oct 2023 23:27:31 +0000 -Subject: [PATCH] [lit] Repair tests for stdlib-only build - -`config.host_triple` can be None when no host tools are built - -This is based on 21d57e887ad1f2d319b8e89af90d2732d50ecf55 in main branch ---- - test/lit.cfg | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -diff --git a/test/lit.cfg b/test/lit.cfg -index 8a955f0da88..c989777dfd5 100644 ---- a/test/lit.cfg -+++ b/test/lit.cfg -@@ -566,8 +566,10 @@ else: - ) - ) - # Parse the host triple. -- (host_cpu, host_vendor, host_os, host_vers) = re.match('([^-]+)-([^-]+)-([^0-9-]+)(.*)', config.host_triple).groups() -- toolchain_lib_dir = make_path(config.swift_lib_dir, 'swift', host_os) -+ toolchain_lib_dir = None -+ if config.host_triple: -+ (host_cpu, host_vendor, host_os, host_vers) = re.match('([^-]+)-([^-]+)-([^0-9-]+)(.*)', config.host_triple).groups() -+ toolchain_lib_dir = make_path(config.swift_lib_dir, 'swift', host_os) - config.host_build_swift = ( - "%s -target %s -g %s -I %s -L %s %s" % ( - config.swiftc_driver, -@@ -575,7 +577,7 @@ else: - '' if kIsWindows else '-no-toolchain-stdlib-rpath', - config.swift_build_lib_dir, - config.swift_build_lib_dir, -- '' if kIsWindows else '-Xlinker -rpath -Xlinker {}'.format(toolchain_lib_dir) -+ '' if kIsWindows or toolchain_lib_dir is None else '-Xlinker -rpath -Xlinker {}'.format(toolchain_lib_dir) - ) - ) - --- -2.40.0 - diff --git a/schemes/release-5.9/build/build-target-toolchain.sh b/schemes/release-5.9/build/build-target-toolchain.sh deleted file mode 100755 index b71e3caf..00000000 --- a/schemes/release-5.9/build/build-target-toolchain.sh +++ /dev/null @@ -1,205 +0,0 @@ -#!/bin/bash -# -# Build the Swift standard library. - -set -euo pipefail -set -x - -print_help() { - echo "Usage: $0 [options]" - echo "" - echo "Options:" - echo " --help Display this help message." - echo " --llvm-bin Path to LLVM bin directory." - echo " --swift-bin Path to Swift bin directory." -} - -SCHEMES_BUILD_PATH="$(cd "$(dirname "$0")" && pwd)" -SOURCE_PATH="$(cd "$(dirname "$0")/../../../.." && pwd)" -TOOLS_BUILD_PATH="$(cd "$(dirname "$0")/../../../tools/build" && pwd)" -TARGET_BUILD_ROOT=$SOURCE_PATH/build/WebAssembly -PACKAGING_DIR="$SOURCE_PATH/build/Packaging" -TARGET_TOOLCHAIN_DESTDIR=$PACKAGING_DIR/target-toolchain/wasm32-unknown-wasi -BUILD_SDK_PATH="$SOURCE_PATH/build-sdk" -WASI_SYSROOT_PATH="$BUILD_SDK_PATH/wasi-sysroot" - -build_target_toolchain() { - - local LLVM_BIN_DIR="$1" - local CLANG_BIN_DIR="$2" - local SWIFT_BIN_DIR="$3" - local SCHEME="$4" - - local COMPILER_RT_BUILD_DIR="$TARGET_BUILD_ROOT/compiler-rt-wasi-wasm32" - local CLANG_VERSION - CLANG_VERSION="$(basename "$($CLANG_BIN_DIR/clang -print-resource-dir)")" - - cmake -B "$COMPILER_RT_BUILD_DIR" \ - -D CMAKE_TOOLCHAIN_FILE="$TOOLS_BUILD_PATH/compiler-rt-cache.cmake" \ - -D CMAKE_BUILD_TYPE=Release \ - -D CMAKE_C_COMPILER="$CLANG_BIN_DIR/clang" \ - -D CMAKE_CXX_COMPILER="$CLANG_BIN_DIR/clang++" \ - -D CMAKE_RANLIB="$LLVM_BIN_DIR/llvm-ranlib" \ - -D CMAKE_AR="$LLVM_BIN_DIR/llvm-ar" \ - -D CMAKE_C_COMPILER_LAUNCHER="$(which sccache)" \ - -D CMAKE_CXX_COMPILER_LAUNCHER="$(which sccache)" \ - -D CMAKE_INSTALL_PREFIX="$TARGET_TOOLCHAIN_DESTDIR/usr/lib/clang/$CLANG_VERSION/" \ - -D CMAKE_SYSROOT="${WASI_SYSROOT_PATH}" \ - -G Ninja \ - -S "$SOURCE_PATH/llvm-project/compiler-rt" - - ninja install -C "$COMPILER_RT_BUILD_DIR" - - local LLVM_TARGET_BUILD_DIR - - if [ -f "$SOURCE_PATH/build/llvm-tools/CMakeCache.txt" ]; then - LLVM_TARGET_BUILD_DIR="$SOURCE_PATH/build/llvm-tools" - else - LLVM_TARGET_BUILD_DIR="$TARGET_BUILD_ROOT/llvm-wasi-wasm32" - if [ ! -f "$LLVM_TARGET_BUILD_DIR/CMakeCache.txt" ]; then - # Only configure LLVM to use CMake functionalities in LLVM - cmake -B "$LLVM_TARGET_BUILD_DIR" \ - -D CMAKE_BUILD_TYPE=Release \ - -D LLVM_ENABLE_ZLIB=NO \ - -D LLVM_ENABLE_LIBXML2=NO \ - -D CMAKE_C_COMPILER="$CLANG_BIN_DIR/clang" \ - -D CMAKE_CXX_COMPILER="$CLANG_BIN_DIR/clang++" \ - -G Ninja \ - -S "$SOURCE_PATH/llvm-project/llvm" - fi - fi - - local SWIFT_STDLIB_BUILD_DIR="$TARGET_BUILD_ROOT/swift-stdlib-wasi-wasm32" - - # FIXME(katei): Platform/WASI is not recognized as a platform in LLVM, so it reports - # "Unable to determine platform" while handling LLVM options. - # Set WASI as a UNIX platform to spoof LLVM - # FIXME(katei): host-build clang's libcxx is capable with LLVM, but it somehow - # fails libcxx version check. So activate LLVM_COMPILER_CHECKED to spoof the checker - # SWIFT_DRIVER_TEST_OPTIONS is used to specify clang resource dir for wasm32-unknown-wasi - # because it's not built beside clang - # TODO(katei): Move SWIFT_STDLIB_HAS_ASL and SWIFT_RUNTIME_CRASH_REPORTER_CLIENT - # to cmake/caches/Runtime-WASI-wasm32.cmake - cmake -B "$SWIFT_STDLIB_BUILD_DIR" \ - -C "$SOURCE_PATH/swift/cmake/caches/Runtime-WASI-wasm32.cmake" \ - -D CMAKE_BUILD_TYPE=Release \ - -D CMAKE_C_COMPILER_LAUNCHER="$(which sccache)" \ - -D CMAKE_CXX_COMPILER_LAUNCHER="$(which sccache)" \ - -D CMAKE_C_COMPILER="$CLANG_BIN_DIR/clang" \ - -D CMAKE_CXX_COMPILER="$CLANG_BIN_DIR/clang++" \ - -D CMAKE_RANLIB="$LLVM_BIN_DIR/llvm-ranlib" \ - -D CMAKE_AR="$LLVM_BIN_DIR/llvm-ar" \ - -D CMAKE_INSTALL_PREFIX="$TARGET_TOOLCHAIN_DESTDIR/usr" \ - -D LLVM_DIR="$LLVM_TARGET_BUILD_DIR/lib/cmake/llvm/" \ - -D LLVM_COMPILER_CHECKED=YES \ - -D UNIX=1 \ - -D SWIFT_NATIVE_SWIFT_TOOLS_PATH="$SWIFT_BIN_DIR" \ - -D SWIFT_NATIVE_CLANG_TOOLS_PATH="$CLANG_BIN_DIR" \ - -D SWIFT_NATIVE_LLVM_TOOLS_PATH="$LLVM_BIN_DIR" \ - -D SWIFT_LIT_TEST_PATHS="$SWIFT_STDLIB_BUILD_DIR/test-wasi-wasm32/stdlib;$SWIFT_STDLIB_BUILD_DIR/test-wasi-wasm32/Concurrency/Runtime" \ - -D SWIFT_DRIVER_TEST_OPTIONS=" -Xclang-linker -resource-dir -Xclang-linker $COMPILER_RT_BUILD_DIR" \ - -D SWIFT_WASI_SYSROOT_PATH="$WASI_SYSROOT_PATH" \ - -D SWIFT_WASI_wasm32_ICU_UC_INCLUDE="$BUILD_SDK_PATH/icu/include" \ - -D SWIFT_WASI_wasm32_ICU_UC="$BUILD_SDK_PATH/icu/lib/libicuuc.a" \ - -D SWIFT_WASI_wasm32_ICU_I18N_INCLUDE="$BUILD_SDK_PATH/icu/include" \ - -D SWIFT_WASI_wasm32_ICU_I18N="$BUILD_SDK_PATH/icu/lib/libicui18n.a" \ - -D SWIFT_WASI_wasm32_ICU_DATA="$BUILD_SDK_PATH/icu/lib/libicudata.a" \ - -D SWIFT_ENABLE_DISPATCH=NO \ - -D SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING=YES \ - -D SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED=YES \ - -D SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING=YES \ - -D SWIFT_ENABLE_EXPERIMENTAL_REFLECTION=YES \ - -D SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP=YES \ - -D SWIFT_PRIMARY_VARIANT_SDK=WASI \ - -D SWIFT_PRIMARY_VARIANT_ARCH=wasm32 \ - -D SWIFT_SDKS:STRING=WASI \ - -D SWIFT_STDLIB_HAS_ASL=NO \ - -D SWIFT_STDLIB_TRACING=NO \ - -D SWIFT_STDLIB_CONCURRENCY_TRACING=NO \ - -D SWIFT_RUNTIME_CRASH_REPORTER_CLIENT=NO \ - -D SWIFT_STDLIB_INSTALL_PARENT_MODULE_FOR_SHIMS=NO \ - -D SWIFT_BUILD_DYNAMIC_SDK_OVERLAY=NO \ - -D SWIFT_BUILD_STATIC_SDK_OVERLAY=NO \ - -D SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE="$SOURCE_PATH/swift-syntax" \ - -D SWIFT_PATH_TO_STRING_PROCESSING_SOURCE="$SOURCE_PATH/swift-experimental-string-processing" \ - -G Ninja \ - -S "$SOURCE_PATH/swift" - - # FIXME(katei): 'sdk-overlay' is explicitly used to build libcxxshim.modulemap - # which is used only in tests, so 'ninja install' doesn't build it - # the header and modulemap custom targets should be added as dependency of install - ninja sdk-overlay install -C "$SWIFT_STDLIB_BUILD_DIR" - - # Remove host CoreFoundation module directory to avoid module conflict - # while building Foundation - rm -rf "$TARGET_TOOLCHAIN_DESTDIR/usr/lib/swift_static/CoreFoundation" - - ln -fs "../../../clang/$CLANG_VERSION/lib/wasi" "$TARGET_TOOLCHAIN_DESTDIR/usr/lib/swift/clang/lib/wasi" - ln -fs "../../../clang/$CLANG_VERSION/lib/wasi" "$TARGET_TOOLCHAIN_DESTDIR/usr/lib/swift_static/clang/lib/wasi" - - local CORELIBS_ARGS=( - "$TARGET_TOOLCHAIN_DESTDIR" - "$LLVM_BIN_DIR" - "$CLANG_BIN_DIR" - "$SWIFT_BIN_DIR" - "$WASI_SYSROOT_PATH" - ) - "$TOOLS_BUILD_PATH/build-foundation.sh" "${CORELIBS_ARGS[@]}" - "$SCHEMES_BUILD_PATH/build-xctest.sh" "${CORELIBS_ARGS[@]}" -} - -main() { - local OPTIONS_LLVM_BIN="" - local OPTIONS_CLANG_BIN="" - local OPTIONS_SWIFT_BIN="" - - while [[ $# -gt 0 ]]; do - case "$1" in - --llvm-bin) - OPTIONS_LLVM_BIN="$2" - shift 2 - ;; - --clang-bin) - OPTIONS_CLANG_BIN="$2" - shift 2 - ;; - --swift-bin) - OPTIONS_SWIFT_BIN="$2" - shift 2 - ;; - --scheme) - OPTIONS_SCHEME="$2" - shift 2 - ;; - --help) - print_help - exit 0 - ;; - *) - echo "Unknown option: $1" - print_help - exit 1 - ;; - esac - done - - if [[ -z "$OPTIONS_LLVM_BIN" ]]; then - echo "Missing --llvm-bin option" - print_help - exit 1 - fi - - if [[ -z "$OPTIONS_SWIFT_BIN" ]]; then - echo "Missing --swift-bin option" - print_help - exit 1 - fi - - if [[ -z "$OPTIONS_CLANG_BIN" ]]; then - OPTIONS_CLANG_BIN="$OPTIONS_LLVM_BIN" - fi - - build_target_toolchain "$OPTIONS_LLVM_BIN" "$OPTIONS_CLANG_BIN" "$OPTIONS_SWIFT_BIN" "$OPTIONS_SCHEME" -} - -main "$@" diff --git a/schemes/release-5.9/build/build-xctest.sh b/schemes/release-5.9/build/build-xctest.sh deleted file mode 100755 index fdbedb58..00000000 --- a/schemes/release-5.9/build/build-xctest.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -set -ex -DESTINATION_TOOLCHAIN=$1 -LLVM_BIN_DIR=$2 -CLANG_BIN_DIR=$3 -SWIFT_BIN_DIR=$4 -WASI_SYSROOT_PATH=$5 - -SOURCE_PATH="$(cd "$(dirname $0)/../../../../" && pwd)" -TOOLS_BUILD_PATH="$(cd "$(dirname "$0")/../../../tools/build" && pwd)" - -BUILD_DIR="$SOURCE_PATH/build/WebAssembly/xctest-wasi-wasm32" - -mkdir -p $BUILD_DIR -cd $BUILD_DIR - -cmake -G Ninja \ - -DCMAKE_BUILD_TYPE="Release" \ - -DCMAKE_SYSROOT="$WASI_SYSROOT_PATH" \ - -DCMAKE_Swift_COMPILER="$SWIFT_BIN_DIR/swiftc" \ - -DCMAKE_TOOLCHAIN_FILE="$TOOLS_BUILD_PATH/toolchain-wasi.cmake" \ - -DLLVM_BIN="$LLVM_BIN_DIR" \ - -DCLANG_BIN="$CLANG_BIN_DIR" \ - -DBUILD_SHARED_LIBS=OFF \ - -DCMAKE_Swift_COMPILER_FORCED=ON \ - -DCMAKE_Swift_FLAGS="-resource-dir $DESTINATION_TOOLCHAIN/usr/lib/swift_static" \ - -DSWIFT_FOUNDATION_PATH=$DESTINATION_TOOLCHAIN/usr/lib/swift_static/wasi/wasm32 \ - "${SOURCE_PATH}/swift-corelibs-xctest" - -ninja -v -DESTDIR="$DESTINATION_TOOLCHAIN/usr/lib" ninja -v install diff --git a/schemes/release-5.9/build/run-test.sh b/schemes/release-5.9/build/run-test.sh deleted file mode 100755 index 5d48e403..00000000 --- a/schemes/release-5.9/build/run-test.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -set -euxo pipefail - -SOURCE_PATH="$(cd "$(dirname "$0")/../../../.." && pwd)" -TARGET_BUILD_ROOT="$SOURCE_PATH/build/WebAssembly" - -ninja check-swift-wasi-wasm32-custom -C "$TARGET_BUILD_ROOT/swift-stdlib-wasi-wasm32" diff --git a/schemes/release-5.9/manifest.json b/schemes/release-5.9/manifest.json deleted file mode 100644 index 8817d087..00000000 --- a/schemes/release-5.9/manifest.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "update-checkout-scheme": "release/5.9", - "base-tag": "swift-5.9.2-RELEASE", - "repos": { - "swift-corelibs-foundation": "660624d0220c0efbef054f4919f9f01fd3866be1", - "swift-corelibs-xctest": "77bc9f5386ee8a2a4e8da5ac30e846b451d101b6" - }, - "icu4c": ["https://github.com/swiftwasm/icu4c-wasi/releases/download/0.5.0/icu4c-wasi.tar.xz"], - "libxml2": ["https://github.com/swiftwasm/libxml2-wasm/releases/download/2.0.0/libxml2-wasm32-unknown-wasi.tar.gz"], - "wasi-sysroot": "https://github.com/swiftwasm/wasi-sdk-build/releases/download/wasi-sdk-14%2Bswiftwasm-2022-03-13/wasi-sysroot.tar.gz", - "swift-org-download-channel": "swift-5.9.2-release" -} diff --git a/schemes/release-5.9/swift/0001-wasm-Add-metadata-registration-for-WebAssembly.patch b/schemes/release-5.9/swift/0001-wasm-Add-metadata-registration-for-WebAssembly.patch deleted file mode 100644 index e67f39a0..00000000 --- a/schemes/release-5.9/swift/0001-wasm-Add-metadata-registration-for-WebAssembly.patch +++ /dev/null @@ -1,131 +0,0 @@ -From e906a5615206f580b512ae2eabe71cc4050d2c99 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Sun, 11 Jun 2023 11:44:24 +0000 -Subject: [PATCH] [wasm] Add metadata registration for WebAssembly - -This patch adds the metadata registration for the wasm targets, and also -adds build support for it. ---- - stdlib/public/runtime/CMakeLists.txt | 26 ++++++++++++++++--- - .../{SwiftRT-ELF.cpp => SwiftRT-ELF-WASM.cpp} | 15 +++++++++-- - 2 files changed, 35 insertions(+), 6 deletions(-) - rename stdlib/public/runtime/{SwiftRT-ELF.cpp => SwiftRT-ELF-WASM.cpp} (85%) - -diff --git a/stdlib/public/runtime/CMakeLists.txt b/stdlib/public/runtime/CMakeLists.txt -index 2ee018f6fc5..4881410d6a8 100644 ---- a/stdlib/public/runtime/CMakeLists.txt -+++ b/stdlib/public/runtime/CMakeLists.txt -@@ -94,7 +94,7 @@ set(swift_runtime_backtracing_sources - # Acknowledge that the following sources are known. - set(LLVM_OPTIONAL_SOURCES - SwiftRT-COFF.cpp -- SwiftRT-ELF.cpp -+ SwiftRT-ELF-WASM.cpp - ${swift_runtime_sources} - ${swift_runtime_objc_sources} - ${swift_runtime_leaks_sources} -@@ -149,11 +149,14 @@ add_swift_target_library(swiftRuntime OBJECT_LIBRARY - - set(ELFISH_SDKS) - set(COFF_SDKS) -+set(WASM_SDKS) - foreach(sdk ${SWIFT_SDKS}) - if("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "ELF") - list(APPEND ELFISH_SDKS ${sdk}) - elseif("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "COFF") - list(APPEND COFF_SDKS ${sdk}) -+ elseif("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "WASM") -+ list(APPEND WASM_SDKS ${sdk}) - endif() - endforeach() - -@@ -162,7 +165,7 @@ endforeach() - # with LTO, force swift runtime to compile without LTO for Linux. - add_swift_target_library(swiftImageRegistrationObjectELF - OBJECT_LIBRARY IS_STDLIB IS_STDLIB_CORE -- SwiftRT-ELF.cpp -+ SwiftRT-ELF-WASM.cpp - C_COMPILE_FLAGS - ${SWIFT_RUNTIME_CORE_CXX_FLAGS} - ${swift_enable_backtracing} -@@ -184,17 +187,32 @@ add_swift_target_library(swiftImageRegistrationObjectCOFF - SWIFT_COMPILE_FLAGS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS} - INSTALL_IN_COMPONENT none) - -+add_swift_target_library(swiftImageRegistrationObjectWASM -+ OBJECT_LIBRARY IS_STDLIB IS_STDLIB_CORE -+ SwiftRT-ELF-WASM.cpp -+ C_COMPILE_FLAGS ${SWIFT_RUNTIME_CORE_CXX_FLAGS} -+ LINK_FLAGS ${SWIFT_RUNTIME_CORE_LINK_FLAGS} -+ TARGET_SDKS ${WASM_SDKS} -+ SWIFT_COMPILE_FLAGS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS} -+ INSTALL_IN_COMPONENT none) -+ - foreach(sdk ${SWIFT_SDKS}) - foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES}) - set(arch_subdir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}") - set(arch_suffix "${SWIFT_SDK_${sdk}_LIB_SUBDIR}-${arch}") - - if("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "ELF" OR -- "${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "COFF") -+ "${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "COFF" OR -+ "${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "WASM") - # TODO(compnerd) switch to the generator expression when cmake is upgraded - # to a version which supports it. - # set(swiftrtObject "$") -- set(swiftrtObject ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/swiftImageRegistrationObject${SWIFT_SDK_${sdk}_OBJECT_FORMAT}-${arch_suffix}.dir/SwiftRT-${SWIFT_SDK_${sdk}_OBJECT_FORMAT}.cpp${CMAKE_C_OUTPUT_EXTENSION}) -+ set(swiftrtSourceName SwiftRT-${SWIFT_SDK_${sdk}_OBJECT_FORMAT}.cpp) -+ if("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "ELF" OR -+ "${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "WASM") -+ set(swiftrtSourceName SwiftRT-ELF-WASM.cpp) -+ endif() -+ set(swiftrtObject ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/swiftImageRegistrationObject${SWIFT_SDK_${sdk}_OBJECT_FORMAT}-${arch_suffix}.dir/${swiftrtSourceName}${CMAKE_C_OUTPUT_EXTENSION}) - - if(sdk STREQUAL "WINDOWS") - set(extension .obj) -diff --git a/stdlib/public/runtime/SwiftRT-ELF.cpp b/stdlib/public/runtime/SwiftRT-ELF-WASM.cpp -similarity index 85% -rename from stdlib/public/runtime/SwiftRT-ELF.cpp -rename to stdlib/public/runtime/SwiftRT-ELF-WASM.cpp -index 64d62f3de09..4ee737c8352 100644 ---- a/stdlib/public/runtime/SwiftRT-ELF.cpp -+++ b/stdlib/public/runtime/SwiftRT-ELF-WASM.cpp -@@ -1,4 +1,4 @@ --//===--- SwiftRT-ELF.cpp --------------------------------------------------===// -+//===--- SwiftRT-ELF-WASM.cpp ---------------------------------------------===// - // - // This source file is part of the Swift.org open source project - // -@@ -17,7 +17,13 @@ - #include - #include - -+#if defined(__ELF__) - extern "C" const char __dso_handle[]; -+#elif defined(__wasm__) -+// NOTE: Multi images in a single process is not yet -+// stabilized in WebAssembly toolchain outside of Emscripten. -+static constexpr const void *__dso_handle = nullptr; -+#endif - - #if SWIFT_ENABLE_BACKTRACING - // Drag in a symbol from the backtracer, to force the static linker to include -@@ -29,9 +35,14 @@ static const void *__backtraceRef __attribute__((used)) - // Create empty sections to ensure that the start/stop symbols are synthesized - // by the linker. Otherwise, we may end up with undefined symbol references as - // the linker table section was never constructed. -+#if defined(__ELF__) -+# define DECLARE_EMPTY_METADATA_SECTION(name) __asm__("\t.section " #name ",\"a\"\n"); -+#elif defined(__wasm__) -+# define DECLARE_EMPTY_METADATA_SECTION(name) __asm__("\t.section " #name ",\"\",@\n"); -+#endif - - #define DECLARE_SWIFT_SECTION(name) \ -- __asm__("\t.section " #name ",\"a\"\n"); \ -+ DECLARE_EMPTY_METADATA_SECTION(name) \ - __attribute__((__visibility__("hidden"),__aligned__(1))) extern const char __start_##name; \ - __attribute__((__visibility__("hidden"),__aligned__(1))) extern const char __stop_##name; - --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0002-wasm-cmake-HACK-Skip-building-swift-reflection-test-.patch b/schemes/release-5.9/swift/0002-wasm-cmake-HACK-Skip-building-swift-reflection-test-.patch deleted file mode 100644 index d7a9464b..00000000 --- a/schemes/release-5.9/swift/0002-wasm-cmake-HACK-Skip-building-swift-reflection-test-.patch +++ /dev/null @@ -1,44 +0,0 @@ -From ce08b2284dc3300c61f5adf617cc954b773d1021 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 06:49:07 +0000 -Subject: [PATCH] [wasm][cmake] HACK: Skip building swift-reflection-test for - now - -The reason why this change is needed is unclear to me... ---- - CMakeLists.txt | 5 +++++ - stdlib/private/CMakeLists.txt | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 2eeaf61e374..4342ae674c9 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -566,6 +566,11 @@ option(SWIFT_STDLIB_ENABLE_OBJC_INTEROP - "Should stdlib be built with Obj-C interop." - "${SWIFT_STDLIB_ENABLE_OBJC_INTEROP_default}") - -+# FIXME(wasm) Reflection tests are temporalily disabled due to lack of linker features -+option(SWIFTWASM_DISABLE_REFLECTION_TEST -+ "Disable building swift-reflection-test for WebAssembly build" -+ FALSE) -+ - # - # User-configurable experimental options. Do not use in production builds. - # -diff --git a/stdlib/private/CMakeLists.txt b/stdlib/private/CMakeLists.txt -index 05ef455b755..704d96f9248 100644 ---- a/stdlib/private/CMakeLists.txt -+++ b/stdlib/private/CMakeLists.txt -@@ -28,7 +28,7 @@ if(SWIFT_BUILD_SDK_OVERLAY) - endif() - # Currently SwiftReflectionTest cannot be built on Windows, due to - # dependencies on POSIX symbols -- if (SWIFT_INCLUDE_TESTS AND (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")) -+ if (SWIFT_INCLUDE_TESTS AND (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows") AND NOT SWIFTWASM_DISABLE_REFLECTION_TEST) - add_subdirectory(SwiftReflectionTest) - endif() - endif() --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0003-wasm-cmake-HACK-Tweak-standalone-stdlib-build-config.patch b/schemes/release-5.9/swift/0003-wasm-cmake-HACK-Tweak-standalone-stdlib-build-config.patch deleted file mode 100644 index a212ee93..00000000 --- a/schemes/release-5.9/swift/0003-wasm-cmake-HACK-Tweak-standalone-stdlib-build-config.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 24923e2d437b536b2a48e443a1204ce925e443aa Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 06:58:41 +0000 -Subject: [PATCH] [wasm][cmake] HACK: Tweak standalone stdlib build - configuration - -This commit disables remote mirrors due to cross-compilation issues, and -turns off several additional features that are not yet supported on WASI. ---- - cmake/caches/Runtime-WASI-wasm32.cmake | 9 +++++++++ - 1 file changed, 9 insertions(+) - -diff --git a/cmake/caches/Runtime-WASI-wasm32.cmake b/cmake/caches/Runtime-WASI-wasm32.cmake -index d96dc885022..2938f4a8f60 100644 ---- a/cmake/caches/Runtime-WASI-wasm32.cmake -+++ b/cmake/caches/Runtime-WASI-wasm32.cmake -@@ -8,6 +8,7 @@ set(SWIFT_SDKS WASI CACHE STRING "") - set(SWIFT_INCLUDE_TOOLS NO CACHE BOOL "") - set(SWIFT_INCLUDE_TESTS TRUE CACHE BOOL "") - set(SWIFT_INCLUDE_DOCS NO CACHE BOOL "") -+set(SWIFT_BUILD_REMOTE_MIRROR NO CACHE BOOL "") - - set(SWIFT_BUILD_SOURCEKIT NO CACHE BOOL "") - set(SWIFT_ENABLE_SOURCEKIT_TESTS NO CACHE BOOL "") -@@ -18,8 +19,16 @@ set(SWIFTWASM_DISABLE_REFLECTION_TEST YES CACHE BOOL "") - set(SWIFT_BUILD_STATIC_STDLIB YES CACHE BOOL "") - set(SWIFT_BUILD_DYNAMIC_STDLIB NO CACHE BOOL "") - set(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY YES CACHE BOOL "") -+# TODO(katei): This should get turned off, as this is not an ABI stable platform. -+# But current CMake build system doesn't support SWIFT_STDLIB_STABLE_ABI=NO -+set(SWIFT_STDLIB_STABLE_ABI YES CACHE BOOL "") - - # build with the host compiler - set(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER YES CACHE BOOL "") - - set(SWIFT_STDLIB_SINGLE_THREADED_CONCURRENCY TRUE CACHE BOOL "") -+set(SWIFT_THREADING_PACKAGE TRUE CACHE STRING "none") -+ -+set(SWIFT_STDLIB_SUPPORTS_BACKTRACE_REPORTING FALSE CACHE BOOL "") -+set(SWIFT_STDLIB_HAS_DLADDR FALSE CACHE BOOL "") -+set(SWIFT_STDLIB_COMPACT_ABSOLUTE_FUNCTION_POINTER TRUE CACHE BOOL "") --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0004-wasm-cmake-HACK-link-wasi-emulated-mman-to-host-exec.patch b/schemes/release-5.9/swift/0004-wasm-cmake-HACK-link-wasi-emulated-mman-to-host-exec.patch deleted file mode 100644 index b1c6b3bf..00000000 --- a/schemes/release-5.9/swift/0004-wasm-cmake-HACK-link-wasi-emulated-mman-to-host-exec.patch +++ /dev/null @@ -1,27 +0,0 @@ -From a75a27dfde2d4668c37ed3bb226c66fd55b2f003 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 07:04:03 +0000 -Subject: [PATCH] [wasm][cmake] HACK: link wasi-emulated-mman to host - executable - -The reason why this change is needed is unclear to me... ---- - cmake/modules/AddSwift.cmake | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/cmake/modules/AddSwift.cmake b/cmake/modules/AddSwift.cmake -index e0fb5de09f2..834138ba8f6 100644 ---- a/cmake/modules/AddSwift.cmake -+++ b/cmake/modules/AddSwift.cmake -@@ -397,6 +397,8 @@ function(_add_host_variant_link_flags target) - cxx_link_libraries) - target_link_libraries(${target} PRIVATE - ${cxx_link_libraries}) -+ elseif("${LFLAGS_SDK}" STREQUAL "WASI") -+ list(APPEND result "-Wl,wasi-emulated-mman") - else() - # If lto is enabled, we need to add the object path flag so that the LTO code - # generator leaves the intermediate object file in a place where it will not --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0005-wasm-build-Add-WASILibc-module-and-its-build-support.patch b/schemes/release-5.9/swift/0005-wasm-build-Add-WASILibc-module-and-its-build-support.patch deleted file mode 100644 index ac784d14..00000000 --- a/schemes/release-5.9/swift/0005-wasm-build-Add-WASILibc-module-and-its-build-support.patch +++ /dev/null @@ -1,438 +0,0 @@ -From 5ebb81603ed84d7fa4e8da9fad5ba86b290b5089 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Wed, 7 Jun 2023 17:58:49 +0000 -Subject: [PATCH] [wasm][build] Add WASILibc module and its build support - -[wasi-libc](https://github.com/WebAssembly/wasi-libc) is a libc -implementation widely used in WASI toolchains. This patch adds a new -Swift and C module for it to import and use it in Swift code. This -module is intentionally separate from the existing `Glibc` module -because wasi-libc is actually based on musl libc. ---- - stdlib/public/Platform/CMakeLists.txt | 51 ++++-- - stdlib/public/Platform/SwiftWASILibc.h.gyb | 126 ++++++++++++++ - stdlib/public/Platform/WASILibc.swift.gyb | 161 ++++++++++++++++++ - .../public/Platform/wasi-libc.modulemap.gyb | 18 ++ - 4 files changed, 343 insertions(+), 13 deletions(-) - create mode 100644 stdlib/public/Platform/SwiftWASILibc.h.gyb - create mode 100644 stdlib/public/Platform/WASILibc.swift.gyb - create mode 100644 stdlib/public/Platform/wasi-libc.modulemap.gyb - -diff --git a/stdlib/public/Platform/CMakeLists.txt b/stdlib/public/Platform/CMakeLists.txt -index e78e760942b..e97ba7994d2 100644 ---- a/stdlib/public/Platform/CMakeLists.txt -+++ b/stdlib/public/Platform/CMakeLists.txt -@@ -98,6 +98,23 @@ add_swift_target_library(swiftGlibc ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_O - INSTALL_IN_COMPONENT sdk-overlay - DEPENDS glibc_modulemap) - -+add_swift_target_library(swiftWASILibc ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY -+ ${swift_platform_sources} -+ POSIXError.swift -+ -+ GYB_SOURCES -+ ${swift_platform_gyb_sources} -+ WASILibc.swift.gyb -+ -+ SWIFT_COMPILE_FLAGS -+ ${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS} -+ ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS} -+ ${swift_platform_compile_flags} -+ LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}" -+ TARGET_SDKS WASI -+ INSTALL_IN_COMPONENT sdk-overlay -+ DEPENDS glibc_modulemap) -+ - add_swift_target_library(swiftCRT ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY - ucrt.swift - ${swift_platform_sources} -@@ -117,23 +134,31 @@ add_swift_target_library(swiftCRT ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVE - - set(glibc_modulemap_target_list) - foreach(sdk ${SWIFT_SDKS}) -- if(NOT "${sdk}" STREQUAL "LINUX" AND -- NOT "${sdk}" STREQUAL "FREEBSD" AND -- NOT "${sdk}" STREQUAL "OPENBSD" AND -- NOT "${sdk}" STREQUAL "ANDROID" AND -- NOT "${sdk}" STREQUAL "CYGWIN" AND -- NOT "${sdk}" STREQUAL "HAIKU") -+ if("${sdk}" STREQUAL "LINUX" OR -+ "${sdk}" STREQUAL "FREEBSD" OR -+ "${sdk}" STREQUAL "OPENBSD" OR -+ "${sdk}" STREQUAL "ANDROID" OR -+ "${sdk}" STREQUAL "CYGWIN" OR -+ "${sdk}" STREQUAL "HAIKU") -+ set(glibc_modulemap_source "glibc.modulemap.gyb") -+ set(glibc_header_source "SwiftGlibc.h.gyb") -+ elseif("${sdk}" STREQUAL "WASI") -+ set(glibc_modulemap_source "wasi-libc.modulemap.gyb") -+ set(glibc_header_source "SwiftWASILibc.h.gyb") -+ else() - continue() - endif() - -+ string(REGEX REPLACE "\\.gyb$" "" glibc_modulemap_outname "${glibc_modulemap_source}") -+ string(REGEX REPLACE "\\.gyb$" "" glibc_header_outname "${glibc_header_source}") -+ - foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES}) - set(arch_subdir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}") - set(module_dir "${SWIFTLIB_DIR}/${arch_subdir}") - set(module_dir_static "${SWIFTSTATICLIB_DIR}/${arch_subdir}") - -- set(glibc_modulemap_source "glibc.modulemap.gyb") -- set(glibc_modulemap_out "${module_dir}/glibc.modulemap") -- set(glibc_modulemap_out_static "${module_dir_static}/glibc.modulemap") -+ set(glibc_modulemap_out "${module_dir}/${glibc_modulemap_outname}") -+ set(glibc_modulemap_out_static "${module_dir_static}/${glibc_modulemap_outname}") - - # Configure the module map based on the target. Each platform needs to - # reference different headers, based on what's available in their glibc. -@@ -147,10 +172,10 @@ foreach(sdk ${SWIFT_SDKS}) - - list(APPEND glibc_modulemap_target_list ${glibc_modulemap_target}) - -- set(glibc_header_out "${module_dir}/SwiftGlibc.h") -- set(glibc_header_out_static "${module_dir_static}/SwiftGlibc.h") -+ set(glibc_header_out "${module_dir}/${glibc_header_outname}") -+ set(glibc_header_out_static "${module_dir_static}/${glibc_header_outname}") - handle_gyb_source_single(glibc_header_target -- SOURCE "SwiftGlibc.h.gyb" -+ SOURCE "${glibc_header_source}" - OUTPUT "${glibc_header_out}" - FLAGS "-DCMAKE_SDK=${sdk}") - list(APPEND glibc_modulemap_target_list ${glibc_header_target}) -@@ -181,7 +206,7 @@ foreach(sdk ${SWIFT_SDKS}) - # prefix. This is the one we'll install instead. - if(NOT "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${arch}_PATH}" STREQUAL "/" AND - NOT (sdk STREQUAL "ANDROID" AND NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")) -- set(glibc_sysroot_relative_modulemap_out "${module_dir}/sysroot-relative-modulemaps/glibc.modulemap") -+ set(glibc_sysroot_relative_modulemap_out "${module_dir}/sysroot-relative-modulemaps/${glibc_modulemap_outname}") - - handle_gyb_source_single(glibc_modulemap_native_target - SOURCE "${glibc_modulemap_source}" -diff --git a/stdlib/public/Platform/SwiftWASILibc.h.gyb b/stdlib/public/Platform/SwiftWASILibc.h.gyb -new file mode 100644 -index 00000000000..c051627f2b7 ---- /dev/null -+++ b/stdlib/public/Platform/SwiftWASILibc.h.gyb -@@ -0,0 +1,126 @@ -+%{ -+headers = [ -+ 'stdc-predef.h', -+ 'features.h', -+ -+ # C standard library -+ 'complex.h', -+ 'ctype.h', -+ 'errno.h', -+ 'fenv.h', -+ 'float.h', -+ 'inttypes.h', -+ 'iso646.h', -+ 'libutil.h', -+ 'limits.h', -+ 'locale.h', -+ 'math.h', -+ 'pty.h', -+ # setjmp/longjmp is not available -+ # 'setjmp.h', -+ 'signal.h', -+ 'stdarg.h', -+ 'stdbool.h', -+ 'stddef.h', -+ 'stdint.h', -+ 'stdio.h', -+ 'stdlib.h', -+ 'string.h', -+ 'tgmath.h', -+ 'time.h', -+ 'util.h', -+ 'utmp.h', -+ -+ # POSIX -+ 'aio.h', -+ 'arpa/inet.h', -+ 'bsd/ifaddrs.h', -+ 'bsd/pty.h', -+ 'cpio.h', -+ 'dirent.h', -+ 'dlfcn.h', -+ 'fcntl.h', -+ 'fmtmsg.h', -+ 'fnmatch.h', -+ 'ftw.h', -+ 'glob.h', -+ 'grp.h', -+ 'iconv.h', -+ 'ifaddrs.h', -+ 'langinfo.h', -+ 'libgen.h', -+ 'link.h', -+ 'monetary.h', -+ 'net/if.h', -+ 'netdb.h', -+ 'netinet/in.h', -+ 'netinet/tcp.h', -+ 'nl_types.h', -+ 'poll.h', -+ 'pthread.h', -+ 'pwd.h', -+ 'regex.h', -+ 'sched.h', -+ 'search.h', -+ 'semaphore.h', -+ 'spawn.h', -+ 'strings.h', -+ 'sys/event.h', -+ 'sys/file.h', -+ 'sys/inotify.h', -+ 'sys/ioctl.h', -+ 'sys/ipc.h', -+ 'sys/mman.h', -+ 'sys/mount.h', -+ 'sys/msg.h', -+ 'sys/resource.h', -+ 'sys/select.h', -+ 'sys/sem.h', -+ 'sys/sendfile.h', -+ 'sys/shm.h', -+ 'sys/socket.h', -+ 'sys/stat.h', -+ 'sys/statvfs.h', -+ 'sys/time.h', -+ 'sys/times.h', -+ 'sys/types.h', -+ 'sys/uio.h', -+ 'sys/un.h', -+ 'sys/user.h', -+ 'sys/utsname.h', -+ 'sys/wait.h', -+ 'sysexits.h', -+ 'syslog.h', -+ 'tar.h', -+ 'termios.h', -+ 'ulimit.h', -+ 'unistd.h', -+ 'utime.h', -+ 'utmpx.h', -+ 'wait.h', -+ 'wordexp.h', -+ -+ # WASI specific -+ 'wasi/api.h', -+] -+}% -+ -+// FIXME?(katei): -+// Those emulations are now enabled by default to have compatibility -+// with other platforms as much as possible without any extra modification. -+// But we should consider moving them into their own submodules. -+#ifndef _WASI_EMULATED_MMAN -+# define _WASI_EMULATED_MMAN -+#endif -+#ifndef _WASI_EMULATED_SIGNAL -+# define _WASI_EMULATED_SIGNAL -+#endif -+#ifndef _WASI_EMULATED_PROCESS_CLOCKS -+# define _WASI_EMULATED_PROCESS_CLOCKS -+#endif -+ -+% for header in headers: -+#if __has_include(<${header}>) -+#include <${header}> -+#endif -+% end -diff --git a/stdlib/public/Platform/WASILibc.swift.gyb b/stdlib/public/Platform/WASILibc.swift.gyb -new file mode 100644 -index 00000000000..bd6e03ed3c4 ---- /dev/null -+++ b/stdlib/public/Platform/WASILibc.swift.gyb -@@ -0,0 +1,161 @@ -+//===----------------------------------------------------------------------===// -+// -+// This source file is part of the Swift.org open source project -+// -+// Copyright (c) 2020 Apple Inc. and the Swift project authors -+// Licensed under Apache License v2.0 with Runtime Library Exception -+// -+// See https://swift.org/LICENSE.txt for license information -+// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -+// -+//===----------------------------------------------------------------------===// -+ -+@_exported import SwiftWASILibc // Clang module -+ -+// Constants defined by -+@available(swift, deprecated: 3.0, message: "Please use 'Double.pi' or '.pi' to get the value of correct type and avoid casting.") -+public let M_PI = Double.pi -+ -+@available(swift, deprecated: 3.0, message: "Please use 'Double.pi / 2' or '.pi / 2' to get the value of correct type and avoid casting.") -+public let M_PI_2 = Double.pi / 2 -+ -+@available(swift, deprecated: 3.0, message: "Please use 'Double.pi / 4' or '.pi / 4' to get the value of correct type and avoid casting.") -+public let M_PI_4 = Double.pi / 4 -+ -+@available(swift, deprecated: 3.0, message: "Please use '2.squareRoot()'.") -+public let M_SQRT2 = 2.squareRoot() -+ -+@available(swift, deprecated: 3.0, message: "Please use '0.5.squareRoot()'.") -+public let M_SQRT1_2 = 0.5.squareRoot() -+ -+// Constants defined by -+@available(swift, deprecated: 3.0, message: "Please use 'T.radix' to get the radix of a FloatingPoint type 'T'.") -+public let FLT_RADIX = Double.radix -+ -+%for type, prefix in [('Float', 'FLT'), ('Double', 'DBL')]: -+// Where does the 1 come from? C counts the usually-implicit leading -+// significand bit, but Swift does not. Neither is really right or wrong. -+@available(swift, deprecated: 3.0, message: "Please use '${type}.significandBitCount + 1'.") -+public let ${prefix}_MANT_DIG = ${type}.significandBitCount + 1 -+ -+// Where does the 1 come from? C models floating-point numbers as having a -+// significand in [0.5, 1), but Swift (following IEEE 754) considers the -+// significand to be in [1, 2). This rationale applies to ${prefix}_MIN_EXP -+// as well. -+@available(swift, deprecated: 3.0, message: "Please use '${type}.greatestFiniteMagnitude.exponent + 1'.") -+public let ${prefix}_MAX_EXP = ${type}.greatestFiniteMagnitude.exponent + 1 -+ -+@available(swift, deprecated: 3.0, message: "Please use '${type}.leastNormalMagnitude.exponent + 1'.") -+public let ${prefix}_MIN_EXP = ${type}.leastNormalMagnitude.exponent + 1 -+ -+@available(swift, deprecated: 3.0, message: "Please use '${type}.greatestFiniteMagnitude' or '.greatestFiniteMagnitude'.") -+public let ${prefix}_MAX = ${type}.greatestFiniteMagnitude -+ -+@available(swift, deprecated: 3.0, message: "Please use '${type}.ulpOfOne' or '.ulpOfOne'.") -+public let ${prefix}_EPSILON = ${type}.ulpOfOne -+ -+@available(swift, deprecated: 3.0, message: "Please use '${type}.leastNormalMagnitude' or '.leastNormalMagnitude'.") -+public let ${prefix}_MIN = ${type}.leastNormalMagnitude -+ -+@available(swift, deprecated: 3.0, message: "Please use '${type}.leastNonzeroMagnitude' or '.leastNonzeroMagnitude'.") -+public let ${prefix}_TRUE_MIN = ${type}.leastNonzeroMagnitude -+ -+%end -+ -+public let MAP_FAILED: UnsafeMutableRawPointer! = UnsafeMutableRawPointer(bitPattern: -1) -+ -+// TODO: wasi-libc's error.h defines these macros as function-like macros, which -+// Swift can't import for now. -+%{ -+posix_error_codes = [ -+ "E2BIG", -+ "EACCES", -+ "EADDRINUSE", -+ "EADDRNOTAVAIL", -+ "EAFNOSUPPORT", -+ "EAGAIN", -+ "EALREADY", -+ "EBADF", -+ "EBADMSG", -+ "EBUSY", -+ "ECANCELED", -+ "ECHILD", -+ "ECONNABORTED", -+ "ECONNREFUSED", -+ "ECONNRESET", -+ "EDEADLK", -+ "EDESTADDRREQ", -+ "EDOM", -+ "EDQUOT", -+ "EEXIST", -+ "EFAULT", -+ "EFBIG", -+ "EHOSTUNREACH", -+ "EIDRM", -+ "EILSEQ", -+ "EINPROGRESS", -+ "EINTR", -+ "EINVAL", -+ "EIO", -+ "EISCONN", -+ "EISDIR", -+ "ELOOP", -+ "EMFILE", -+ "EMLINK", -+ "EMSGSIZE", -+ "EMULTIHOP", -+ "ENAMETOOLONG", -+ "ENETDOWN", -+ "ENETRESET", -+ "ENETUNREACH", -+ "ENFILE", -+ "ENOBUFS", -+ "ENODEV", -+ "ENOENT", -+ "ENOEXEC", -+ "ENOLCK", -+ "ENOLINK", -+ "ENOMEM", -+ "ENOMSG", -+ "ENOPROTOOPT", -+ "ENOSPC", -+ "ENOSYS", -+ "ENOTCONN", -+ "ENOTDIR", -+ "ENOTEMPTY", -+ "ENOTRECOVERABLE", -+ "ENOTSOCK", -+ "ENOTSUP", -+ "ENOTTY", -+ "ENXIO", -+ "EOVERFLOW", -+ "EOWNERDEAD", -+ "EPERM", -+ "EPIPE", -+ "EPROTO", -+ "EPROTONOSUPPORT", -+ "EPROTOTYPE", -+ "ERANGE", -+ "EROFS", -+ "ESPIPE", -+ "ESRCH", -+ "ESTALE", -+ "ETIMEDOUT", -+ "ETXTBSY", -+ "EXDEV", -+ "ENOTCAPABLE", -+] -+}% -+ -+%for ecode in posix_error_codes: -+ -+@available(*, deprecated, message: "Please use 'POSIXErrorCode.${ecode}'.") -+public let ${ecode} = POSIXErrorCode.${ecode}.rawValue -+ -+%end -+ -+// TODO: wasi-libc's _seek.h defines these macros as function-like macros, which -+// Swift can't import for now. -+public let SEEK_SET: Int32 = 0 -+public let SEEK_CUR: Int32 = 1 -+public let SEEK_END: Int32 = 2 -diff --git a/stdlib/public/Platform/wasi-libc.modulemap.gyb b/stdlib/public/Platform/wasi-libc.modulemap.gyb -new file mode 100644 -index 00000000000..59be5d56499 ---- /dev/null -+++ b/stdlib/public/Platform/wasi-libc.modulemap.gyb -@@ -0,0 +1,18 @@ -+//===--- wasi-libc.modulemap.gyb ------------------------------------------===// -+// -+// This source file is part of the Swift.org open source project -+// -+// Copyright (c) 2020 Apple Inc. and the Swift project authors -+// Licensed under Apache License v2.0 with Runtime Library Exception -+// -+// See https://swift.org/LICENSE.txt for license information -+// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -+// -+//===----------------------------------------------------------------------===// -+ -+module SwiftWASILibc [system] { -+ // C standard library -+ header "SwiftWASILibc.h" -+ -+ export * -+} --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0006-ClangImporter-Support-wasi-libc.modulemap-import-wit.patch b/schemes/release-5.9/swift/0006-ClangImporter-Support-wasi-libc.modulemap-import-wit.patch deleted file mode 100644 index 207f7429..00000000 --- a/schemes/release-5.9/swift/0006-ClangImporter-Support-wasi-libc.modulemap-import-wit.patch +++ /dev/null @@ -1,91 +0,0 @@ -From 2fad6956a3afeb6d1f1f319b5777d37bb5d39496 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Sat, 10 Jun 2023 14:51:49 +0000 -Subject: [PATCH] [ClangImporter] Support wasi-libc.modulemap import with VFS - ---- - lib/ClangImporter/ClangIncludePaths.cpp | 41 +++++++++++++++++++------ - 1 file changed, 31 insertions(+), 10 deletions(-) - -diff --git a/lib/ClangImporter/ClangIncludePaths.cpp b/lib/ClangImporter/ClangIncludePaths.cpp -index dc368b03c3e..529be1b463b 100644 ---- a/lib/ClangImporter/ClangIncludePaths.cpp -+++ b/lib/ClangImporter/ClangIncludePaths.cpp -@@ -101,6 +101,13 @@ static llvm::Optional getGlibcModuleMapPath( - /*isArchSpecific*/ true, vfs); - } - -+static llvm::Optional getWASILibcModuleMapPath( -+ SearchPathOptions &Opts, const llvm::Triple &triple, -+ const llvm::IntrusiveRefCntPtr &vfs) { -+ return getActualModuleMapPath("wasi-libc.modulemap", Opts, triple, -+ /*isArchSpecific*/ true, vfs); -+} -+ - static llvm::Optional getLibStdCxxModuleMapPath( - SearchPathOptions &opts, const llvm::Triple &triple, - const llvm::IntrusiveRefCntPtr &vfs) { -@@ -195,11 +202,32 @@ static bool shouldInjectGlibcModulemap(const llvm::Triple &triple) { - triple.isAndroid(); - } - -+static bool shouldInjectWASILibcModulemap(const llvm::Triple &triple) { -+ return triple.isOSWASI(); -+} -+ - static SmallVector, 2> getGlibcFileMapping( - ASTContext &ctx, - const llvm::IntrusiveRefCntPtr &vfs) { - const llvm::Triple &triple = ctx.LangOpts.Target; -- if (!shouldInjectGlibcModulemap(triple)) -+ -+ std::string auxiliaryHeaderName; -+ llvm::Optional maybeActualModuleMapPath; -+ if (shouldInjectGlibcModulemap(triple)) { -+ auxiliaryHeaderName = "SwiftGlibc.h"; -+ maybeActualModuleMapPath = getGlibcModuleMapPath(ctx.SearchPathOpts, triple, vfs); -+ } else if (shouldInjectWASILibcModulemap(triple)) { -+ auxiliaryHeaderName = "SwiftWASILibc.h"; -+ maybeActualModuleMapPath = getWASILibcModuleMapPath(ctx.SearchPathOpts, triple, vfs); -+ } else { -+ return {}; -+ } -+ -+ Path actualModuleMapPath; -+ if (auto path = maybeActualModuleMapPath) -+ actualModuleMapPath = path.value(); -+ else -+ // FIXME: Emit a warning of some kind. - return {}; - - // Extract the Glibc path from Clang driver. -@@ -225,24 +253,17 @@ static SmallVector, 2> getGlibcFileMapping( - return {}; - } - -- Path actualModuleMapPath; -- if (auto path = getGlibcModuleMapPath(ctx.SearchPathOpts, triple, vfs)) -- actualModuleMapPath = path.value(); -- else -- // FIXME: Emit a warning of some kind. -- return {}; -- - // TODO: remove the SwiftGlibc.h header and reference all Glibc headers - // directly from the modulemap. - Path actualHeaderPath = actualModuleMapPath; - llvm::sys::path::remove_filename(actualHeaderPath); -- llvm::sys::path::append(actualHeaderPath, "SwiftGlibc.h"); -+ llvm::sys::path::append(actualHeaderPath, auxiliaryHeaderName); - - Path injectedModuleMapPath(glibcDir); - llvm::sys::path::append(injectedModuleMapPath, "module.modulemap"); - - Path injectedHeaderPath(glibcDir); -- llvm::sys::path::append(injectedHeaderPath, "SwiftGlibc.h"); -+ llvm::sys::path::append(injectedHeaderPath, auxiliaryHeaderName); - - return { - {std::string(injectedModuleMapPath), std::string(actualModuleMapPath)}, --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0007-build-Replace-glibc-specific-naming-in-libc-like-mod.patch b/schemes/release-5.9/swift/0007-build-Replace-glibc-specific-naming-in-libc-like-mod.patch deleted file mode 100644 index 5040d9dc..00000000 --- a/schemes/release-5.9/swift/0007-build-Replace-glibc-specific-naming-in-libc-like-mod.patch +++ /dev/null @@ -1,195 +0,0 @@ -From 0faf708d7872afc8acd89695286ef06f6d682416 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Sat, 10 Jun 2023 12:57:10 +0000 -Subject: [PATCH] [build] Replace glibc specific naming in libc-like modulemap - generation loop - ---- - stdlib/public/Platform/CMakeLists.txt | 90 +++++++++++++-------------- - 1 file changed, 45 insertions(+), 45 deletions(-) - -diff --git a/stdlib/public/Platform/CMakeLists.txt b/stdlib/public/Platform/CMakeLists.txt -index e97ba7994d2..f202ccd2eee 100644 ---- a/stdlib/public/Platform/CMakeLists.txt -+++ b/stdlib/public/Platform/CMakeLists.txt -@@ -96,7 +96,7 @@ add_swift_target_library(swiftGlibc ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_O - LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}" - TARGET_SDKS "${swiftGlibc_target_sdks}" - INSTALL_IN_COMPONENT sdk-overlay -- DEPENDS glibc_modulemap) -+ DEPENDS libc_modulemap) - - add_swift_target_library(swiftWASILibc ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY - ${swift_platform_sources} -@@ -113,7 +113,7 @@ add_swift_target_library(swiftWASILibc ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SD - LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}" - TARGET_SDKS WASI - INSTALL_IN_COMPONENT sdk-overlay -- DEPENDS glibc_modulemap) -+ DEPENDS libc_modulemap) - - add_swift_target_library(swiftCRT ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY - ucrt.swift -@@ -132,7 +132,7 @@ add_swift_target_library(swiftCRT ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVE - TARGET_SDKS WINDOWS - INSTALL_IN_COMPONENT sdk-overlay) - --set(glibc_modulemap_target_list) -+set(libc_modulemap_target_list) - foreach(sdk ${SWIFT_SDKS}) - if("${sdk}" STREQUAL "LINUX" OR - "${sdk}" STREQUAL "FREEBSD" OR -@@ -140,65 +140,65 @@ foreach(sdk ${SWIFT_SDKS}) - "${sdk}" STREQUAL "ANDROID" OR - "${sdk}" STREQUAL "CYGWIN" OR - "${sdk}" STREQUAL "HAIKU") -- set(glibc_modulemap_source "glibc.modulemap.gyb") -- set(glibc_header_source "SwiftGlibc.h.gyb") -+ set(libc_modulemap_source "glibc.modulemap.gyb") -+ set(libc_header_source "SwiftGlibc.h.gyb") - elseif("${sdk}" STREQUAL "WASI") -- set(glibc_modulemap_source "wasi-libc.modulemap.gyb") -- set(glibc_header_source "SwiftWASILibc.h.gyb") -+ set(libc_modulemap_source "wasi-libc.modulemap.gyb") -+ set(libc_header_source "SwiftWASILibc.h.gyb") - else() - continue() - endif() - -- string(REGEX REPLACE "\\.gyb$" "" glibc_modulemap_outname "${glibc_modulemap_source}") -- string(REGEX REPLACE "\\.gyb$" "" glibc_header_outname "${glibc_header_source}") -+ string(REGEX REPLACE "\\.gyb$" "" libc_modulemap_outname "${libc_modulemap_source}") -+ string(REGEX REPLACE "\\.gyb$" "" libc_header_outname "${libc_header_source}") - - foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES}) - set(arch_subdir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}") - set(module_dir "${SWIFTLIB_DIR}/${arch_subdir}") - set(module_dir_static "${SWIFTSTATICLIB_DIR}/${arch_subdir}") - -- set(glibc_modulemap_out "${module_dir}/${glibc_modulemap_outname}") -- set(glibc_modulemap_out_static "${module_dir_static}/${glibc_modulemap_outname}") -+ set(libc_modulemap_out "${module_dir}/${libc_modulemap_outname}") -+ set(libc_modulemap_out_static "${module_dir_static}/${libc_modulemap_outname}") - - # Configure the module map based on the target. Each platform needs to -- # reference different headers, based on what's available in their glibc. -- # This is the 'glibc.modulemap' in the 'resource-dir', so -+ # reference different headers, based on what's available in their libc. -+ # This is the .modulemap in the 'resource-dir', so - # it's the one we'll look at during the build process. -- handle_gyb_source_single(glibc_modulemap_target -- SOURCE "${glibc_modulemap_source}" -- OUTPUT "${glibc_modulemap_out}" -+ handle_gyb_source_single(libc_modulemap_target -+ SOURCE "${libc_modulemap_source}" -+ OUTPUT "${libc_modulemap_out}" - FLAGS - "-DCMAKE_SDK=${sdk}") - -- list(APPEND glibc_modulemap_target_list ${glibc_modulemap_target}) -+ list(APPEND libc_modulemap_target_list ${libc_modulemap_target}) - -- set(glibc_header_out "${module_dir}/${glibc_header_outname}") -- set(glibc_header_out_static "${module_dir_static}/${glibc_header_outname}") -- handle_gyb_source_single(glibc_header_target -- SOURCE "${glibc_header_source}" -- OUTPUT "${glibc_header_out}" -+ set(libc_header_out "${module_dir}/${libc_header_outname}") -+ set(libc_header_out_static "${module_dir_static}/${libc_header_outname}") -+ handle_gyb_source_single(libc_header_target -+ SOURCE "${libc_header_source}" -+ OUTPUT "${libc_header_out}" - FLAGS "-DCMAKE_SDK=${sdk}") -- list(APPEND glibc_modulemap_target_list ${glibc_header_target}) -+ list(APPEND libc_modulemap_target_list ${libc_header_target}) - - if(SWIFT_BUILD_STATIC_STDLIB) - add_custom_command_target( -- copy_glibc_modulemap_header_static -+ copy_libc_modulemap_header_static - COMMAND - "${CMAKE_COMMAND}" "-E" "make_directory" ${module_dir_static} - COMMAND - "${CMAKE_COMMAND}" "-E" "copy" -- ${glibc_modulemap_out} ${glibc_modulemap_out_static} -+ ${libc_modulemap_out} ${libc_modulemap_out_static} - COMMAND - "${CMAKE_COMMAND}" "-E" "copy" -- ${glibc_header_out} ${glibc_header_out_static} -- OUTPUT ${glibc_modulemap_out_static} ${glibc_header_out_static} -+ ${libc_header_out} ${libc_header_out_static} -+ OUTPUT ${libc_modulemap_out_static} ${libc_header_out_static} - DEPENDS -- "${glibc_modulemap_target}" -- "${glibc_header_target}" -- COMMENT "Copying Glibc modulemap and header to static resources") -+ "${libc_modulemap_target}" -+ "${libc_header_target}" -+ COMMENT "Copying libc modulemap and header to static resources") - -- list(APPEND glibc_modulemap_target_list -- ${copy_glibc_modulemap_header_static}) -+ list(APPEND libc_modulemap_target_list -+ ${copy_libc_modulemap_header_static}) - endif() - - # If this SDK is a target for a non-native host, except if it's for Android -@@ -206,15 +206,15 @@ foreach(sdk ${SWIFT_SDKS}) - # prefix. This is the one we'll install instead. - if(NOT "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${arch}_PATH}" STREQUAL "/" AND - NOT (sdk STREQUAL "ANDROID" AND NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")) -- set(glibc_sysroot_relative_modulemap_out "${module_dir}/sysroot-relative-modulemaps/${glibc_modulemap_outname}") -+ set(libc_sysroot_relative_modulemap_out "${module_dir}/sysroot-relative-modulemaps/${libc_modulemap_outname}") - -- handle_gyb_source_single(glibc_modulemap_native_target -- SOURCE "${glibc_modulemap_source}" -- OUTPUT "${glibc_sysroot_relative_modulemap_out}" -+ handle_gyb_source_single(libc_modulemap_native_target -+ SOURCE "${libc_modulemap_source}" -+ OUTPUT "${libc_sysroot_relative_modulemap_out}" - FLAGS "-DCMAKE_SDK=${sdk}") - -- list(APPEND glibc_modulemap_target_list ${glibc_modulemap_native_target}) -- set(glibc_modulemap_out ${glibc_sysroot_relative_modulemap_out}) -+ list(APPEND libc_modulemap_target_list ${libc_modulemap_native_target}) -+ set(libc_modulemap_out ${libc_sysroot_relative_modulemap_out}) - endif() - - # FIXME: When SDK is a cross-compile target (SDK != Host), the generated -@@ -222,26 +222,26 @@ foreach(sdk ${SWIFT_SDKS}) - # It is not relocatable to the target platform itself. - # This affects any cross-compiled targets that use glibc.modulemap. - -- swift_install_in_component(FILES "${glibc_modulemap_out}" -+ swift_install_in_component(FILES "${libc_modulemap_out}" - DESTINATION "lib/swift/${arch_subdir}" - COMPONENT sdk-overlay) -- swift_install_in_component(FILES "${glibc_header_out}" -+ swift_install_in_component(FILES "${libc_header_out}" - DESTINATION "lib/swift/${arch_subdir}" - COMPONENT sdk-overlay) - - if(SWIFT_BUILD_STATIC_STDLIB) -- swift_install_in_component(FILES "${glibc_modulemap_out}" -+ swift_install_in_component(FILES "${libc_modulemap_out}" - DESTINATION "lib/swift_static/${arch_subdir}" - COMPONENT sdk-overlay) -- swift_install_in_component(FILES "${glibc_header_out}" -+ swift_install_in_component(FILES "${libc_header_out}" - DESTINATION "lib/swift_static/${arch_subdir}" - COMPONENT sdk-overlay) - endif() - endforeach() - endforeach() --add_custom_target(glibc_modulemap DEPENDS ${glibc_modulemap_target_list}) --set_property(TARGET glibc_modulemap PROPERTY FOLDER "Miscellaneous") --add_dependencies(sdk-overlay glibc_modulemap) -+add_custom_target(libc_modulemap DEPENDS ${libc_modulemap_target_list}) -+set_property(TARGET libc_modulemap PROPERTY FOLDER "Miscellaneous") -+add_dependencies(sdk-overlay libc_modulemap) - - if(WINDOWS IN_LIST SWIFT_SDKS) - swift_install_in_component(FILES --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0008-wasm-Driver-HACK-Add-wasi-sysroot-layout-and-auto-de.patch b/schemes/release-5.9/swift/0008-wasm-Driver-HACK-Add-wasi-sysroot-layout-and-auto-de.patch deleted file mode 100644 index 54ce43e4..00000000 --- a/schemes/release-5.9/swift/0008-wasm-Driver-HACK-Add-wasi-sysroot-layout-and-auto-de.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 867164f28473f4a063bb4cc846803b148f7ba424 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 07:11:04 +0000 -Subject: [PATCH] [wasm][Driver] HACK: Add wasi-sysroot layout and - auto-detection support - -Currenty, SwiftWasm toolchain contains wasi-sysroot under -`./usr/share/wasi-sysroot` directory in the toolchain package, but we -don't have a good consensus on the location of wasi-sysroot yet. So this -patch is a temporary solution just to avoid the need to specify `-sdk` -option manually. That being said, SwiftPM already passes `-sdk` option -to the driver, so the option is only needed when the driver is invoked -directly. ---- - lib/Driver/Driver.cpp | 7 +++++++ - lib/Driver/ToolChains.cpp | 3 ++- - 2 files changed, 9 insertions(+), 1 deletion(-) - -diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp -index 955cf93c405..47dd1ea3e58 100644 ---- a/lib/Driver/Driver.cpp -+++ b/lib/Driver/Driver.cpp -@@ -1786,6 +1786,13 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args, - }); - } - } -+ } if (OI.SDKPath.empty() && TC.getTriple().isOSWASI()) { -+ llvm::SmallString<128> SDKPath; -+ llvm::sys::path::append(SDKPath, getSwiftProgramPath()); -+ llvm::sys::path::remove_filename(SDKPath); // 'swift' -+ llvm::sys::path::remove_filename(SDKPath); // 'bin' -+ llvm::sys::path::append(SDKPath, "share", "wasi-sysroot"); -+ OI.SDKPath = SDKPath.str().str(); - } - - if (!OI.SDKPath.empty()) { -diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp -index a290cc5e1d2..48a990a6f83 100644 ---- a/lib/Driver/ToolChains.cpp -+++ b/lib/Driver/ToolChains.cpp -@@ -1444,7 +1444,8 @@ void ToolChain::getResourceDirPath(SmallVectorImpl &resourceDirPath, - if (const Arg *A = args.getLastArg(options::OPT_resource_dir)) { - StringRef value = A->getValue(); - resourceDirPath.append(value.begin(), value.end()); -- } else if (!getTriple().isOSDarwin() && args.hasArg(options::OPT_sdk)) { -+ } else if (!getTriple().isOSDarwin() && !getTriple().isOSWASI() && args.hasArg(options::OPT_sdk)) { -+ // for WASI, sdk option points to wasi-sysroot which doesn't have Swift toolchain - StringRef value = args.getLastArg(options::OPT_sdk)->getValue(); - resourceDirPath.append(value.begin(), value.end()); - llvm::sys::path::append(resourceDirPath, "usr"); --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0009-wasm-Driver-HACK-Add-use-static-resource-dir-by-defa.patch b/schemes/release-5.9/swift/0009-wasm-Driver-HACK-Add-use-static-resource-dir-by-defa.patch deleted file mode 100644 index 913cef69..00000000 --- a/schemes/release-5.9/swift/0009-wasm-Driver-HACK-Add-use-static-resource-dir-by-defa.patch +++ /dev/null @@ -1,76 +0,0 @@ -From a2b60ad60f514c67d6f844279e3544e315806357 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 07:17:38 +0000 -Subject: [PATCH] [wasm][Driver] HACK: Add `-use-static-resource-dir` by - default for wasm target - -Currently, wasm target only supports static linking mode, so we add -`-use-static-resource-dir` by default for wasm target. This patch is not -an essential change because we can also add `-use-static-resource-dir` -in the driver invocation. But it is a convenient change for users. ---- - lib/Driver/Driver.cpp | 3 ++- - lib/Driver/ToolChains.cpp | 19 +++++++++++++++++-- - 2 files changed, 19 insertions(+), 3 deletions(-) - -diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp -index 47dd1ea3e58..782bda3b920 100644 ---- a/lib/Driver/Driver.cpp -+++ b/lib/Driver/Driver.cpp -@@ -2391,7 +2391,8 @@ bool Driver::handleImmediateArgs(const ArgList &Args, const ToolChain &TC) { - if (Args.hasFlag(options::OPT_static_executable, - options::OPT_no_static_executable, false) || - Args.hasFlag(options::OPT_static_stdlib, options::OPT_no_static_stdlib, -- false)) { -+ false) || -+ TC.getTriple().isOSBinFormatWasm()) { - commandLine.push_back("-use-static-resource-dir"); - } - -diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp -index 48a990a6f83..ce7a26dc99f 100644 ---- a/lib/Driver/ToolChains.cpp -+++ b/lib/Driver/ToolChains.cpp -@@ -638,7 +638,8 @@ ToolChain::constructInvocation(const CompileJobAction &job, - if (context.Args.hasFlag(options::OPT_static_executable, - options::OPT_no_static_executable, false) || - context.Args.hasFlag(options::OPT_static_stdlib, -- options::OPT_no_static_stdlib, false)) { -+ options::OPT_no_static_stdlib, false) || -+ getTriple().isOSBinFormatWasm()) { - Arguments.push_back("-use-static-resource-dir"); - } - -@@ -1160,7 +1161,13 @@ ToolChain::constructInvocation(const MergeModuleJobAction &job, - context.Args.AddLastArg(Arguments, options::OPT_import_objc_header); - - context.Args.AddLastArg(Arguments, options::OPT_disable_incremental_imports); -- -+ if (context.Args.hasFlag(options::OPT_static_executable, -+ options::OPT_no_static_executable, false) || -+ context.Args.hasFlag(options::OPT_static_stdlib, -+ options::OPT_no_static_stdlib, false) || -+ getTriple().isOSBinFormatWasm()) { -+ Arguments.push_back("-use-static-resource-dir"); -+ } - Arguments.push_back("-module-name"); - Arguments.push_back(context.Args.MakeArgString(context.OI.ModuleName)); - -@@ -1360,6 +1367,14 @@ ToolChain::constructInvocation(const GeneratePCHJobAction &job, - addInputsOfType(Arguments, context.InputActions, file_types::TY_ClangHeader); - context.Args.AddLastArg(Arguments, options::OPT_index_store_path); - -+ if (context.Args.hasFlag(options::OPT_static_executable, -+ options::OPT_no_static_executable, false) || -+ context.Args.hasFlag(options::OPT_static_stdlib, options::OPT_no_static_stdlib, -+ false) || -+ getTriple().isOSBinFormatWasm()) { -+ Arguments.push_back("-use-static-resource-dir"); -+ } -+ - if (job.isPersistentPCH()) { - Arguments.push_back("-emit-pch"); - Arguments.push_back("-pch-output-dir"); --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0010-wasm-IRGen-HACK-Disable-stack-protection.patch b/schemes/release-5.9/swift/0010-wasm-IRGen-HACK-Disable-stack-protection.patch deleted file mode 100644 index 5aef263d..00000000 --- a/schemes/release-5.9/swift/0010-wasm-IRGen-HACK-Disable-stack-protection.patch +++ /dev/null @@ -1,29 +0,0 @@ -From dd1f477ef72fbffd1623bfcd22d683727b485a8a Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 07:21:31 +0000 -Subject: [PATCH] [wasm][IRGen] HACK: Disable stack protection - -This is a temporary workaround until we can update wasi-sdk to version -17 or later, which includes stack protection support in wasi-libc. -https://github.com/WebAssembly/wasi-libc/commit/8b7148f69ae241a2749b3defe4606da8143b72e0 ---- - lib/IRGen/GenDecl.cpp | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/lib/IRGen/GenDecl.cpp b/lib/IRGen/GenDecl.cpp -index c3b65de0d0c..bdbb03a6349 100644 ---- a/lib/IRGen/GenDecl.cpp -+++ b/lib/IRGen/GenDecl.cpp -@@ -3323,7 +3323,8 @@ llvm::CallBase *swift::irgen::emitCXXConstructorCall( - - StackProtectorMode IRGenModule::shouldEmitStackProtector(SILFunction *f) { - const SILOptions &opts = IRGen.SIL.getOptions(); -- return (opts.EnableStackProtection && f->needsStackProtection()) ? -+ // FIXME(katei): stack protection support will be added by https://github.com/WebAssembly/wasi-libc/pull/351 -+ return (opts.EnableStackProtection && f->needsStackProtection() && Triple.getObjectFormat() != llvm::Triple::Wasm) ? - StackProtectorMode::StackProtector : StackProtectorMode::NoStackProtector; - } - --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0011-wasm-SIL-IRGen-HACK-Always-forward-extra-argument-to.patch b/schemes/release-5.9/swift/0011-wasm-SIL-IRGen-HACK-Always-forward-extra-argument-to.patch deleted file mode 100644 index dbb68c17..00000000 --- a/schemes/release-5.9/swift/0011-wasm-SIL-IRGen-HACK-Always-forward-extra-argument-to.patch +++ /dev/null @@ -1,246 +0,0 @@ -From 8ad12f77d2ca12c930730fd2ef4fc17561095d47 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 07:25:35 +0000 -Subject: [PATCH] [wasm][SIL/IRGen] HACK: Always forward extra argument to - match callee and caller signature - -This is a legacy solution for the KeyPath calling convention problem -described in https://forums.swift.org/t/wasm-support/16087/21. This -patch will be replaced by https://github.com/apple/swift/pull/66273 ---- - lib/IRGen/GenKeyPath.cpp | 7 +++- - lib/SIL/Verifier/SILVerifier.cpp | 10 +++-- - lib/SILGen/SILGenExpr.cpp | 39 +++++++++++++++++-- - .../SILCombiner/SILCombinerApplyVisitors.cpp | 14 +++++++ - lib/SILOptimizer/Utils/KeyPathProjector.cpp | 17 +++++++- - 5 files changed, 77 insertions(+), 10 deletions(-) - -diff --git a/lib/IRGen/GenKeyPath.cpp b/lib/IRGen/GenKeyPath.cpp -index d23a53e822c..dfd37ec2830 100644 ---- a/lib/IRGen/GenKeyPath.cpp -+++ b/lib/IRGen/GenKeyPath.cpp -@@ -224,7 +224,8 @@ getAccessorForComputedComponent(IRGenModule &IGM, - componentArgsBuf = params.claimNext(); - // Pass the argument pointer down to the underlying function, if it - // wants it. -- if (hasSubscriptIndices) { -+ // Always forward extra argument to match callee and caller signature on WebAssembly -+ if (hasSubscriptIndices || IGM.TargetInfo.OutputObjectFormat == llvm::Triple::Wasm) { - forwardedArgs.add(componentArgsBuf); - } - break; -@@ -250,6 +251,10 @@ getAccessorForComputedComponent(IRGenModule &IGM, - forwardingSubs, - &ignoreWitnessMetadata, - forwardedArgs); -+ } else if (IGM.Triple.isOSBinFormatWasm()) { -+ // wasm: Add null swift.type pointer to match signature even when there is -+ // no generic environment. -+ forwardedArgs.add(llvm::ConstantPointerNull::get(IGM.TypeMetadataPtrTy)); - } - auto fnPtr = - FunctionPointer::forDirect(IGM, accessorFn, /*secondaryValue*/ nullptr, -diff --git a/lib/SIL/Verifier/SILVerifier.cpp b/lib/SIL/Verifier/SILVerifier.cpp -index cc0634f09fd..6a98b3cf710 100644 ---- a/lib/SIL/Verifier/SILVerifier.cpp -+++ b/lib/SIL/Verifier/SILVerifier.cpp -@@ -299,8 +299,9 @@ void verifyKeyPathComponent(SILModule &M, - SILFunctionTypeRepresentation::Thin, - "getter should be a thin function"); - -- require(substGetterType->getNumParameters() == 1 + hasIndices, -- "getter should have one parameter"); -+ // FIXME(katei): Disabled for now. Will be replaced by keypath cc -+ // require(substGetterType->getNumParameters() == 1 + hasIndices, -+ // "getter should have one parameter"); - auto baseParam = substGetterType->getParameters()[0]; - require(baseParam.getConvention() == normalArgConvention, - "getter base parameter should have normal arg convention"); -@@ -351,8 +352,9 @@ void verifyKeyPathComponent(SILModule &M, - SILFunctionTypeRepresentation::Thin, - "setter should be a thin function"); - -- require(substSetterType->getNumParameters() == 2 + hasIndices, -- "setter should have two parameters"); -+ // FIXME(katei): Disabled for now. Will be replaced by keypath cc -+ // require(substSetterType->getNumParameters() == 2 + hasIndices, -+ // "setter should have two parameters"); - - auto newValueParam = substSetterType->getParameters()[0]; - // TODO: This should probably be unconditionally +1 when we -diff --git a/lib/SILGen/SILGenExpr.cpp b/lib/SILGen/SILGenExpr.cpp -index 96860888599..f1544e50337 100644 ---- a/lib/SILGen/SILGenExpr.cpp -+++ b/lib/SILGen/SILGenExpr.cpp -@@ -2987,6 +2987,7 @@ static SILFunction *getOrCreateKeyPathGetter(SILGenModule &SGM, - } - } - -+ auto Target = SGM.getASTContext().LangOpts.Target; - auto genericSig = - genericEnv ? genericEnv->getGenericSignature().getCanonicalSignature() - : nullptr; -@@ -2995,6 +2996,14 @@ static SILFunction *getOrCreateKeyPathGetter(SILGenModule &SGM, - genericEnv = nullptr; - } - -+ // Add empty generic type parameter to match function signature on WebAssembly -+ if (!genericSig && Target.isOSBinFormatWasm()) { -+ auto param = GenericTypeParamType::get(false, 0, 0, SGM.getASTContext()); -+ auto sig = GenericSignature::get(param, { }); -+ genericSig = CanGenericSignature(sig); -+ genericEnv = sig.getGenericEnvironment(); -+ } -+ - // Build the signature of the thunk as expected by the keypath runtime. - auto signature = [&]() { - CanType loweredBaseTy, loweredPropTy; -@@ -3010,7 +3019,8 @@ static SILFunction *getOrCreateKeyPathGetter(SILGenModule &SGM, - SmallVector params; - params.push_back({loweredBaseTy, paramConvention}); - auto &C = SGM.getASTContext(); -- if (!indexes.empty()) -+ // Always take indexes parameter to match callee and caller signature on WebAssembly -+ if (!indexes.empty() || C.LangOpts.Target.isOSBinFormatWasm()) - params.push_back({C.getUnsafeRawPointerType()->getCanonicalType(), - ParameterConvention::Direct_Unowned}); - -@@ -3070,7 +3080,8 @@ static SILFunction *getOrCreateKeyPathGetter(SILGenModule &SGM, - } - auto baseArg = entry->createFunctionArgument(baseArgTy); - SILValue indexPtrArg; -- if (!indexes.empty()) { -+ // Always take indexes parameter to match callee and caller signature on WebAssembly -+ if (!indexes.empty() || Target.isOSBinFormatWasm()) { - auto indexArgTy = signature->getParameters()[1].getSILStorageType( - SGM.M, signature, subSGF.F.getTypeExpansionContext()); - indexPtrArg = entry->createFunctionArgument(indexArgTy); -@@ -3159,6 +3170,7 @@ static SILFunction *getOrCreateKeyPathSetter(SILGenModule &SGM, - } - } - -+ auto Target = SGM.getASTContext().LangOpts.Target; - auto genericSig = - genericEnv ? genericEnv->getGenericSignature().getCanonicalSignature() - : nullptr; -@@ -3167,6 +3179,14 @@ static SILFunction *getOrCreateKeyPathSetter(SILGenModule &SGM, - genericEnv = nullptr; - } - -+ // Add empty generic type parameter to match function signature on WebAssembly -+ if (!genericSig && Target.isOSBinFormatWasm()) { -+ auto param = GenericTypeParamType::get(false, 0, 0, SGM.getASTContext()); -+ auto sig = GenericSignature::get(param, { }); -+ genericSig = CanGenericSignature(sig); -+ genericEnv = sig.getGenericEnvironment(); -+ } -+ - // Build the signature of the thunk as expected by the keypath runtime. - auto signature = [&]() { - CanType loweredBaseTy, loweredPropTy; -@@ -3192,7 +3212,8 @@ static SILFunction *getOrCreateKeyPathSetter(SILGenModule &SGM, - ? ParameterConvention::Indirect_Inout - : paramConvention}); - // indexes -- if (!indexes.empty()) -+ // Always take indexes parameter to match callee and caller signature on WebAssembly -+ if (!indexes.empty() || C.LangOpts.Target.isOSBinFormatWasm()) - params.push_back({C.getUnsafeRawPointerType()->getCanonicalType(), - ParameterConvention::Direct_Unowned}); - -@@ -3246,7 +3267,8 @@ static SILFunction *getOrCreateKeyPathSetter(SILGenModule &SGM, - auto baseArg = entry->createFunctionArgument(baseArgTy); - SILValue indexPtrArg; - -- if (!indexes.empty()) { -+ // Always take indexes parameter to match callee and caller signature on WebAssembly -+ if (!indexes.empty() || Target.isOSBinFormatWasm()) { - auto indexArgTy = signature->getParameters()[2].getSILStorageType( - SGM.M, signature, subSGF.getTypeExpansionContext()); - indexPtrArg = entry->createFunctionArgument(indexArgTy); -@@ -3336,6 +3358,7 @@ getOrCreateKeyPathEqualsAndHash(SILGenModule &SGM, - return; - } - -+ auto Target = SGM.getASTContext().LangOpts.Target; - auto genericSig = - genericEnv ? genericEnv->getGenericSignature().getCanonicalSignature() - : nullptr; -@@ -3345,6 +3368,14 @@ getOrCreateKeyPathEqualsAndHash(SILGenModule &SGM, - genericEnv = nullptr; - } - -+ // Add empty generic type parameter to match function signature on WebAssembly -+ if (!genericSig && Target.isOSBinFormatWasm()) { -+ auto param = GenericTypeParamType::get(false, 0, 0, SGM.getASTContext()); -+ auto sig = GenericSignature::get(param, { }); -+ genericSig = CanGenericSignature(sig); -+ genericEnv = sig.getGenericEnvironment(); -+ } -+ - auto &C = SGM.getASTContext(); - auto unsafeRawPointerTy = C.getUnsafeRawPointerType()->getCanonicalType(); - auto boolTy = C.getBoolType()->getCanonicalType(); -diff --git a/lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp b/lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp -index 6bf48c3d7f1..9b89e9d78e4 100644 ---- a/lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp -+++ b/lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp -@@ -505,6 +505,13 @@ bool SILCombiner::tryOptimizeKeypathKVCString(ApplyInst *AI, - } - - bool SILCombiner::tryOptimizeKeypath(ApplyInst *AI) { -+ // FIXME(katei): Disable for WebAssembly for now because -+ // KeyPath cc is unstable and KeyPathProjector hask violates -+ // some assert assumptions -+ SILModule &M = AI->getModule(); -+ if (M.getASTContext().LangOpts.Target.isOSBinFormatWasm()) -+ return false; -+ - if (SILFunction *callee = AI->getReferencedFunctionOrNull()) { - return tryOptimizeKeypathApplication(AI, callee); - } -@@ -550,6 +557,13 @@ bool SILCombiner::tryOptimizeKeypath(ApplyInst *AI) { - /// %addr = struct_element_addr/ref_element_addr %root_object - /// // use %inout_addr - bool SILCombiner::tryOptimizeInoutKeypath(BeginApplyInst *AI) { -+ // FIXME(katei): Disable for WebAssembly for now because -+ // KeyPath cc is unstable and KeyPathProjector hask violates -+ // some assert assumptions -+ SILModule &M = AI->getModule(); -+ if (M.getASTContext().LangOpts.Target.isOSBinFormatWasm()) -+ return false; -+ - // Disable in OSSA because KeyPathProjector is not fully ported - if (AI->getFunction()->hasOwnership()) - return false; -diff --git a/lib/SILOptimizer/Utils/KeyPathProjector.cpp b/lib/SILOptimizer/Utils/KeyPathProjector.cpp -index 073ba49a563..6950ab4ae10 100644 ---- a/lib/SILOptimizer/Utils/KeyPathProjector.cpp -+++ b/lib/SILOptimizer/Utils/KeyPathProjector.cpp -@@ -233,7 +233,22 @@ public: - assert(getter->getConventions().getNumSILArguments()); - - auto ref = builder.createFunctionRef(loc, getter); -- builder.createApply(loc, ref, subs, {addr, parentValue}); -+ -+ std::vector args{addr, parentValue}; -+ // FIXME(wasm): For wasm, KeyPath getter always take indices parameter -+ // to match callee and caller signature. So need to pass stub pointer. -+ // See also: getOrCreateKeyPathSetter and getOrCreateKeyPathGetter -+ if (builder.getASTContext().LangOpts.Target.isOSBinFormatWasm()) { -+ auto IntTy = SILType::getBuiltinIntegerType(32, builder.getASTContext()); -+ auto UnsafeRawPointerTy = SILType::getRawPointerType(builder.getASTContext()); -+ auto zeroVal = SILValue(builder.createIntegerLiteral(loc, IntTy, 0)); -+ auto stackBuffer = SILValue(builder.createAllocStack(loc, IntTy)); -+ builder.createStore(loc, zeroVal, stackBuffer, StoreOwnershipQualifier::Unqualified); -+ auto nonePointer = builder.createUncheckedAddrCast(loc, stackBuffer, UnsafeRawPointerTy); -+ args.push_back(SILValue(nonePointer)); -+ } -+ -+ builder.createApply(loc, ref, subs, args); - - // If we were previously accessing a class member, we're done now. - insertEndAccess(beginAccess, builder); --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0012-wasm-stdlib-Enable-wasi-libc-emulations-to-build-std.patch b/schemes/release-5.9/swift/0012-wasm-stdlib-Enable-wasi-libc-emulations-to-build-std.patch deleted file mode 100644 index 047ce066..00000000 --- a/schemes/release-5.9/swift/0012-wasm-stdlib-Enable-wasi-libc-emulations-to-build-std.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 4a86057317789e84649c557f554fa24a23dc047a Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 07:31:23 +0000 -Subject: [PATCH] [wasm][stdlib] Enable wasi-libc emulations to build stdlib - -But I'm not sure all of them are actually needed. ---- - stdlib/cmake/modules/AddSwiftStdlib.cmake | 2 +- - stdlib/cmake/modules/SwiftSource.cmake | 4 ++++ - 2 files changed, 5 insertions(+), 1 deletion(-) - -diff --git a/stdlib/cmake/modules/AddSwiftStdlib.cmake b/stdlib/cmake/modules/AddSwiftStdlib.cmake -index 84a50a4d3f5..fbd274f1490 100644 ---- a/stdlib/cmake/modules/AddSwiftStdlib.cmake -+++ b/stdlib/cmake/modules/AddSwiftStdlib.cmake -@@ -333,7 +333,7 @@ function(_add_target_variant_c_compile_flags) - endif() - - if("${CFLAGS_SDK}" STREQUAL "WASI") -- list(APPEND result "-D_WASI_EMULATED_MMAN") -+ list(APPEND result "-D_WASI_EMULATED_MMAN" "-D_WASI_EMULATED_SIGNAL" "-D_WASI_EMULATED_PROCESS_CLOCKS") - endif() - - if(NOT SWIFT_STDLIB_ENABLE_OBJC_INTEROP) -diff --git a/stdlib/cmake/modules/SwiftSource.cmake b/stdlib/cmake/modules/SwiftSource.cmake -index cc4b3398823..c77a21c02df 100644 ---- a/stdlib/cmake/modules/SwiftSource.cmake -+++ b/stdlib/cmake/modules/SwiftSource.cmake -@@ -244,6 +244,10 @@ function(_add_target_variant_swift_compile_flags - "-target" "${SWIFT_SDK_${sdk}_ARCH_${arch}_TRIPLE}") - endif() - -+ if("${sdk}" STREQUAL "WASI") -+ list(APPEND result "-Xcc" "-D_WASI_EMULATED_MMAN" "-Xcc" "-D_WASI_EMULATED_SIGNAL" "-Xcc" "-D_WASI_EMULATED_PROCESS_CLOCKS") -+ endif() -+ - if(NOT BUILD_STANDALONE) - list(APPEND result "-resource-dir" "${SWIFTLIB_DIR}") - endif() --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0013-stdlib-Propagate-SWIFT_STDLIB_SINGLE_THREADED_RUNTIM.patch b/schemes/release-5.9/swift/0013-stdlib-Propagate-SWIFT_STDLIB_SINGLE_THREADED_RUNTIM.patch deleted file mode 100644 index fd8f7875..00000000 --- a/schemes/release-5.9/swift/0013-stdlib-Propagate-SWIFT_STDLIB_SINGLE_THREADED_RUNTIM.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 8d2f07cb976916a345ded0bf96ba6ae7f419d0c3 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 07:34:30 +0000 -Subject: [PATCH] [stdlib] Propagate `SWIFT_STDLIB_SINGLE_THREADED_RUNTIME` - -This change may be unnecessary now ---- - stdlib/cmake/modules/SwiftSource.cmake | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/stdlib/cmake/modules/SwiftSource.cmake b/stdlib/cmake/modules/SwiftSource.cmake -index c77a21c02df..4a2c70cbe5e 100644 ---- a/stdlib/cmake/modules/SwiftSource.cmake -+++ b/stdlib/cmake/modules/SwiftSource.cmake -@@ -327,6 +327,10 @@ function(_add_target_variant_swift_compile_flags - list(APPEND result "-D" "SWIFT_STDLIB_HAS_STDIN") - endif() - -+ if(SWIFT_STDLIB_SINGLE_THREADED_RUNTIME) -+ list(APPEND result "-DSWIFT_STDLIB_SINGLE_THREADED_RUNTIME") -+ endif() -+ - if(SWIFT_STDLIB_HAS_ENVIRON) - list(APPEND result "-D" "SWIFT_STDLIB_HAS_ENVIRON") - list(APPEND result "-Xcc" "-DSWIFT_STDLIB_HAS_ENVIRON") --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0014-test-Avoid-building-unnecessary-targets-when-cross-c.patch b/schemes/release-5.9/swift/0014-test-Avoid-building-unnecessary-targets-when-cross-c.patch deleted file mode 100644 index b4841561..00000000 --- a/schemes/release-5.9/swift/0014-test-Avoid-building-unnecessary-targets-when-cross-c.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0863aa9106d1612dce817b2fe0ef4f851e17ee3a Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 07:40:05 +0000 -Subject: [PATCH] [test] Avoid building unnecessary targets when - cross-compiling non-Darwin platforms - ---- - stdlib/private/CMakeLists.txt | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/stdlib/private/CMakeLists.txt b/stdlib/private/CMakeLists.txt -index 704d96f9248..7b04ee4e39c 100644 ---- a/stdlib/private/CMakeLists.txt -+++ b/stdlib/private/CMakeLists.txt -@@ -23,7 +23,8 @@ endif() - if(SWIFT_BUILD_SDK_OVERLAY) - add_subdirectory(OSLog) - -- if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") -+ list_intersect("${SWIFT_APPLE_PLATFORMS}" "${SWIFT_SDKS}" building_darwin_sdks) -+ if(building_darwin_sdks) - add_subdirectory(StdlibUnittestFoundationExtras) - endif() - # Currently SwiftReflectionTest cannot be built on Windows, due to --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0015-wasm-cmake-Add-WASI-specific-stdlib-dependencies.patch b/schemes/release-5.9/swift/0015-wasm-cmake-Add-WASI-specific-stdlib-dependencies.patch deleted file mode 100644 index a0836165..00000000 --- a/schemes/release-5.9/swift/0015-wasm-cmake-Add-WASI-specific-stdlib-dependencies.patch +++ /dev/null @@ -1,105 +0,0 @@ -From f50ef3b2e9ff612dcd2b93bb7f7044054cee2265 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 07:50:16 +0000 -Subject: [PATCH] [wasm][cmake] Add WASI specific stdlib dependencies - -Currently WASI target doesn't support SwiftPrivateThreadExtras, so we -need to remove it from the common dependencies. Also WASI target has its -own libc module WASILibc, so we need to add it as well as other libc modules. ---- - stdlib/private/StdlibUnittest/CMakeLists.txt | 27 ++++++++++--------- - stdlib/private/SwiftPrivate/CMakeLists.txt | 1 + - .../SwiftPrivateLibcExtras/CMakeLists.txt | 1 + - .../SwiftPrivateThreadExtras/CMakeLists.txt | 1 + - stdlib/public/Differentiation/CMakeLists.txt | 1 + - 5 files changed, 18 insertions(+), 13 deletions(-) - -diff --git a/stdlib/private/StdlibUnittest/CMakeLists.txt b/stdlib/private/StdlibUnittest/CMakeLists.txt -index a8a3f17b60b..714cca193cf 100644 ---- a/stdlib/private/StdlibUnittest/CMakeLists.txt -+++ b/stdlib/private/StdlibUnittest/CMakeLists.txt -@@ -49,19 +49,20 @@ add_swift_target_library(swiftStdlibUnittest ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} - TestHelpers.swift - TypeIndexed.swift - -- SWIFT_MODULE_DEPENDS SwiftPrivate SwiftPrivateThreadExtras SwiftPrivateLibcExtras ${swift_stdlib_unittest_modules} -- SWIFT_MODULE_DEPENDS_IOS Darwin -- SWIFT_MODULE_DEPENDS_OSX Darwin -- SWIFT_MODULE_DEPENDS_TVOS Darwin -- SWIFT_MODULE_DEPENDS_WATCHOS Darwin -- SWIFT_MODULE_DEPENDS_MACCATALYST Darwin -- SWIFT_MODULE_DEPENDS_FREESTANDING "${SWIFT_FREESTANDING_TEST_DEPENDENCIES}" -- SWIFT_MODULE_DEPENDS_LINUX Glibc -- SWIFT_MODULE_DEPENDS_FREEBSD Glibc -- SWIFT_MODULE_DEPENDS_OPENBSD Glibc -- SWIFT_MODULE_DEPENDS_CYGWIN Glibc -- SWIFT_MODULE_DEPENDS_HAIKU Glibc -- SWIFT_MODULE_DEPENDS_WINDOWS CRT WinSDK -+ SWIFT_MODULE_DEPENDS SwiftPrivate SwiftPrivateLibcExtras ${swift_stdlib_unittest_modules} -+ SWIFT_MODULE_DEPENDS_IOS Darwin SwiftPrivateThreadExtras -+ SWIFT_MODULE_DEPENDS_OSX Darwin SwiftPrivateThreadExtras -+ SWIFT_MODULE_DEPENDS_TVOS Darwin SwiftPrivateThreadExtras -+ SWIFT_MODULE_DEPENDS_WATCHOS Darwin SwiftPrivateThreadExtras -+ SWIFT_MODULE_DEPENDS_MACCATALYST Darwin SwiftPrivateThreadExtras -+ SWIFT_MODULE_DEPENDS_FREESTANDING "${SWIFT_FREESTANDING_TEST_DEPENDENCIES}" SwiftPrivateThreadExtras -+ SWIFT_MODULE_DEPENDS_LINUX Glibc SwiftPrivateThreadExtras -+ SWIFT_MODULE_DEPENDS_FREEBSD Glibc SwiftPrivateThreadExtras -+ SWIFT_MODULE_DEPENDS_OPENBSD Glibc SwiftPrivateThreadExtras -+ SWIFT_MODULE_DEPENDS_CYGWIN Glibc SwiftPrivateThreadExtras -+ SWIFT_MODULE_DEPENDS_HAIKU Glibc SwiftPrivateThreadExtras -+ SWIFT_MODULE_DEPENDS_WASI WASILibc -+ SWIFT_MODULE_DEPENDS_WINDOWS CRT WinSDK SwiftPrivateThreadExtras - C_COMPILE_FLAGS -I${SWIFT_SOURCE_DIR}/stdlib/include - SWIFT_COMPILE_FLAGS ${swift_stdlib_unittest_compile_flags} ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS} - INSTALL_IN_COMPONENT stdlib-experimental -diff --git a/stdlib/private/SwiftPrivate/CMakeLists.txt b/stdlib/private/SwiftPrivate/CMakeLists.txt -index a1fc412a156..f1e7d461d0e 100644 ---- a/stdlib/private/SwiftPrivate/CMakeLists.txt -+++ b/stdlib/private/SwiftPrivate/CMakeLists.txt -@@ -26,6 +26,7 @@ add_swift_target_library(swiftSwiftPrivate ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I - SWIFT_MODULE_DEPENDS_OPENBSD Glibc - SWIFT_MODULE_DEPENDS_CYGWIN Glibc - SWIFT_MODULE_DEPENDS_HAIKU Glibc -+ SWIFT_MODULE_DEPENDS_WASI WASILibc - SWIFT_MODULE_DEPENDS_WINDOWS CRT WinSDK - SWIFT_COMPILE_FLAGS ${swift_swiftprivate_compile_flags} ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS} - INSTALL_IN_COMPONENT stdlib-experimental -diff --git a/stdlib/private/SwiftPrivateLibcExtras/CMakeLists.txt b/stdlib/private/SwiftPrivateLibcExtras/CMakeLists.txt -index 9095a700838..b8058031de8 100644 ---- a/stdlib/private/SwiftPrivateLibcExtras/CMakeLists.txt -+++ b/stdlib/private/SwiftPrivateLibcExtras/CMakeLists.txt -@@ -36,6 +36,7 @@ add_swift_target_library(swiftSwiftPrivateLibcExtras ${SWIFT_STDLIB_LIBRARY_BUIL - SWIFT_MODULE_DEPENDS_OPENBSD Glibc - SWIFT_MODULE_DEPENDS_CYGWIN Glibc - SWIFT_MODULE_DEPENDS_HAIKU Glibc -+ SWIFT_MODULE_DEPENDS_WASI WASILibc - SWIFT_MODULE_DEPENDS_WINDOWS CRT WinSDK - INCORPORATE_OBJECT_LIBRARIES ${swift_private_libc_extras_incorporate_object_libraries} - INSTALL_IN_COMPONENT stdlib-experimental -diff --git a/stdlib/private/SwiftPrivateThreadExtras/CMakeLists.txt b/stdlib/private/SwiftPrivateThreadExtras/CMakeLists.txt -index 35fcf24881c..52d2e28b9f5 100644 ---- a/stdlib/private/SwiftPrivateThreadExtras/CMakeLists.txt -+++ b/stdlib/private/SwiftPrivateThreadExtras/CMakeLists.txt -@@ -17,6 +17,7 @@ add_swift_target_library(swiftSwiftPrivateThreadExtras ${SWIFT_STDLIB_LIBRARY_BU - SWIFT_MODULE_DEPENDS_OPENBSD Glibc - SWIFT_MODULE_DEPENDS_CYGWIN Glibc - SWIFT_MODULE_DEPENDS_HAIKU Glibc -+ SWIFT_MODULE_DEPENDS_WASI WASILibc - SWIFT_MODULE_DEPENDS_WINDOWS CRT WinSDK - SWIFT_COMPILE_FLAGS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS} - INSTALL_IN_COMPONENT stdlib-experimental -diff --git a/stdlib/public/Differentiation/CMakeLists.txt b/stdlib/public/Differentiation/CMakeLists.txt -index aa895c02bc8..30ad34900c7 100644 ---- a/stdlib/public/Differentiation/CMakeLists.txt -+++ b/stdlib/public/Differentiation/CMakeLists.txt -@@ -40,6 +40,7 @@ add_swift_target_library(swift_Differentiation ${SWIFT_STDLIB_LIBRARY_BUILD_TYPE - SWIFT_MODULE_DEPENDS_OPENBSD Glibc - SWIFT_MODULE_DEPENDS_CYGWIN Glibc - SWIFT_MODULE_DEPENDS_HAIKU Glibc -+ SWIFT_MODULE_DEPENDS_WASI WASILibc - SWIFT_MODULE_DEPENDS_WINDOWS CRT - - C_COMPILE_FLAGS --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0016-wasm-test-Fix-build-of-StdlibUnittest-on-WASI.patch b/schemes/release-5.9/swift/0016-wasm-test-Fix-build-of-StdlibUnittest-on-WASI.patch deleted file mode 100644 index ac334276..00000000 --- a/schemes/release-5.9/swift/0016-wasm-test-Fix-build-of-StdlibUnittest-on-WASI.patch +++ /dev/null @@ -1,141 +0,0 @@ -From f2bbb9827dabd4799b4f8e67b37986c2fb52cff8 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 07:53:38 +0000 -Subject: [PATCH] [wasm][test] Fix build of StdlibUnittest on WASI - -WASI platform doesn't support crash interception and spawning -threads/processes. So this patch disables interception support and -subprocess spawning. The later patch will disable crash tests in each -test case. ---- - .../private/StdlibUnittest/InterceptTraps.cpp | 6 +++--- - stdlib/private/StdlibUnittest/RaceTest.swift | 2 ++ - .../StdlibUnittest/StdlibUnittest.swift | 20 +++++++++++++++++-- - 3 files changed, 23 insertions(+), 5 deletions(-) - -diff --git a/stdlib/private/StdlibUnittest/InterceptTraps.cpp b/stdlib/private/StdlibUnittest/InterceptTraps.cpp -index 80c3fa59795..cf81e872556 100644 ---- a/stdlib/private/StdlibUnittest/InterceptTraps.cpp -+++ b/stdlib/private/StdlibUnittest/InterceptTraps.cpp -@@ -50,8 +50,6 @@ static void CrashCatcher(int Sig) { - _exit(0); - } - --#endif // __wasi__ -- - #if defined(_WIN32) - static LONG WINAPI - VectoredCrashHandler(PEXCEPTION_POINTERS ExceptionInfo) { -@@ -92,6 +90,8 @@ void installTrapInterceptor() { - signal(SIGBUS, CrashCatcher); - signal(SIGSYS, CrashCatcher); - #endif --} - - #endif // !defined(__wasi__) -+} -+ -+#endif // !defined(__wasi__) -\ No newline at end of file -diff --git a/stdlib/private/StdlibUnittest/RaceTest.swift b/stdlib/private/StdlibUnittest/RaceTest.swift -index 008f17a5200..368f49d7000 100644 ---- a/stdlib/private/StdlibUnittest/RaceTest.swift -+++ b/stdlib/private/StdlibUnittest/RaceTest.swift -@@ -38,7 +38,9 @@ - - import SwiftPrivate - import SwiftPrivateLibcExtras -+#if !os(WASI) - import SwiftPrivateThreadExtras -+#endif - #if canImport(Darwin) - import Darwin - #elseif canImport(Glibc) -diff --git a/stdlib/private/StdlibUnittest/StdlibUnittest.swift b/stdlib/private/StdlibUnittest/StdlibUnittest.swift -index d6e3f90bae2..f3ac00c80e6 100644 ---- a/stdlib/private/StdlibUnittest/StdlibUnittest.swift -+++ b/stdlib/private/StdlibUnittest/StdlibUnittest.swift -@@ -12,7 +12,9 @@ - - - import SwiftPrivate -+#if !os(WASI) - import SwiftPrivateThreadExtras -+#endif - import SwiftPrivateLibcExtras - - #if canImport(Darwin) -@@ -22,6 +24,8 @@ import Foundation - import Darwin - #elseif canImport(Glibc) - import Glibc -+#elseif os(WASI) -+import WASILibc - #elseif os(Windows) - import CRT - import WinSDK -@@ -35,6 +39,12 @@ import ObjectiveC - import _Concurrency - #endif - -+#if os(WASI) -+let platformSupportSpawnChild = false -+#else -+let platformSupportSpawnChild = true -+#endif -+ - extension String { - /// Returns the lines in `self`. - public var _lines : [String] { -@@ -855,8 +865,10 @@ var _testSuiteNameToIndex: [String : Int] = [:] - let _stdlibUnittestStreamPrefix = "__STDLIB_UNITTEST__" - let _crashedPrefix = "CRASHED:" - -+#if !os(WASI) - @_silgen_name("installTrapInterceptor") - func _installTrapInterceptor() -+#endif - - #if _runtime(_ObjC) - @objc protocol _StdlibUnittestNSException { -@@ -867,7 +879,9 @@ func _installTrapInterceptor() - // Avoid serializing references to objc_setUncaughtExceptionHandler in SIL. - @inline(never) - func _childProcess() { -+#if !os(WASI) - _installTrapInterceptor() -+#endif - - #if _runtime(_ObjC) - objc_setUncaughtExceptionHandler { -@@ -923,7 +937,9 @@ func _childProcess() { - @available(SwiftStdlib 5.1, *) - @inline(never) - func _childProcessAsync() async { -+#if !os(WASI) - _installTrapInterceptor() -+#endif - - #if _runtime(_ObjC) - objc_setUncaughtExceptionHandler { -@@ -1724,7 +1740,7 @@ public func runAllTests() { - if _isChildProcess { - _childProcess() - } else { -- var runTestsInProcess: Bool = false -+ var runTestsInProcess: Bool = !platformSupportSpawnChild - var filter: String? - var args = [String]() - var i = 0 -@@ -1794,7 +1810,7 @@ public func runAllTestsAsync() async { - if _isChildProcess { - await _childProcessAsync() - } else { -- var runTestsInProcess: Bool = false -+ var runTestsInProcess: Bool = !platformSupportSpawnChild - var filter: String? - var args = [String]() - var i = 0 --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0017-wasm-stdlib-Fix-build-of-SwiftPrivate-on-WASI.patch b/schemes/release-5.9/swift/0017-wasm-stdlib-Fix-build-of-SwiftPrivate-on-WASI.patch deleted file mode 100644 index 3f173328..00000000 --- a/schemes/release-5.9/swift/0017-wasm-stdlib-Fix-build-of-SwiftPrivate-on-WASI.patch +++ /dev/null @@ -1,37 +0,0 @@ -From f327ad1413a65f0506484ad7dd8f3d0659ad8ec4 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 07:57:26 +0000 -Subject: [PATCH] [wasm][stdlib] Fix build of SwiftPrivate on WASI - -Just support WASILibc as well as other libc modules ---- - stdlib/private/SwiftPrivate/IO.swift | 10 +++++++--- - 1 file changed, 7 insertions(+), 3 deletions(-) - -diff --git a/stdlib/private/SwiftPrivate/IO.swift b/stdlib/private/SwiftPrivate/IO.swift -index ba5d26515c3..dac3f39dc11 100644 ---- a/stdlib/private/SwiftPrivate/IO.swift -+++ b/stdlib/private/SwiftPrivate/IO.swift -@@ -16,12 +16,16 @@ import SwiftShims - #if canImport(Darwin) - import Darwin - let (platform_read, platform_write, platform_close) = (read, write, close) --#elseif canImport(Glibc) --import Glibc --let (platform_read, platform_write, platform_close) = (read, write, close) - #elseif os(Windows) - import CRT - import WinSDK -+#else -+#if os(WASI) -+import WASILibc -+#elseif canImport(Glibc) -+import Glibc -+#endif -+let (platform_read, platform_write, platform_close) = (read, write, close) - #endif - - #if os(Windows) --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0018-Concurrency-Fix-calling-convention-mismatch-in-Async.patch b/schemes/release-5.9/swift/0018-Concurrency-Fix-calling-convention-mismatch-in-Async.patch deleted file mode 100644 index 94671826..00000000 --- a/schemes/release-5.9/swift/0018-Concurrency-Fix-calling-convention-mismatch-in-Async.patch +++ /dev/null @@ -1,79 +0,0 @@ -From 54321121f0ed62381dd46fedbc23e25b585bcc0c Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Sun, 11 Jun 2023 12:12:52 +0000 -Subject: [PATCH] [Concurrency] Fix calling convention mismatch in AsyncStream - -Functions defined in AsyncStream.cpp are called from Swift with swiftcc -but are defined with the C calling convention. ---- - stdlib/public/BackDeployConcurrency/AsyncStream.cpp | 5 +++++ - stdlib/public/Concurrency/AsyncStream.cpp | 5 +++++ - 2 files changed, 10 insertions(+) - -diff --git a/stdlib/public/BackDeployConcurrency/AsyncStream.cpp b/stdlib/public/BackDeployConcurrency/AsyncStream.cpp -index 389ebd3d738..57031e53d0e 100644 ---- a/stdlib/public/BackDeployConcurrency/AsyncStream.cpp -+++ b/stdlib/public/BackDeployConcurrency/AsyncStream.cpp -@@ -12,10 +12,12 @@ - - #include - -+#include "swift/Runtime/Config.h" - #include "swift/Threading/Mutex.h" - - namespace swift { - // return the size in words for the given mutex primitive -+SWIFT_CC(swift) - extern "C" - size_t _swift_async_stream_lock_size() { - size_t words = sizeof(Mutex) / sizeof(void *); -@@ -23,11 +25,14 @@ size_t _swift_async_stream_lock_size() { - return words; - } - -+SWIFT_CC(swift) - extern "C" void _swift_async_stream_lock_init(Mutex &lock) { - new (&lock) Mutex(); - } - -+SWIFT_CC(swift) - extern "C" void _swift_async_stream_lock_lock(Mutex &lock) { lock.lock(); } - -+SWIFT_CC(swift) - extern "C" void _swift_async_stream_lock_unlock(Mutex &lock) { lock.unlock(); } - } -diff --git a/stdlib/public/Concurrency/AsyncStream.cpp b/stdlib/public/Concurrency/AsyncStream.cpp -index 389ebd3d738..57031e53d0e 100644 ---- a/stdlib/public/Concurrency/AsyncStream.cpp -+++ b/stdlib/public/Concurrency/AsyncStream.cpp -@@ -12,10 +12,12 @@ - - #include - -+#include "swift/Runtime/Config.h" - #include "swift/Threading/Mutex.h" - - namespace swift { - // return the size in words for the given mutex primitive -+SWIFT_CC(swift) - extern "C" - size_t _swift_async_stream_lock_size() { - size_t words = sizeof(Mutex) / sizeof(void *); -@@ -23,11 +25,14 @@ size_t _swift_async_stream_lock_size() { - return words; - } - -+SWIFT_CC(swift) - extern "C" void _swift_async_stream_lock_init(Mutex &lock) { - new (&lock) Mutex(); - } - -+SWIFT_CC(swift) - extern "C" void _swift_async_stream_lock_lock(Mutex &lock) { lock.lock(); } - -+SWIFT_CC(swift) - extern "C" void _swift_async_stream_lock_unlock(Mutex &lock) { lock.unlock(); } - } --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0019-wasm-stdlib-Stop-including-stdint.h-in-wasi-libc-for.patch b/schemes/release-5.9/swift/0019-wasm-stdlib-Stop-including-stdint.h-in-wasi-libc-for.patch deleted file mode 100644 index 05720925..00000000 --- a/schemes/release-5.9/swift/0019-wasm-stdlib-Stop-including-stdint.h-in-wasi-libc-for.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 08b878d1968699997f3243daed480922c31b6ad5 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 08:02:13 +0000 -Subject: [PATCH] [wasm][stdlib] Stop including stdint.h in wasi-libc for - SwiftShims - -To avoid `error: 'stddef.h' file not found' issue described in -SwiftStdint.h ---- - stdlib/public/SwiftShims/swift/shims/SwiftStdint.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/stdlib/public/SwiftShims/swift/shims/SwiftStdint.h b/stdlib/public/SwiftShims/swift/shims/SwiftStdint.h -index cd8d808cbd6..386186df096 100644 ---- a/stdlib/public/SwiftShims/swift/shims/SwiftStdint.h -+++ b/stdlib/public/SwiftShims/swift/shims/SwiftStdint.h -@@ -24,7 +24,7 @@ - - // Clang has been defining __INTxx_TYPE__ macros for a long time. - // __UINTxx_TYPE__ are defined only since Clang 3.5. --#if !defined(__APPLE__) && !defined(__linux__) && !defined(__OpenBSD__) -+#if !defined(__APPLE__) && !defined(__linux__) && !defined(__OpenBSD__) && !defined(__wasi__) - #include - typedef int64_t __swift_int64_t; - typedef uint64_t __swift_uint64_t; --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0020-stdlib-Fix-calling-convention-mismatch-for-debugger-.patch b/schemes/release-5.9/swift/0020-stdlib-Fix-calling-convention-mismatch-for-debugger-.patch deleted file mode 100644 index 846983f7..00000000 --- a/schemes/release-5.9/swift/0020-stdlib-Fix-calling-convention-mismatch-for-debugger-.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 39f3cc98e884fce90ef3990ecb7b2815150ed6ac Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Fri, 9 Jun 2023 16:23:39 +0000 -Subject: [PATCH] [stdlib] Fix calling convention mismatch for debugger utility - functions - -The functions `swift_retainCount`, `swift_unownedRetainCount`, and -`swift_weakRetainCount` are declared in `HeapObject.h` as using -the C calling convention, but the Swift declarations referenced them -by `@_silgen_name`, which uses the Swift calling convention. This -patch fixes the mismatch without any ABI/API breakage by calling the -utility functions through C interop. ---- - stdlib/public/core/DebuggerSupport.swift | 15 +++++++++------ - 1 file changed, 9 insertions(+), 6 deletions(-) - -diff --git a/stdlib/public/core/DebuggerSupport.swift b/stdlib/public/core/DebuggerSupport.swift -index ef9eafeab81..c8c77d26400 100644 ---- a/stdlib/public/core/DebuggerSupport.swift -+++ b/stdlib/public/core/DebuggerSupport.swift -@@ -269,9 +269,12 @@ public func _stringForPrintObject(_ value: Any) -> String { - public func _debuggerTestingCheckExpect(_: String, _: String) { } - - // Utilities to get refcount(s) of class objects. --@_silgen_name("swift_retainCount") --public func _getRetainCount(_ Value: AnyObject) -> UInt --@_silgen_name("swift_unownedRetainCount") --public func _getUnownedRetainCount(_ Value: AnyObject) -> UInt --@_silgen_name("swift_weakRetainCount") --public func _getWeakRetainCount(_ Value: AnyObject) -> UInt -+public func _getRetainCount(_ Value: AnyObject) -> UInt { -+ return UInt(swift_retainCount(unsafeBitCast(Value, to: UnsafeMutablePointer.self))) -+} -+public func _getUnownedRetainCount(_ Value: AnyObject) -> UInt { -+ return UInt(swift_unownedRetainCount(unsafeBitCast(Value, to: UnsafeMutablePointer.self))) -+} -+public func _getWeakRetainCount(_ Value: AnyObject) -> UInt { -+ return UInt(swift_weakRetainCount(unsafeBitCast(Value, to: UnsafeMutablePointer.self))) -+} --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0021-wasm-build-Install-ICU-static-libraries-under-swift_.patch b/schemes/release-5.9/swift/0021-wasm-build-Install-ICU-static-libraries-under-swift_.patch deleted file mode 100644 index 2864d33c..00000000 --- a/schemes/release-5.9/swift/0021-wasm-build-Install-ICU-static-libraries-under-swift_.patch +++ /dev/null @@ -1,77 +0,0 @@ -From fadee93a1ea5effe6bc137a02c5757c9ed096365 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 08:14:18 +0000 -Subject: [PATCH] [wasm][build] Install ICU static libraries under swift_static - ---- - stdlib/public/runtime/CMakeLists.txt | 43 ++++++++++++++++++++++++++++ - 1 file changed, 43 insertions(+) - -diff --git a/stdlib/public/runtime/CMakeLists.txt b/stdlib/public/runtime/CMakeLists.txt -index 4881410d6a8..be7f63e5e92 100644 ---- a/stdlib/public/runtime/CMakeLists.txt -+++ b/stdlib/public/runtime/CMakeLists.txt -@@ -258,10 +258,31 @@ foreach(sdk ${SWIFT_SDKS}) - add_dependencies(stdlib swift-stdlib-${arch_suffix} swiftImageRegistration-${arch_suffix}) - endif() - -+ string(TOLOWER "${sdk}" lowercase_sdk) - # Generate the static-stdlib-args.lnk file used by -static-stdlib option for - # 'GenericUnix' (eg linux) - if(SWIFT_SDK_${sdk}_OBJECT_FORMAT STREQUAL "ELF") - string(TOLOWER "${sdk}" lowercase_sdk) -+ if(SWIFT_${SWIFT_HOST_VARIANT_SDK}_${SWIFT_HOST_VARIANT_ARCH}_ICU_STATICLIB) -+ set(libicu_i18n_a -licui18nswift) -+ set(libicu_uc_a -licuucswift) -+ set(libicu_data_a -licudataswift) -+ else() -+ find_package(ICU REQUIRED COMPONENTS uc i18n) -+ get_filename_component(ICU_UC_LIBDIR "${ICU_UC_LIBRARIES}" DIRECTORY) -+ get_filename_component(ICU_I18N_LIBDIR "${ICU_I18N_LIBRARIES}" DIRECTORY) -+ -+ set(libicu_i18n_a -licui18n) -+ set(libicu_uc_a -licuuc) -+ set(libicu_data_a) -+ if(EXISTS ${ICU_I18N_LIBDIR}/libicui18n.a AND -+ EXISTS ${ICU_UC_LIBDIR}/libicuuc.a AND -+ EXISTS ${ICU_UC_LIBDIR}/libicudata.a) -+ set(libicu_i18n_a ${ICU_I18N_LIBDIR}/libicui18n.a) -+ set(libicu_uc_a ${ICU_UC_LIBDIR}/libicuuc.a) -+ set(libicu_data_a ${ICU_UC_LIBDIR}/libicudata.a) -+ endif() -+ endif() - set(libpthread -lpthread) - set(concurrency_libs) - set(android_libraries) -@@ -288,6 +309,28 @@ ${concurrency_libs} - swift_install_in_component(FILES "${SWIFTSTATICLIB_DIR}/${linkfile}" - DESTINATION "lib/swift_static/${lowercase_sdk}" - COMPONENT stdlib) -+ elseif("${sdk}" STREQUAL "WASI") -+ set(swift_icu_libs_wasi_list) -+ set(icu_modules UC I18N DATA) -+ foreach(module IN LISTS icu_modules) -+ set(module_lib "${SWIFT_WASI_wasm32_ICU_${module}}") -+ get_filename_component(module_lib_name ${module_lib} NAME) -+ add_custom_command_target(swift_icu_${module}_${sdk} -+ COMMAND -+ "${CMAKE_COMMAND}" -E copy -+ "${module_lib}" -+ "${SWIFTSTATICLIB_DIR}/${lowercase_sdk}/${module_lib_name}" -+ OUTPUT -+ "${SWIFTSTATICLIB_DIR}/${lowercase_sdk}/${module_lib_name}" -+ DEPENDS -+ "${module_lib}") -+ list(APPEND swift_icu_libs_wasi_list ${swift_icu_${module}_${sdk}}) -+ swift_install_in_component(FILES "${SWIFTSTATICLIB_DIR}/${lowercase_sdk}/${module_lib_name}" -+ DESTINATION "lib/swift_static/${lowercase_sdk}" -+ COMPONENT stdlib) -+ endforeach() -+ add_custom_target(swift_icu_libs_wasi ALL DEPENDS ${swift_icu_libs_wasi_list}) -+ add_dependencies(stdlib swift_icu_libs_wasi) - endif() - endforeach() - endforeach() --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0022-wasm-stdlib-Add-static-stdlib-args.lnk-generation-fo.patch b/schemes/release-5.9/swift/0022-wasm-stdlib-Add-static-stdlib-args.lnk-generation-fo.patch deleted file mode 100644 index d78d93c0..00000000 --- a/schemes/release-5.9/swift/0022-wasm-stdlib-Add-static-stdlib-args.lnk-generation-fo.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 182a6f25f57dbd75d0b8e20506b43e401d6ff06e Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 08:15:30 +0000 -Subject: [PATCH] [wasm][stdlib] Add static-stdlib-args.lnk generation for WASI - -But static-stdlib-args.lnk is actually not used by WebAssembly driver -toolchain now because we don't support non-executable linking for now. ---- - stdlib/public/runtime/CMakeLists.txt | 17 +++++++++++++++++ - 1 file changed, 17 insertions(+) - -diff --git a/stdlib/public/runtime/CMakeLists.txt b/stdlib/public/runtime/CMakeLists.txt -index be7f63e5e92..0d3bc17f595 100644 ---- a/stdlib/public/runtime/CMakeLists.txt -+++ b/stdlib/public/runtime/CMakeLists.txt -@@ -310,6 +310,23 @@ ${concurrency_libs} - DESTINATION "lib/swift_static/${lowercase_sdk}" - COMPONENT stdlib) - elseif("${sdk}" STREQUAL "WASI") -+ set(linkfile "${lowercase_sdk}/static-stdlib-args.lnk") -+ file(WRITE "${SWIFTSTATICLIB_DIR}/${linkfile}" " -+-ldl -+-latomic -+-lswiftWasiPthread -+-lswiftCore -+-licuuc -+-licudata -+-lstdc++ -+-lm -+-Xlinker --exclude-libs -+-Xlinker ALL") -+ -+ swift_install_in_component(FILES "${SWIFTSTATICLIB_DIR}/${linkfile}" -+ DESTINATION "lib/swift_static/${lowercase_sdk}" -+ COMPONENT stdlib) -+ - set(swift_icu_libs_wasi_list) - set(icu_modules UC I18N DATA) - foreach(module IN LISTS icu_modules) --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0023-test-Fix-calling-convention-mismatch-for-swift_deman.patch b/schemes/release-5.9/swift/0023-test-Fix-calling-convention-mismatch-for-swift_deman.patch deleted file mode 100644 index ca0b8747..00000000 --- a/schemes/release-5.9/swift/0023-test-Fix-calling-convention-mismatch-for-swift_deman.patch +++ /dev/null @@ -1,30 +0,0 @@ -From dfc25f4f2236d733fc52e40229092c71d334532a Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 08:17:12 +0000 -Subject: [PATCH] [test] Fix calling convention mismatch for swift_demangle - -`test/stdlib/Runtime.swift.gyb` calls `swift_demangle` with the Swift -calling convention, but the functions is defined with the C calling -convention. But this does not cause a problem other than testing, and -ideal fix would be to put `@_cdecl` on the function declared in -Swift-side to choose the correct calling convention. `@cdecl` without -body is not supported yet but discussed in https://forums.swift.org/t/formalizing-cdecl/40677 ---- - stdlib/public/runtime/Demangle.cpp | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/stdlib/public/runtime/Demangle.cpp b/stdlib/public/runtime/Demangle.cpp -index 64c917a2018..8f5c3ea3475 100644 ---- a/stdlib/public/runtime/Demangle.cpp -+++ b/stdlib/public/runtime/Demangle.cpp -@@ -907,6 +907,7 @@ swift::_swift_buildDemanglingForMetadata(const Metadata *type, - /// \returns the demangled name. Returns nullptr if the input String is not a - /// Swift mangled name. - SWIFT_RUNTIME_EXPORT -+SWIFT_CC(swift) - char *swift_demangle(const char *mangledName, - size_t mangledNameLength, - char *outputBuffer, --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0024-stdlib-Fix-calling-convention-mismatch-for-swift_COW.patch b/schemes/release-5.9/swift/0024-stdlib-Fix-calling-convention-mismatch-for-swift_COW.patch deleted file mode 100644 index 448c623e..00000000 --- a/schemes/release-5.9/swift/0024-stdlib-Fix-calling-convention-mismatch-for-swift_COW.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 24c659bcd209b135d86f3d8a8a6567699c134343 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 08:26:32 +0000 -Subject: [PATCH] [stdlib] Fix calling convention mismatch for - swift_COWChecksEnabled - -`ContiguousArrayBuffer.swift` calls `swift_COWChecksEnabled` with the -Swift calling convention, but the functions is defined with the C calling -convention. This mismatch actually happens only when building with -`enable-array-cow-checks` (which is not enabled by default). -Also ideal fix would be to put `@_cdecl` on the function declared in -Swift-side to choose the correct calling convention. `@cdecl` without -body is not supported yet but discussed in https://forums.swift.org/t/formalizing-cdecl/40677 ---- - stdlib/public/runtime/EnvironmentVariables.cpp | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/stdlib/public/runtime/EnvironmentVariables.cpp b/stdlib/public/runtime/EnvironmentVariables.cpp -index 264e44a4db6..3a04eb9c928 100644 ---- a/stdlib/public/runtime/EnvironmentVariables.cpp -+++ b/stdlib/public/runtime/EnvironmentVariables.cpp -@@ -253,6 +253,7 @@ void swift::runtime::environment::initialize(void *context) { - } - #endif - -+SWIFT_CC(swift) - SWIFT_RUNTIME_EXPORT - bool swift_COWChecksEnabled() { - return runtime::environment::SWIFT_DEBUG_ENABLE_COW_CHECKS(); --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0025-wasm-stdlib-Add-wasi-libc-support-for-Heap.cpp.patch b/schemes/release-5.9/swift/0025-wasm-stdlib-Add-wasi-libc-support-for-Heap.cpp.patch deleted file mode 100644 index 1a27593f..00000000 --- a/schemes/release-5.9/swift/0025-wasm-stdlib-Add-wasi-libc-support-for-Heap.cpp.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 21438d9a54ceb325d658814ebf7479c7bcc1881f Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 08:37:23 +0000 -Subject: [PATCH] [wasm][stdlib] Add wasi-libc support for Heap.cpp - -Pointers returned by malloc() are 16-byte aligned on wasi-libc, even -it's 32-bit architecture. See wasi-libc's dlmalloc configuration: -https://github.com/WebAssembly/wasi-libc/blob/aecd368c6dedc417037afa136139eccc4490e56e/dlmalloc/src/dlmalloc.c#L31 ---- - stdlib/public/runtime/Heap.cpp | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -diff --git a/stdlib/public/runtime/Heap.cpp b/stdlib/public/runtime/Heap.cpp -index c2d26dddad5..61e6f7ad6ce 100644 ---- a/stdlib/public/runtime/Heap.cpp -+++ b/stdlib/public/runtime/Heap.cpp -@@ -32,10 +32,11 @@ using namespace swift; - /// On Apple platforms, \c malloc() is always 16-byte aligned. - static constexpr size_t MALLOC_ALIGN_MASK = 15; - --#elif defined(__linux__) || defined(_WIN32) -+#elif defined(__linux__) || defined(_WIN32) || defined(__wasi__) - /// On Linux and Windows, \c malloc() returns 16-byte aligned pointers on 64-bit - /// and 8-byte aligned pointers on 32-bit. --#if defined(__LP64) || defined(_WIN64) -+/// On wasi-libc, pointers are 16-byte aligned even though 32-bit for SIMD access. -+#if defined(__LP64) || defined(_WIN64) || defined(__wasi__) - static constexpr size_t MALLOC_ALIGN_MASK = 15; - #else - static constexpr size_t MALLOC_ALIGN_MASK = 7; --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0026-stdlib-Fix-calling-convention-mismatch-for-runtime-f.patch b/schemes/release-5.9/swift/0026-stdlib-Fix-calling-convention-mismatch-for-runtime-f.patch deleted file mode 100644 index cc308421..00000000 --- a/schemes/release-5.9/swift/0026-stdlib-Fix-calling-convention-mismatch-for-runtime-f.patch +++ /dev/null @@ -1,161 +0,0 @@ -From 5c8973f5914347c3cdbcc0dc65e12d36abe88bdf Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 08:44:04 +0000 -Subject: [PATCH] [stdlib] Fix calling convention mismatch for runtime function - tracking - -Runtime function tracking APIs are defined with the C calling convention -but they are called from Swift through `@_silgen_name`, so they are -called with the Swift calling convention. This patch fixes the mismatch -by adding `SWIFT_CC(swift)` to the definitions, but ideally we should be -able to call these APIs with the C calling convention with `@_cdecl`. -`@cdecl` without body is not supported yet but discussed in -https://forums.swift.org/t/formalizing-cdecl/40677 ---- - .../runtime/RuntimeInvocationsTracking.cpp | 16 +++++++++------- - .../runtime/RuntimeInvocationsTracking.h | 18 +++++++++--------- - 2 files changed, 18 insertions(+), 16 deletions(-) - -diff --git a/stdlib/public/runtime/RuntimeInvocationsTracking.cpp b/stdlib/public/runtime/RuntimeInvocationsTracking.cpp -index bf5812b4ba1..51a9ab16b11 100644 ---- a/stdlib/public/runtime/RuntimeInvocationsTracking.cpp -+++ b/stdlib/public/runtime/RuntimeInvocationsTracking.cpp -@@ -130,7 +130,7 @@ static std::uint16_t RuntimeFunctionCountersOffsets[] = { - /// Public APIs - - /// Get the runtime object state associated with an object. --void _swift_getObjectRuntimeFunctionCounters( -+SWIFT_CC(swift) void _swift_getObjectRuntimeFunctionCounters( - HeapObject *object, RuntimeFunctionCountersState *result) { - auto &theSentinel = RuntimeObjectStateCache.get(); - Mutex::ScopedLock lock(theSentinel.Lock); -@@ -139,7 +139,7 @@ void _swift_getObjectRuntimeFunctionCounters( - - /// Set the runtime object state associated with an object from a provided - /// state. --void _swift_setObjectRuntimeFunctionCounters( -+SWIFT_CC(swift) void _swift_setObjectRuntimeFunctionCounters( - HeapObject *object, RuntimeFunctionCountersState *state) { - auto &theSentinel = RuntimeObjectStateCache.get(); - Mutex::ScopedLock lock(theSentinel.Lock); -@@ -148,14 +148,14 @@ void _swift_setObjectRuntimeFunctionCounters( - - /// Get the global runtime state containing the total numbers of invocations for - /// each runtime function of interest. --void _swift_getGlobalRuntimeFunctionCounters( -+SWIFT_CC(swift) void _swift_getGlobalRuntimeFunctionCounters( - RuntimeFunctionCountersState *result) { - LazyMutex::ScopedLock lock(RuntimeGlobalFunctionCountersState.Lock); - *result = RuntimeGlobalFunctionCountersState.State; - } - - /// Set the global runtime state of function pointers from a provided state. --void _swift_setGlobalRuntimeFunctionCounters( -+SWIFT_CC(swift) void _swift_setGlobalRuntimeFunctionCounters( - RuntimeFunctionCountersState *state) { - LazyMutex::ScopedLock lock(RuntimeGlobalFunctionCountersState.Lock); - RuntimeGlobalFunctionCountersState.State = *state; -@@ -164,18 +164,20 @@ void _swift_setGlobalRuntimeFunctionCounters( - /// Return the names of the runtime functions being tracked. - /// Their order is the same as the order of the counters in the - /// RuntimeObjectState structure. All these strings are null terminated. --const char **_swift_getRuntimeFunctionNames() { -+SWIFT_CC(swift) const char **_swift_getRuntimeFunctionNames() { - return RuntimeFunctionNames; - } - - /// Return the offsets of the runtime function counters being tracked. - /// Their order is the same as the order of the counters in the - /// RuntimeObjectState structure. -+SWIFT_CC(swift) - const std::uint16_t *_swift_getRuntimeFunctionCountersOffsets() { - return RuntimeFunctionCountersOffsets; - } - - /// Return the number of runtime functions being tracked. -+SWIFT_CC(swift) - std::uint64_t _swift_getNumRuntimeFunctionCounters() { - return ID_LastRuntimeFunctionName; - } -@@ -204,7 +206,7 @@ void _swift_dumpObjectsRuntimeFunctionPointers() { - - /// Set mode for global runtime function counters. - /// Return the old value of this flag. --int _swift_setGlobalRuntimeFunctionCountersMode(int mode) { -+SWIFT_CC(swift) int _swift_setGlobalRuntimeFunctionCountersMode(int mode) { - int oldMode = UpdateGlobalRuntimeFunctionCounters; - UpdateGlobalRuntimeFunctionCounters = mode ? 1 : 0; - return oldMode; -@@ -212,7 +214,7 @@ int _swift_setGlobalRuntimeFunctionCountersMode(int mode) { - - /// Set mode for per object runtime function counters. - /// Return the old value of this flag. --int _swift_setPerObjectRuntimeFunctionCountersMode(int mode) { -+SWIFT_CC(swift) int _swift_setPerObjectRuntimeFunctionCountersMode(int mode) { - int oldMode = UpdatePerObjectRuntimeFunctionCounters; - UpdatePerObjectRuntimeFunctionCounters = mode ? 1 : 0; - return oldMode; -diff --git a/stdlib/public/runtime/RuntimeInvocationsTracking.h b/stdlib/public/runtime/RuntimeInvocationsTracking.h -index 74d60917656..3005df2b79c 100644 ---- a/stdlib/public/runtime/RuntimeInvocationsTracking.h -+++ b/stdlib/public/runtime/RuntimeInvocationsTracking.h -@@ -61,47 +61,47 @@ using RuntimeFunctionCountersUpdateHandler = - - /// Get the runtime object state associated with an object and store it - /// into the result. --SWIFT_RUNTIME_EXPORT void -+SWIFT_CC(swift) SWIFT_RUNTIME_EXPORT void - _swift_getObjectRuntimeFunctionCounters(HeapObject *object, - RuntimeFunctionCountersState *result); - - /// Get the global runtime state containing the total numbers of invocations for - /// each runtime function of interest and store it into the result. --SWIFT_RUNTIME_EXPORT void _swift_getGlobalRuntimeFunctionCounters( -+SWIFT_CC(swift) SWIFT_RUNTIME_EXPORT void _swift_getGlobalRuntimeFunctionCounters( - swift::RuntimeFunctionCountersState *result); - - /// Return the names of the runtime functions being tracked. - /// Their order is the same as the order of the counters in the - /// RuntimeObjectState structure. --SWIFT_RUNTIME_EXPORT const char **_swift_getRuntimeFunctionNames(); -+SWIFT_CC(swift) SWIFT_RUNTIME_EXPORT const char **_swift_getRuntimeFunctionNames(); - - /// Return the offsets of the runtime function counters being tracked. - /// Their order is the same as the order of the counters in the - /// RuntimeFunctionCountersState structure. --SWIFT_RUNTIME_EXPORT const uint16_t *_swift_getRuntimeFunctionCountersOffsets(); -+SWIFT_CC(swift) SWIFT_RUNTIME_EXPORT const uint16_t *_swift_getRuntimeFunctionCountersOffsets(); - - /// Return the number of runtime functions being tracked. --SWIFT_RUNTIME_EXPORT uint64_t _swift_getNumRuntimeFunctionCounters(); -+SWIFT_CC(swift) SWIFT_RUNTIME_EXPORT uint64_t _swift_getNumRuntimeFunctionCounters(); - - /// Dump all per-object runtime function pointers. - SWIFT_RUNTIME_EXPORT void _swift_dumpObjectsRuntimeFunctionPointers(); - - /// Set mode for global runtime function counters. - /// Return the old value of this flag. --SWIFT_RUNTIME_EXPORT int -+SWIFT_CC(swift) SWIFT_RUNTIME_EXPORT int - _swift_setPerObjectRuntimeFunctionCountersMode(int mode); - - /// Set mode for per object runtime function counters. - /// Return the old value of this flag. --SWIFT_RUNTIME_EXPORT int _swift_setGlobalRuntimeFunctionCountersMode(int mode); -+SWIFT_CC(swift) SWIFT_RUNTIME_EXPORT int _swift_setGlobalRuntimeFunctionCountersMode(int mode); - - /// Set the global runtime state of function pointers from a provided state. --SWIFT_RUNTIME_EXPORT void _swift_setGlobalRuntimeFunctionCounters( -+SWIFT_CC(swift) SWIFT_RUNTIME_EXPORT void _swift_setGlobalRuntimeFunctionCounters( - swift::RuntimeFunctionCountersState *state); - - /// Set the runtime object state associated with an object from a provided - /// state. --SWIFT_RUNTIME_EXPORT void -+SWIFT_CC(swift) SWIFT_RUNTIME_EXPORT void - _swift_setObjectRuntimeFunctionCounters(HeapObject *object, - RuntimeFunctionCountersState *state); - --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0027-wasm-stdlib-HACK-Workaround-for-the-bad-stacksave-co.patch b/schemes/release-5.9/swift/0027-wasm-stdlib-HACK-Workaround-for-the-bad-stacksave-co.patch deleted file mode 100644 index cc85aa4c..00000000 --- a/schemes/release-5.9/swift/0027-wasm-stdlib-HACK-Workaround-for-the-bad-stacksave-co.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 5612196a60f3bb93b5880d86966084f2578da589 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Wed, 19 Apr 2023 13:14:46 +0000 -Subject: [PATCH] [wasm][stdlib] HACK: Workaround for the bad stacksave codegen - in LLVM - -The LLVM backend generates bad code for some code using `llvm.stacksave` -intrinsics. This patch works around the issue by avoiding such code -generation. See https://github.com/llvm/llvm-project/issues/62235 ---- - stdlib/public/core/ValidUTF8Buffer.swift | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/stdlib/public/core/ValidUTF8Buffer.swift b/stdlib/public/core/ValidUTF8Buffer.swift -index 38799a2a86a..7dd7ca38bee 100644 ---- a/stdlib/public/core/ValidUTF8Buffer.swift -+++ b/stdlib/public/core/ValidUTF8Buffer.swift -@@ -127,7 +127,10 @@ extension _ValidUTF8Buffer: RandomAccessCollection { - @inlinable - @inline(__always) - public func distance(from i: Index, to j: Index) -> Int { -- _debugPrecondition(_isValid(i)) -+ // FIXME(katei): The precondition check is commented out because it -+ // causes bad codegen for `stacksave` on WebAssembly. -+ // See https://github.com/llvm/llvm-project/issues/62235 -+ // _debugPrecondition(_isValid(i)) - _debugPrecondition(_isValid(j)) - return ( - i._biasedBits.leadingZeroBitCount - j._biasedBits.leadingZeroBitCount --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0028-wasm-test-Add-checks-for-swift-autolink-extract.patch b/schemes/release-5.9/swift/0028-wasm-test-Add-checks-for-swift-autolink-extract.patch deleted file mode 100644 index e0a0b637..00000000 --- a/schemes/release-5.9/swift/0028-wasm-test-Add-checks-for-swift-autolink-extract.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 02f39c72bce77d267ceca575bca7b61cf0eaa487 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 08:54:00 +0000 -Subject: [PATCH] [wasm][test] Add checks for swift-autolink-extract - ---- - test/AutolinkExtract/empty.swift | 1 + - test/AutolinkExtract/empty_archive.swift | 1 + - test/AutolinkExtract/import.swift | 3 +++ - test/AutolinkExtract/import_archive.swift | 3 +++ - 4 files changed, 8 insertions(+) - -diff --git a/test/AutolinkExtract/empty.swift b/test/AutolinkExtract/empty.swift -index b9ae0068c07..c5b61292709 100644 ---- a/test/AutolinkExtract/empty.swift -+++ b/test/AutolinkExtract/empty.swift -@@ -5,3 +5,4 @@ - - // CHECK-elf: -lswiftCore - // CHECK-coff: -lswiftCore -+// CHECK-wasm: -lswiftCore -diff --git a/test/AutolinkExtract/empty_archive.swift b/test/AutolinkExtract/empty_archive.swift -index ee66d676261..a94f40ad68c 100644 ---- a/test/AutolinkExtract/empty_archive.swift -+++ b/test/AutolinkExtract/empty_archive.swift -@@ -7,3 +7,4 @@ - - // CHECK-elf: -lswiftCore - // CHECK-coff: -lswiftCore -+// CHECK-wasm: -lswiftCore -diff --git a/test/AutolinkExtract/import.swift b/test/AutolinkExtract/import.swift -index 2b95be66fe0..5fe5a77ff4b 100644 ---- a/test/AutolinkExtract/import.swift -+++ b/test/AutolinkExtract/import.swift -@@ -18,4 +18,7 @@ - // CHECK-coff-DAG: -lswiftCore - // CHECK-coff-DAG: -lempty - -+// CHECK-wasm-DAG: -lswiftCore -+// CHECK-wasm-DAG: -lempty -+ - import empty -diff --git a/test/AutolinkExtract/import_archive.swift b/test/AutolinkExtract/import_archive.swift -index 5aa0ee41d74..1bd6f5323a8 100644 ---- a/test/AutolinkExtract/import_archive.swift -+++ b/test/AutolinkExtract/import_archive.swift -@@ -12,4 +12,7 @@ - // CHECK-coff-DAG: -lswiftCore - // CHECK-coff-DAG: -lempty - -+// CHECK-wasm-DAG: -lswiftCore -+// CHECK-wasm-DAG: -lempty -+ - import empty --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0029-wasm-test-Recognize-WASI-as-a-supported-SDK-in-test-.patch b/schemes/release-5.9/swift/0029-wasm-test-Recognize-WASI-as-a-supported-SDK-in-test-.patch deleted file mode 100644 index 36dbf562..00000000 --- a/schemes/release-5.9/swift/0029-wasm-test-Recognize-WASI-as-a-supported-SDK-in-test-.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 587d4acae1e358894b4da97d86b154aed5d720ea Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 08:55:22 +0000 -Subject: [PATCH] [wasm][test] Recognize WASI as a supported SDK in test build - ---- - test/CMakeLists.txt | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt -index d2d5f71ded4..4b96375d2c1 100644 ---- a/test/CMakeLists.txt -+++ b/test/CMakeLists.txt -@@ -114,7 +114,8 @@ function(get_test_dependencies SDK result_var_name) - ("${SDK}" STREQUAL "OPENBSD") OR - ("${SDK}" STREQUAL "ANDROID") OR - ("${SDK}" STREQUAL "WINDOWS") OR -- ("${SDK}" STREQUAL "HAIKU")) -+ ("${SDK}" STREQUAL "HAIKU") OR -+ ("${SDK}" STREQUAL "WASI")) - # No extra dependencies. - else() - message(FATAL_ERROR "Unknown SDK: ${SDK}") --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0030-test-static-stdlib-Test-with-swift_static-when-build.patch b/schemes/release-5.9/swift/0030-test-static-stdlib-Test-with-swift_static-when-build.patch deleted file mode 100644 index bd59f903..00000000 --- a/schemes/release-5.9/swift/0030-test-static-stdlib-Test-with-swift_static-when-build.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 66f1aefb98fc4d91b915b07e5ea4fc5a349c21d0 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 08:56:16 +0000 -Subject: [PATCH] [test][static-stdlib] Test with swift_static when building - only static stdlib - -This patch makes the test suite use `lib/swift_static` instead of -`lib/swift` when building only static stdlib. ---- - test/CMakeLists.txt | 10 ++++++++-- - 1 file changed, 8 insertions(+), 2 deletions(-) - -diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt -index 4b96375d2c1..59492ebfd41 100644 ---- a/test/CMakeLists.txt -+++ b/test/CMakeLists.txt -@@ -155,8 +155,14 @@ if(NOT SWIFT_INCLUDE_TOOLS) - ) - endif() - if(SWIFT_BUILD_STDLIB) -- list(APPEND SWIFT_LIT_ARGS -- "--param" "test_resource_dir=${SWIFTLIB_DIR}") -+ # if building only static stdlib, prefer static lib. -+ if(NOT SWIFT_BUILD_DYNAMIC_STDLIB AND SWIFT_BUILD_STATIC_STDLIB) -+ list(APPEND SWIFT_LIT_ARGS -+ "--param" "test_resource_dir=${SWIFTSTATICLIB_DIR}") -+ else() -+ list(APPEND SWIFT_LIT_ARGS -+ "--param" "test_resource_dir=${SWIFTLIB_DIR}") -+ endif() - endif() - endif() - --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0031-wasm-test-Skip-crash-tests-on-WASI-for-now.patch b/schemes/release-5.9/swift/0031-wasm-test-Skip-crash-tests-on-WASI-for-now.patch deleted file mode 100644 index 278c0d35..00000000 --- a/schemes/release-5.9/swift/0031-wasm-test-Skip-crash-tests-on-WASI-for-now.patch +++ /dev/null @@ -1,344 +0,0 @@ -From 21db67e16198a90f650c1f49df34cd6f19d38ca0 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 09:04:17 +0000 -Subject: [PATCH] [wasm][test] Skip crash tests on WASI for now - -WASI doesn't support spawning a subprocess, so crash tests crashes the -test harness itself. Skip them for now. ---- - .../actor_assert_precondition_executor.swift | 2 ++ - .../Runtime/actor_assume_executor.swift | 6 ++++++ - .../Runtime/checked_continuation.swift | 3 +++ - .../Runtime/continuation_validation.swift | 1 + - test/stdlib/Error.swift | 2 ++ - test/stdlib/StringAPI.swift | 2 ++ - test/stdlib/StringAPICString.swift | 16 ++++++++++++++++ - test/stdlib/TemporaryAllocation.swift | 4 ++++ - test/stdlib/UnsafePointer.swift.gyb | 2 ++ - test/stdlib/UnsafeRawPointer.swift | 4 ++++ - 10 files changed, 42 insertions(+) - -diff --git a/test/Concurrency/Runtime/actor_assert_precondition_executor.swift b/test/Concurrency/Runtime/actor_assert_precondition_executor.swift -index fb6112cf6be..bffd87cb3ee 100644 ---- a/test/Concurrency/Runtime/actor_assert_precondition_executor.swift -+++ b/test/Concurrency/Runtime/actor_assert_precondition_executor.swift -@@ -78,10 +78,12 @@ actor Someone { - await MainFriend().callCheckMainActor() - } - -+ #if !os(WASI) - tests.test("precondition on actor (main): wrongly assume the main executor, from actor on other executor") { - expectCrashLater(withMessage: "Incorrect actor executor assumption; Expected 'MainActor' executor.") - await Someone().callCheckMainActor() - } -+ #endif - - // === Global actor ----------------------------------------------------- - -diff --git a/test/Concurrency/Runtime/actor_assume_executor.swift b/test/Concurrency/Runtime/actor_assume_executor.swift -index 2c703a4687a..60652080a9c 100644 ---- a/test/Concurrency/Runtime/actor_assume_executor.swift -+++ b/test/Concurrency/Runtime/actor_assume_executor.swift -@@ -115,14 +115,17 @@ final class MainActorEcho { - await MainFriend().callCheck(echo: echo) - } - -+ #if !os(WASI) - tests.test("MainActor.assumeIsolated: wrongly assume the main executor, from actor on other executor") { - expectCrashLater(withMessage: "Incorrect actor executor assumption; Expected 'MainActor' executor.") - await Someone().callCheckMainActor(echo: echo) - } -+ #endif - - // === some Actor ------------------------------------------------------- - - let someone = Someone() -+ #if !os(WASI) - tests.test("assumeOnActorExecutor: wrongly assume someone's executor, from 'main() async'") { - expectCrashLater(withMessage: "Incorrect actor executor assumption; Expected same executor as a.Someone.") - checkAssumeSomeone(someone: someone) -@@ -132,6 +135,7 @@ final class MainActorEcho { - expectCrashLater(withMessage: "Incorrect actor executor assumption; Expected same executor as a.Someone.") - checkAssumeSomeone(someone: someone) - } -+ #endif - - tests.test("assumeOnActorExecutor: assume someone's executor, from Someone") { - await someone.callCheckSomeone() -@@ -141,10 +145,12 @@ final class MainActorEcho { - await SomeonesFriend(someone: someone).callCheckSomeone() - } - -+ #if !os(WASI) - tests.test("assumeOnActorExecutor: wrongly assume the main executor, from actor on other executor") { - expectCrashLater(withMessage: "Incorrect actor executor assumption; Expected same executor as a.Someone.") - await CompleteStranger(someone: someone).callCheckSomeone() - } -+ #endif - - - } -diff --git a/test/Concurrency/Runtime/checked_continuation.swift b/test/Concurrency/Runtime/checked_continuation.swift -index 9f9f1d81469..f440129cac3 100644 ---- a/test/Concurrency/Runtime/checked_continuation.swift -+++ b/test/Concurrency/Runtime/checked_continuation.swift -@@ -16,6 +16,8 @@ struct TestError: Error {} - var tests = TestSuite("CheckedContinuation") - - if #available(SwiftStdlib 5.1, *) { -+// Disable crash tests -+#if !os(WASI) - tests.test("trap on double resume non-throwing continuation") { - expectCrashLater() - -@@ -43,6 +45,7 @@ struct TestError: Error {} - await task.get() - } - -+#endif - tests.test("test withCheckedThrowingContinuation") { - let task2 = detach { - do { -diff --git a/test/Concurrency/Runtime/continuation_validation.swift b/test/Concurrency/Runtime/continuation_validation.swift -index 941fdd559eb..78c86e94647 100644 ---- a/test/Concurrency/Runtime/continuation_validation.swift -+++ b/test/Concurrency/Runtime/continuation_validation.swift -@@ -12,6 +12,7 @@ - // UNSUPPORTED: back_deploy_concurrency - // UNSUPPORTED: use_os_stdlib - // UNSUPPORTED: freestanding -+// UNSUPPORTED: OS=wasi - - import StdlibUnittest - -diff --git a/test/stdlib/Error.swift b/test/stdlib/Error.swift -index 542b15f4f23..77e259621d1 100644 ---- a/test/stdlib/Error.swift -+++ b/test/stdlib/Error.swift -@@ -207,6 +207,7 @@ ErrorTests.test("test dealloc empty error box") { - } - } - -+#if !os(WASI) - var errors: [Error] = [] - - @inline(never) -@@ -249,6 +250,7 @@ ErrorTests.test("willThrow") { - expectEqual(2, errors.count) - expectEqual(SillyError.self, type(of: errors.last!)) - } -+#endif - - runAllTests() - -diff --git a/test/stdlib/StringAPI.swift b/test/stdlib/StringAPI.swift -index 86dc0f174b2..6321c9737f7 100644 ---- a/test/stdlib/StringAPI.swift -+++ b/test/stdlib/StringAPI.swift -@@ -342,6 +342,7 @@ StringTests.test("SameTypeComparisons") { - expectFalse(xs != xs) - } - -+#if !os(WASI) - StringTests.test("CompareStringsWithUnpairedSurrogates") - .xfail( - .always(" Strings referring to underlying " + -@@ -357,6 +358,7 @@ StringTests.test("CompareStringsWithUnpairedSurrogates") - ] - ) - } -+#endif - - StringTests.test("[String].joined() -> String") { - let s = ["hello", "world"].joined() -diff --git a/test/stdlib/StringAPICString.swift b/test/stdlib/StringAPICString.swift -index fa8f005ab37..81d277c24f5 100644 ---- a/test/stdlib/StringAPICString.swift -+++ b/test/stdlib/StringAPICString.swift -@@ -7,6 +7,12 @@ - - import StdlibUnittest - -+#if arch(wasm32) -+let enableCrashTests = false -+#else -+let enableCrashTests = true -+#endif -+ - var CStringTests = TestSuite("CStringTests") - - func getNullUTF8() -> UnsafeMutablePointer? { -@@ -239,6 +245,7 @@ CStringTests.test("String.cString.with.Array.UInt8.input") { - } - } - } -+ guard enableCrashTests else { return } - // no need to test every case; that is covered in other tests - expectCrashLater( - // Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967) -@@ -263,6 +270,7 @@ CStringTests.test("String.cString.with.Array.CChar.input") { - } - } - } -+ guard enableCrashTests else { return } - // no need to test every case; that is covered in other tests - expectCrashLater( - // Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967) -@@ -292,6 +300,7 @@ CStringTests.test("String.cString.with.inout.UInt8.conversion") { - var str = String(cString: &c) - expectTrue(str.isEmpty) - c = 100 -+ guard enableCrashTests else { return } - expectCrashLater( - // Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967) - // withMessage: "input of String.init(cString:) must be null-terminated" -@@ -306,6 +315,7 @@ CStringTests.test("String.cString.with.inout.CChar.conversion") { - var str = String(cString: &c) - expectTrue(str.isEmpty) - c = 100 -+ guard enableCrashTests else { return } - expectCrashLater( - // Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967) - // withMessage: "input of String.init(cString:) must be null-terminated" -@@ -330,6 +340,7 @@ CStringTests.test("String.validatingUTF8.with.Array.input") { - } - } - } -+ guard enableCrashTests else { return } - // no need to test every case; that is covered in other tests - expectCrashLater( - // Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967) -@@ -362,6 +373,7 @@ CStringTests.test("String.validatingUTF8.with.inout.conversion") { - expectNotNil(str) - expectEqual(str?.isEmpty, true) - c = 100 -+ guard enableCrashTests else { return } - expectCrashLater( - // Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967) - // withMessage: "input of String.init(validatingUTF8:) must be null-terminated" -@@ -387,6 +399,7 @@ CStringTests.test("String.decodeCString.with.Array.input") { - } - } - } -+ guard enableCrashTests else { return } - // no need to test every case; that is covered in other tests - expectCrashLater( - // Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967) -@@ -426,6 +439,7 @@ CStringTests.test("String.decodeCString.with.inout.conversion") { - expectEqual(result?.result.isEmpty, true) - expectEqual(result?.repairsMade, false) - c = 100 -+ guard enableCrashTests else { return } - expectCrashLater( - // Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967) - // withMessage: "input of decodeCString(_:as:repairingInvalidCodeUnits:) must be null-terminated" -@@ -449,6 +463,7 @@ CStringTests.test("String.init.decodingCString.with.Array.input") { - } - } - } -+ guard enableCrashTests else { return } - // no need to test every case; that is covered in other tests - expectCrashLater( - // Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967) -@@ -478,6 +493,7 @@ CStringTests.test("String.init.decodingCString.with.inout.conversion") { - var str = String(decodingCString: &c, as: Unicode.UTF8.self) - expectEqual(str.isEmpty, true) - c = 100 -+ guard enableCrashTests else { return } - expectCrashLater( - // Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967) - // withMessage: "input of String.init(decodingCString:as:) must be null-terminated" -diff --git a/test/stdlib/TemporaryAllocation.swift b/test/stdlib/TemporaryAllocation.swift -index 90683159653..494d20ce234 100644 ---- a/test/stdlib/TemporaryAllocation.swift -+++ b/test/stdlib/TemporaryAllocation.swift -@@ -70,6 +70,7 @@ TemporaryAllocationTestSuite.test("untypedEmptyAllocationIsStackAllocated") { - } - } - -+#if !os(WASI) - TemporaryAllocationTestSuite.test("crashOnNegativeByteCount") { - expectCrash { - let byteCount = Int.random(in: -2 ..< -1) -@@ -83,6 +84,7 @@ TemporaryAllocationTestSuite.test("crashOnNegativeAlignment") { - withUnsafeTemporaryAllocation(byteCount: 16, alignment: alignment) { _ in } - } - } -+#endif - - TemporaryAllocationTestSuite.test("untypedAllocationIsAligned") { - withUnsafeTemporaryAllocation(byteCount: 1, alignment: 8) { buffer in -@@ -136,12 +138,14 @@ TemporaryAllocationTestSuite.test("voidAllocationIsStackAllocated") { - } - } - -+#if !os(WASI) - TemporaryAllocationTestSuite.test("crashOnNegativeValueCount") { - expectCrash { - let capacity = Int.random(in: -2 ..< -1) - withUnsafeTemporaryAllocation(of: Int.self, capacity: capacity) { _ in } - } - } -+#endif - - TemporaryAllocationTestSuite.test("typedAllocationIsAligned") { - withUnsafeTemporaryAllocation(of: Int.self, capacity: 1) { buffer in -diff --git a/test/stdlib/UnsafePointer.swift.gyb b/test/stdlib/UnsafePointer.swift.gyb -index e0ea6199ef3..f8f8a1c33fb 100644 ---- a/test/stdlib/UnsafePointer.swift.gyb -+++ b/test/stdlib/UnsafePointer.swift.gyb -@@ -537,6 +537,7 @@ ${SelfName}TestSuite.test("pointer(to:)") { - % end - } - -+#if !os(WASI) - ${SelfName}TestSuite.test("pointer(to:).overflow") { - struct Example { - var a = false -@@ -558,6 +559,7 @@ ${SelfName}TestSuite.test("pointer(to:).overflow") { - let doublePointer = p.pointer(to: \.d) - expectNotNil(doublePointer) - } -+#endif - - % end - -diff --git a/test/stdlib/UnsafeRawPointer.swift b/test/stdlib/UnsafeRawPointer.swift -index df476c3ebe5..ffae9582035 100644 ---- a/test/stdlib/UnsafeRawPointer.swift -+++ b/test/stdlib/UnsafeRawPointer.swift -@@ -131,6 +131,7 @@ UnsafeMutableRawPointerExtraTestSuite.test("load.unaligned") - expectEqual(result, 0xffff_0000) - } - -+#if !os(WASI) - UnsafeMutableRawPointerExtraTestSuite.test("load.invalid") - .skip(.custom({ !_isDebugAssertConfiguration() }, - reason: "This tests a debug precondition..")) -@@ -154,6 +155,7 @@ UnsafeMutableRawPointerExtraTestSuite.test("load.invalid.mutable") - } - expectUnreachable() - } -+#endif - - UnsafeMutableRawPointerExtraTestSuite.test("store.unaligned") - .skip(.custom({ -@@ -184,6 +186,7 @@ UnsafeMutableRawPointerExtraTestSuite.test("store.unaligned") - 0) - } - -+#if !os(WASI) - UnsafeMutableRawPointerExtraTestSuite.test("store.invalid") - .skip(.custom({ !_isDebugAssertConfiguration() }, - reason: "This tests a debug precondition..")) -@@ -203,6 +206,7 @@ UnsafeMutableRawPointerExtraTestSuite.test("store.invalid") - p1.storeBytes(of: m, as: Missile.self) - expectUnreachable() - } -+#endif - - UnsafeMutableRawPointerExtraTestSuite.test("copyMemory") { - let sizeInBytes = 4 * MemoryLayout.stride --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0032-wasm-test-Add-missing-WASILibc-import.patch b/schemes/release-5.9/swift/0032-wasm-test-Add-missing-WASILibc-import.patch deleted file mode 100644 index b10209cb..00000000 --- a/schemes/release-5.9/swift/0032-wasm-test-Add-missing-WASILibc-import.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 6e81adfbe86d1064f9e905a13573f5c400797ca7 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 09:06:08 +0000 -Subject: [PATCH] [wasm][test] Add missing WASILibc import - ---- - test/Concurrency/Runtime/cancellation_handler.swift | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/test/Concurrency/Runtime/cancellation_handler.swift b/test/Concurrency/Runtime/cancellation_handler.swift -index 4cc044c7579..b1b154593e0 100644 ---- a/test/Concurrency/Runtime/cancellation_handler.swift -+++ b/test/Concurrency/Runtime/cancellation_handler.swift -@@ -12,6 +12,8 @@ - import Darwin - #elseif canImport(Glibc) - import Glibc -+#elseif os(WASI) -+ import WASILibc - #elseif os(Windows) - import WinSDK - #endif --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0033-wasm-test-Add-test-case-for-WebAssembly-object-file-.patch b/schemes/release-5.9/swift/0033-wasm-test-Add-test-case-for-WebAssembly-object-file-.patch deleted file mode 100644 index 3f7fc169..00000000 --- a/schemes/release-5.9/swift/0033-wasm-test-Add-test-case-for-WebAssembly-object-file-.patch +++ /dev/null @@ -1,25 +0,0 @@ -From b81a33edb1ba2c446034ce0e82a17fe7191b8e52 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 09:08:40 +0000 -Subject: [PATCH] [wasm][test] Add test case for WebAssembly object file format - ---- - test/DebugInfo/modulecache.swift | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/test/DebugInfo/modulecache.swift b/test/DebugInfo/modulecache.swift -index 1dceafbf15d..22d126eca7c 100644 ---- a/test/DebugInfo/modulecache.swift -+++ b/test/DebugInfo/modulecache.swift -@@ -16,7 +16,7 @@ import ClangModule - // RUN: %empty-directory(%t) - // RUN: %target-swift-frontend %s -c -g -o %t.o -module-cache-path %t -I %S/Inputs - // RUN: llvm-readobj -h %t/*/ClangModule-*.pcm | %FileCheck %s --// CHECK: Format: {{(Mach-O|ELF|elf64|COFF|elf32-littlearm)}} -+// CHECK: Format: {{(Mach-O|ELF|elf64|COFF|elf32-littlearm|WASM)}} - - // 3. Test that swift-ide-check will not share swiftc's module cache. - --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0034-wasm-test-HACK-Disable-objc-interop-and-lldb-related.patch b/schemes/release-5.9/swift/0034-wasm-test-HACK-Disable-objc-interop-and-lldb-related.patch deleted file mode 100644 index 9be04f12..00000000 --- a/schemes/release-5.9/swift/0034-wasm-test-HACK-Disable-objc-interop-and-lldb-related.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 4914a979f220532539bf675d9bdc32e7fdcc20e4 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 09:11:53 +0000 -Subject: [PATCH] [wasm][test] HACK: Disable objc-interop and lldb related - tests - ---- - test/lit.cfg | 26 ++++++++++++++++++++++++++ - 1 file changed, 26 insertions(+) - -diff --git a/test/lit.cfg b/test/lit.cfg -index 01160b29a8a..a1c708dd439 100644 ---- a/test/lit.cfg -+++ b/test/lit.cfg -@@ -1842,6 +1842,32 @@ elif run_os == 'wasi': - config.target_sdk_name = "wasi" - config.target_runtime = "native" - -+ # Exclude test cases that use objc-interop because clang doesn't support it -+ # with WebAssembly binary file yet. -+ def use_objc_interop(path): -+ try: -+ with open(path) as f: -+ return '-enable-objc-interop' in f.read() -+ except: -+ return False -+ def lldb_related_test(path): -+ try: -+ with open(path) as f: -+ return 'lldb-moduleimport-test' in f.read() -+ except: -+ return False -+ -+ def disabled_filenames(path): -+ matches = [] -+ for root, dirnames, filenames in os.walk(path): -+ for filename in filenames: -+ filepath = os.path.join(root, filename) -+ if use_objc_interop(filepath) or lldb_related_test(filepath): -+ matches.append(os.path.basename(filepath)) -+ return matches -+ -+ config.excludes += disabled_filenames(config.test_source_root) -+ - config.target_swift_autolink_extract = inferSwiftBinary("swift-autolink-extract") - - config.target_build_swift = ' '.join([ --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0035-wasm-test-Prefer-sdk-instead-of-Xcc-sysroot.patch b/schemes/release-5.9/swift/0035-wasm-test-Prefer-sdk-instead-of-Xcc-sysroot.patch deleted file mode 100644 index c4b8767a..00000000 --- a/schemes/release-5.9/swift/0035-wasm-test-Prefer-sdk-instead-of-Xcc-sysroot.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 08cf756aa7aa61c567f8c481bd1eaafdfa526917 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 09:21:12 +0000 -Subject: [PATCH] [wasm][test] Prefer -sdk instead of -Xcc --sysroot - ---- - test/lit.cfg | 7 +++---- - 1 file changed, 3 insertions(+), 4 deletions(-) - -diff --git a/test/lit.cfg b/test/lit.cfg -index a1c708dd439..fb79fba9aa2 100644 ---- a/test/lit.cfg -+++ b/test/lit.cfg -@@ -1873,9 +1873,8 @@ elif run_os == 'wasi': - config.target_build_swift = ' '.join([ - config.swiftc, - '-target', config.variant_triple, -- '-Xcc', '--sysroot=%s' % config.variant_sdk, -- '-Xclang-linker', '--sysroot=%s' % config.variant_sdk, -- '-toolchain-stdlib-rpath', config.resource_dir_opt, -+ '-sdk', config.variant_sdk, -+ '-toolchain-stdlib-rpath', config.resource_dir_opt, - mcp_opt, config.swift_test_options, - config.swift_driver_test_options, swift_execution_tests_extra_flags]) - config.target_codesign = "echo" -@@ -1886,7 +1885,7 @@ elif run_os == 'wasi': - config.target_swift_frontend = ' '.join([ - config.swift_frontend, - '-target', config.variant_triple, -- '-Xcc', '--sysroot=%s' % config.variant_sdk, -+ '-sdk', config.variant_sdk, - config.resource_dir_opt, mcp_opt, - config.swift_test_options, config.swift_frontend_test_options]) - subst_target_swift_frontend_mock_sdk = config.target_swift_frontend --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0036-wasm-test-Force-static-library-to-avoid-unsupported-.patch b/schemes/release-5.9/swift/0036-wasm-test-Force-static-library-to-avoid-unsupported-.patch deleted file mode 100644 index 9463e629..00000000 --- a/schemes/release-5.9/swift/0036-wasm-test-Force-static-library-to-avoid-unsupported-.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 9b3d935c5403d7eb983e09313b359251c9c7466e Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 09:22:49 +0000 -Subject: [PATCH] [wasm][test] Force static library to avoid unsupported shared - library build - -Linking libraries without `-static` flag produces unexpected main -function reference error. This is because the linker is trying to link -input objects as executable, not as library. ---- - test/lit.cfg | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/test/lit.cfg b/test/lit.cfg -index fb79fba9aa2..a145f2e0934 100644 ---- a/test/lit.cfg -+++ b/test/lit.cfg -@@ -1879,7 +1879,7 @@ elif run_os == 'wasi': - config.swift_driver_test_options, swift_execution_tests_extra_flags]) - config.target_codesign = "echo" - config.target_build_swift_dylib = ( -- "%s -parse-as-library -emit-library -o '\\1'" -+ "%s -parse-as-library -emit-library -static -o '\\1'" - % (config.target_build_swift)) - config.target_add_rpath = '' - config.target_swift_frontend = ' '.join([ --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0037-wasm-test-Add-missing-target-specific-lit-properties.patch b/schemes/release-5.9/swift/0037-wasm-test-Add-missing-target-specific-lit-properties.patch deleted file mode 100644 index 0ec672fa..00000000 --- a/schemes/release-5.9/swift/0037-wasm-test-Add-missing-target-specific-lit-properties.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 1c23e6ef7e1c15007d90b108f3c7252e8e237955 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 09:24:47 +0000 -Subject: [PATCH] [wasm][test] Add missing target specific lit properties - ---- - test/lit.cfg | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/test/lit.cfg b/test/lit.cfg -index a145f2e0934..ce5a8c5ee32 100644 ---- a/test/lit.cfg -+++ b/test/lit.cfg -@@ -1896,10 +1896,16 @@ elif run_os == 'wasi': - config.target_sil_opt = ( - '%s -target %s %s %s %s' % - (config.sil_opt, config.variant_triple, config.resource_dir_opt, mcp_opt, config.sil_test_options)) -+ subst_target_sil_opt_mock_sdk_after = "" -+ subst_target_sil_opt_mock_sdk = config.target_sil_opt - config.target_swift_symbolgraph_extract = ' '.join([ - config.swift_symbolgraph_extract, - '-target', config.variant_triple, - mcp_opt]) -+ config.target_swift_api_extract = ' '.join([ -+ config.swift_api_extract, -+ '-target', config.variant_triple, -+ '-sdk', shell_quote(config.variant_sdk)]) - config.target_swift_ide_test = ( - '%s -target %s %s %s %s' % - (config.swift_ide_test, config.variant_triple, config.resource_dir_opt, --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0038-wasm-test-Add-wasm-test-harness-to-propagate-environ.patch b/schemes/release-5.9/swift/0038-wasm-test-Add-wasm-test-harness-to-propagate-environ.patch deleted file mode 100644 index 2459c280..00000000 --- a/schemes/release-5.9/swift/0038-wasm-test-Add-wasm-test-harness-to-propagate-environ.patch +++ /dev/null @@ -1,98 +0,0 @@ -From 7a1fa35750027fa6268c0480bece63d7ad27c66c Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 09:26:56 +0000 -Subject: [PATCH] [wasm][test] Add wasm test harness to propagate environment - vars - ---- - test/lit.cfg | 5 ++-- - utils/webassembly/wasm-run.py | 54 +++++++++++++++++++++++++++++++++++ - 2 files changed, 57 insertions(+), 2 deletions(-) - create mode 100755 utils/webassembly/wasm-run.py - -diff --git a/test/lit.cfg b/test/lit.cfg -index ce5a8c5ee32..60596416262 100644 ---- a/test/lit.cfg -+++ b/test/lit.cfg -@@ -341,7 +341,6 @@ config.swift_demangle_yamldump = inferSwiftBinary('swift-demangle-yamldump') - config.swift_demangle = inferSwiftBinary('swift-demangle') - config.benchmark_o = inferSwiftBinary('Benchmark_O') - config.benchmark_driver = inferSwiftBinary('Benchmark_Driver') --config.wasmer = inferSwiftBinary('wasmer') - config.wasm_ld = inferSwiftBinary('wasm-ld') - config.swift_plugin_server = inferSwiftBinary('swift-plugin-server') - -@@ -1890,7 +1889,9 @@ elif run_os == 'wasi': - config.swift_test_options, config.swift_frontend_test_options]) - subst_target_swift_frontend_mock_sdk = config.target_swift_frontend - subst_target_swift_frontend_mock_sdk_after = "" -- config.target_run = '%s run --backend cranelift --' % config.wasmer -+ config.target_run = os.path.join(config.swift_utils, 'webassembly', 'wasm-run.py') -+ config.target_env_prefix = 'WASM_RUN_CHILD_' -+ - if 'interpret' in lit_config.params: - use_interpreter_for_simple_runs() - config.target_sil_opt = ( -diff --git a/utils/webassembly/wasm-run.py b/utils/webassembly/wasm-run.py -new file mode 100755 -index 00000000000..e59f95ebf3c ---- /dev/null -+++ b/utils/webassembly/wasm-run.py -@@ -0,0 +1,54 @@ -+#!/usr/bin/env python3 -+ -+import argparse -+import os -+import subprocess -+import sys -+ -+ -+def collect_wasm_env(local_env=os.environ, prefix='WASM_RUN_CHILD_'): -+ return dict((key[len(prefix):], value) -+ for key, value in local_env.items() if key.startswith(prefix)) -+ -+ -+class WasmtimeRunner(object): -+ def __init__(self): -+ pass -+ -+ def run(self, args): -+ command = self.invocation(args) -+ if args.verbose: -+ print(' '.join(command), file=sys.stderr) -+ -+ if not args.dry_run: -+ subprocess.check_call(command) -+ -+ def invocation(self, args): -+ command = ["wasmtime", "run"] -+ envs = collect_wasm_env() -+ for key in envs: -+ command.append("--env") -+ command.append(f"{key}={envs[key]}") -+ command.append("--") -+ command.extend(args.command) -+ return command -+ -+ -+def main(): -+ parser = argparse.ArgumentParser() -+ -+ parser.add_argument('-v', '--verbose', action='store_true', dest='verbose', -+ help='print commands as they are run') -+ parser.add_argument('-n', '--dry-run', action='store_true', dest='dry_run', -+ help="print the commands that would have been run, but" -+ " don't actually run them") -+ parser.add_argument('command', nargs=argparse.REMAINDER, -+ help='the command to run', metavar='command...') -+ -+ args = parser.parse_args() -+ runner = WasmtimeRunner() -+ runner.run(args) -+ -+ -+if __name__ == "__main__": -+ main() --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0039-wasm-test-HACK-Disable-os_stdlib-tests-due-to-no-dyn.patch b/schemes/release-5.9/swift/0039-wasm-test-HACK-Disable-os_stdlib-tests-due-to-no-dyn.patch deleted file mode 100644 index b9b3c186..00000000 --- a/schemes/release-5.9/swift/0039-wasm-test-HACK-Disable-os_stdlib-tests-due-to-no-dyn.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 92b8418a0e1aa57e110585e879b7e1625679d695 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 09:27:38 +0000 -Subject: [PATCH] [wasm][test] HACK: Disable os_stdlib tests due to no dynamic - loading - ---- - test/lit.cfg | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/test/lit.cfg b/test/lit.cfg -index 60596416262..e229dc85a09 100644 ---- a/test/lit.cfg -+++ b/test/lit.cfg -@@ -2329,7 +2329,7 @@ if run_vendor != 'apple': - - if 'remote_run_host' in lit_config.params: - configure_remote_run() --elif not kIsWindows: -+elif not kIsWindows and not run_os == 'wasi': - if 'use_os_stdlib' in lit_config.params: - config.available_features.add('use_os_stdlib') - --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0040-test-Disable-test-stdlib-Duration.swift-on-32bit-pla.patch b/schemes/release-5.9/swift/0040-test-Disable-test-stdlib-Duration.swift-on-32bit-pla.patch deleted file mode 100644 index 61a6f9ed..00000000 --- a/schemes/release-5.9/swift/0040-test-Disable-test-stdlib-Duration.swift-on-32bit-pla.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 6fa7d5e3dc0153bbde6d20e9d307a2d33a8297bf Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Fri, 26 May 2023 16:25:14 +0000 -Subject: [PATCH] [test] Disable test/stdlib/Duration.swift on 32bit platforms - -Because Int128 operations are not supported on 32bit platforms. ---- - test/stdlib/Duration.swift | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/test/stdlib/Duration.swift b/test/stdlib/Duration.swift -index c5bfb87b3fb..1a23b1c157b 100644 ---- a/test/stdlib/Duration.swift -+++ b/test/stdlib/Duration.swift -@@ -1,6 +1,9 @@ - // RUN: %target-run-simple-swift - // REQUIRES: executable_test - -+// Int128 operations are not supported on 32bit platforms. See `dividingFullWidth` in IntegerTypes.swift.gyb -+// UNSUPPORTED: PTRSIZE=32 -+ - import StdlibUnittest - - var suite = TestSuite("DurationTests") --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0041-wasm-test-Add-WebAssembly-test-case-for-FloatingPoin.patch b/schemes/release-5.9/swift/0041-wasm-test-Add-WebAssembly-test-case-for-FloatingPoin.patch deleted file mode 100644 index 49ae2943..00000000 --- a/schemes/release-5.9/swift/0041-wasm-test-Add-WebAssembly-test-case-for-FloatingPoin.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 8ed8583346706e7099332274bb14ffe96e11429f Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 09:37:03 +0000 -Subject: [PATCH] [wasm][test] Add WebAssembly test case for - FloatingPointIR.swift - ---- - test/stdlib/FloatingPointIR.swift | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/test/stdlib/FloatingPointIR.swift b/test/stdlib/FloatingPointIR.swift -index a00469c855c..00410eee5a4 100644 ---- a/test/stdlib/FloatingPointIR.swift -+++ b/test/stdlib/FloatingPointIR.swift -@@ -56,3 +56,6 @@ func testConstantFoldFloatLiterals() { - - // s390x: call swiftcc void @"$s15FloatingPointIR13acceptFloat32yySfF{{.*}}"(float 1.000000e+00) - // s390x: call swiftcc void @"$s15FloatingPointIR13acceptFloat64yySdF{{.*}}"(double 1.000000e+00) -+ -+// wasm32: call swiftcc void @"$s15FloatingPointIR13acceptFloat32yySfF{{.*}}"(float 1.000000e+00) -+// wasm32: call swiftcc void @"$s15FloatingPointIR13acceptFloat64yySdF{{.*}}"(double 1.000000e+00) --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0042-test-Make-KeyPath-test-pointer-size-agnostic.patch b/schemes/release-5.9/swift/0042-test-Make-KeyPath-test-pointer-size-agnostic.patch deleted file mode 100644 index d1b444e5..00000000 --- a/schemes/release-5.9/swift/0042-test-Make-KeyPath-test-pointer-size-agnostic.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 30147096910f461b6607d6241e8271033a0a9b62 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 09:37:52 +0000 -Subject: [PATCH] [test] Make KeyPath test pointer-size agnostic - -The field offset of the `age` property is 16 bytes on 64-bit platforms -but not on other pointer-sized platforms. ---- - test/stdlib/KeyPath.swift | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/test/stdlib/KeyPath.swift b/test/stdlib/KeyPath.swift -index 1649e7087b1..1358345f2e2 100644 ---- a/test/stdlib/KeyPath.swift -+++ b/test/stdlib/KeyPath.swift -@@ -1085,7 +1085,7 @@ if #available(SwiftStdlib 5.9, *) { - let dogAgeKp = _createOffsetBasedKeyPath( - root: Dog.self, - value: Int.self, -- offset: 16 -+ offset: MemoryLayout.size - ) as? KeyPath - - expectNotNil(dogAgeKp) --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0043-wasm-test-HACK-Disable-PrintStruct.swift-test-for-un.patch b/schemes/release-5.9/swift/0043-wasm-test-HACK-Disable-PrintStruct.swift-test-for-un.patch deleted file mode 100644 index 57e900eb..00000000 --- a/schemes/release-5.9/swift/0043-wasm-test-HACK-Disable-PrintStruct.swift-test-for-un.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 2af4caa5e34226e8da4f5718f2d77938a91b8202 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 09:40:00 +0000 -Subject: [PATCH] [wasm][test] HACK: Disable PrintStruct.swift test for unclear - reason - ---- - test/stdlib/PrintStruct.swift | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/test/stdlib/PrintStruct.swift b/test/stdlib/PrintStruct.swift -index 9ecac235539..b616e61f517 100644 ---- a/test/stdlib/PrintStruct.swift -+++ b/test/stdlib/PrintStruct.swift -@@ -4,7 +4,10 @@ - // RUN: %target-codesign %t/main - // RUN: %target-run %t/main - // REQUIRES: executable_test --// REQUIRES: reflection -+// -+// FIXME Disable this case because this failed on only CI. -+// Failed with 'Caught exception of type "CallIndirectOOB"' -+// UNSUPPORTED: CPU=wasm32 - - import StdlibUnittest - import PrintTestTypes --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0044-static-stdlib-Move-static-executable-args.lnk-under-.patch b/schemes/release-5.9/swift/0044-static-stdlib-Move-static-executable-args.lnk-under-.patch deleted file mode 100644 index 202402ac..00000000 --- a/schemes/release-5.9/swift/0044-static-stdlib-Move-static-executable-args.lnk-under-.patch +++ /dev/null @@ -1,46 +0,0 @@ -From ed57c661ed3bf26e248d252cb9c110ba33440aeb Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Wed, 7 Jun 2023 19:04:23 +0000 -Subject: [PATCH] [static-stdlib] Move static-executable-args.lnk under - stdlib/public/Resources/linux - -This is a preparatory change for adding a static executable support for WASI ---- - .../public/Resources/linux}/static-executable-args.lnk | 0 - stdlib/public/runtime/CMakeLists.txt | 5 +++-- - 2 files changed, 3 insertions(+), 2 deletions(-) - rename {utils => stdlib/public/Resources/linux}/static-executable-args.lnk (100%) - -diff --git a/utils/static-executable-args.lnk b/stdlib/public/Resources/linux/static-executable-args.lnk -similarity index 100% -rename from utils/static-executable-args.lnk -rename to stdlib/public/Resources/linux/static-executable-args.lnk -diff --git a/stdlib/public/runtime/CMakeLists.txt b/stdlib/public/runtime/CMakeLists.txt -index 0d3bc17f595..e43c0775cdb 100644 ---- a/stdlib/public/runtime/CMakeLists.txt -+++ b/stdlib/public/runtime/CMakeLists.txt -@@ -114,18 +114,19 @@ set(sdk "${SWIFT_HOST_VARIANT_SDK}") - if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX") - set(static_binary_lnk_file_list) - string(TOLOWER "${sdk}" lowercase_sdk) -+ set(static_binary_lnk_src "${SWIFT_SOURCE_DIR}/stdlib/public/Resources/${lowercase_sdk}/static-executable-args.lnk") - - # Generate the static-executable-args.lnk file used for ELF systems (eg linux) - set(linkfile "${lowercase_sdk}/static-executable-args.lnk") - add_custom_command_target(swift_static_binary_${sdk}_args - COMMAND - "${CMAKE_COMMAND}" -E copy -- "${SWIFT_SOURCE_DIR}/utils/static-executable-args.lnk" -+ "${static_binary_lnk_src}" - "${SWIFTSTATICLIB_DIR}/${linkfile}" - OUTPUT - "${SWIFTSTATICLIB_DIR}/${linkfile}" - DEPENDS -- "${SWIFT_SOURCE_DIR}/utils/static-executable-args.lnk") -+ "${static_binary_lnk_src}") - - list(APPEND static_binary_lnk_file_list ${swift_static_binary_${sdk}_args}) - swift_install_in_component(FILES "${SWIFTSTATICLIB_DIR}/${linkfile}" --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0045-static-stdlib-NFC-Generalize-the-static-executable-a.patch b/schemes/release-5.9/swift/0045-static-stdlib-NFC-Generalize-the-static-executable-a.patch deleted file mode 100644 index 00f36e28..00000000 --- a/schemes/release-5.9/swift/0045-static-stdlib-NFC-Generalize-the-static-executable-a.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 0a734aa1cc8b18de5c5c65696ed664d43b728be1 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Fri, 9 Jun 2023 15:43:23 +0000 -Subject: [PATCH] [static-stdlib] NFC: Generalize the - static-executable-args.lnk file generation - -This patch makes the build system to copy the lnk files for each -stdlib targets if needed instead of only for the Linux target. ---- - stdlib/public/runtime/CMakeLists.txt | 48 ++++++++++++++++------------ - 1 file changed, 27 insertions(+), 21 deletions(-) - -diff --git a/stdlib/public/runtime/CMakeLists.txt b/stdlib/public/runtime/CMakeLists.txt -index e43c0775cdb..54a06b3697e 100644 ---- a/stdlib/public/runtime/CMakeLists.txt -+++ b/stdlib/public/runtime/CMakeLists.txt -@@ -110,28 +110,34 @@ set(swift_runtime_library_compile_flags ${swift_runtime_compile_flags}) - list(APPEND swift_runtime_library_compile_flags -DswiftCore_EXPORTS) - list(APPEND swift_runtime_library_compile_flags -I${SWIFT_SOURCE_DIR}/stdlib/include/llvm/Support -I${SWIFT_SOURCE_DIR}/include) - --set(sdk "${SWIFT_HOST_VARIANT_SDK}") --if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX") -+if(SWIFT_BUILD_STATIC_STDLIB) - set(static_binary_lnk_file_list) -- string(TOLOWER "${sdk}" lowercase_sdk) -- set(static_binary_lnk_src "${SWIFT_SOURCE_DIR}/stdlib/public/Resources/${lowercase_sdk}/static-executable-args.lnk") -- -- # Generate the static-executable-args.lnk file used for ELF systems (eg linux) -- set(linkfile "${lowercase_sdk}/static-executable-args.lnk") -- add_custom_command_target(swift_static_binary_${sdk}_args -- COMMAND -- "${CMAKE_COMMAND}" -E copy -- "${static_binary_lnk_src}" -- "${SWIFTSTATICLIB_DIR}/${linkfile}" -- OUTPUT -- "${SWIFTSTATICLIB_DIR}/${linkfile}" -- DEPENDS -- "${static_binary_lnk_src}") -- -- list(APPEND static_binary_lnk_file_list ${swift_static_binary_${sdk}_args}) -- swift_install_in_component(FILES "${SWIFTSTATICLIB_DIR}/${linkfile}" -- DESTINATION "lib/swift_static/${lowercase_sdk}" -- COMPONENT stdlib) -+ -+ foreach(sdk ${SWIFT_SDKS}) -+ if(NOT "${sdk}" STREQUAL "LINUX") -+ continue() -+ endif() -+ -+ string(TOLOWER "${sdk}" lowercase_sdk) -+ set(static_binary_lnk_src "${SWIFT_SOURCE_DIR}/stdlib/public/Resources/${lowercase_sdk}/static-executable-args.lnk") -+ -+ # Generate the static-executable-args.lnk file used for ELF systems (eg linux) -+ set(linkfile "${lowercase_sdk}/static-executable-args.lnk") -+ add_custom_command_target(swift_static_binary_${sdk}_args -+ COMMAND -+ "${CMAKE_COMMAND}" -E copy -+ "${static_binary_lnk_src}" -+ "${SWIFTSTATICLIB_DIR}/${linkfile}" -+ OUTPUT -+ "${SWIFTSTATICLIB_DIR}/${linkfile}" -+ DEPENDS -+ "${static_binary_lnk_src}") -+ -+ list(APPEND static_binary_lnk_file_list ${swift_static_binary_${sdk}_args}) -+ swift_install_in_component(FILES "${SWIFTSTATICLIB_DIR}/${linkfile}" -+ DESTINATION "lib/swift_static/${lowercase_sdk}" -+ COMPONENT stdlib) -+ endforeach() - add_dependencies(stdlib ${static_binary_lnk_file_list}) - add_custom_target(static_binary_magic ALL DEPENDS ${static_binary_lnk_file_list}) - endif() --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0046-static-stdlib-Add-static-executable-support-for-WASI.patch b/schemes/release-5.9/swift/0046-static-stdlib-Add-static-executable-support-for-WASI.patch deleted file mode 100644 index 3721a49d..00000000 --- a/schemes/release-5.9/swift/0046-static-stdlib-Add-static-executable-support-for-WASI.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 9c494dccd974069c3b8366d0897d8a8de7a12cea Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Fri, 9 Jun 2023 15:47:16 +0000 -Subject: [PATCH] [static-stdlib] Add static executable support for WASI target - -This patch adds static-executble-args.lnk file for WASI target ---- - .../public/Resources/wasi/static-executable-args.lnk | 11 +++++++++++ - stdlib/public/runtime/CMakeLists.txt | 2 +- - 2 files changed, 12 insertions(+), 1 deletion(-) - create mode 100644 stdlib/public/Resources/wasi/static-executable-args.lnk - -diff --git a/stdlib/public/Resources/wasi/static-executable-args.lnk b/stdlib/public/Resources/wasi/static-executable-args.lnk -new file mode 100644 -index 00000000000..1500f94f891 ---- /dev/null -+++ b/stdlib/public/Resources/wasi/static-executable-args.lnk -@@ -0,0 +1,11 @@ -+-static -+-lswiftSwiftOnoneSupport -+-ldl -+-lstdc++ -+-lm -+-lwasi-emulated-mman -+-lwasi-emulated-signal -+-lwasi-emulated-process-clocks -+-Xlinker --error-limit=0 -+-Xlinker --no-gc-sections -+-Xlinker --threads=1 -diff --git a/stdlib/public/runtime/CMakeLists.txt b/stdlib/public/runtime/CMakeLists.txt -index 54a06b3697e..11db27f97dd 100644 ---- a/stdlib/public/runtime/CMakeLists.txt -+++ b/stdlib/public/runtime/CMakeLists.txt -@@ -114,7 +114,7 @@ if(SWIFT_BUILD_STATIC_STDLIB) - set(static_binary_lnk_file_list) - - foreach(sdk ${SWIFT_SDKS}) -- if(NOT "${sdk}" STREQUAL "LINUX") -+ if(NOT "${sdk}" STREQUAL "LINUX" AND NOT "${sdk}" STREQUAL "WASI") - continue() - endif() - --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0047-wasm-stdlib-HACK-Add-pthread-stub-to-avoid-linking-e.patch b/schemes/release-5.9/swift/0047-wasm-stdlib-HACK-Add-pthread-stub-to-avoid-linking-e.patch deleted file mode 100644 index 9ba2231b..00000000 --- a/schemes/release-5.9/swift/0047-wasm-stdlib-HACK-Add-pthread-stub-to-avoid-linking-e.patch +++ /dev/null @@ -1,215 +0,0 @@ -From d314aced8ed1c9a18fb2f967572474cf6bb8e85c Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 09:45:10 +0000 -Subject: [PATCH] [wasm][stdlib] HACK: Add pthread stub to avoid linking error - -This is a hack to avoid missing pthread symbols error when linking. But -we now have `SWIFT_STDLIB_SINGLE_THREADED_RUNTIME` mode so the hack should -not be necessary anymore. ---- - stdlib/public/CMakeLists.txt | 4 + - .../Resources/wasi/static-executable-args.lnk | 1 + - stdlib/public/WASI/CMakeLists.txt | 4 + - stdlib/public/WASI/Pthread.cpp | 153 ++++++++++++++++++ - 4 files changed, 162 insertions(+) - create mode 100644 stdlib/public/WASI/CMakeLists.txt - create mode 100644 stdlib/public/WASI/Pthread.cpp - -diff --git a/stdlib/public/CMakeLists.txt b/stdlib/public/CMakeLists.txt -index a080c874711..6c6883a6475 100644 ---- a/stdlib/public/CMakeLists.txt -+++ b/stdlib/public/CMakeLists.txt -@@ -142,6 +142,10 @@ if(SWIFT_BUILD_STDLIB) - add_subdirectory(core) - add_subdirectory(SwiftOnoneSupport) - -+ if(WASI IN_LIST SWIFT_SDKS) -+ add_subdirectory(WASI) -+ endif() -+ - if(SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING) - add_subdirectory(Differentiation) - endif() -diff --git a/stdlib/public/Resources/wasi/static-executable-args.lnk b/stdlib/public/Resources/wasi/static-executable-args.lnk -index 1500f94f891..a18d5fc3668 100644 ---- a/stdlib/public/Resources/wasi/static-executable-args.lnk -+++ b/stdlib/public/Resources/wasi/static-executable-args.lnk -@@ -1,5 +1,6 @@ - -static - -lswiftSwiftOnoneSupport -+-lswiftWasiPthread - -ldl - -lstdc++ - -lm -diff --git a/stdlib/public/WASI/CMakeLists.txt b/stdlib/public/WASI/CMakeLists.txt -new file mode 100644 -index 00000000000..0d088443ad7 ---- /dev/null -+++ b/stdlib/public/WASI/CMakeLists.txt -@@ -0,0 +1,4 @@ -+add_swift_target_library(swiftWasiPthread STATIC IS_STDLIB -+ Pthread.cpp -+ TARGET_SDKS WASI -+ INSTALL_IN_COMPONENT stdlib) -diff --git a/stdlib/public/WASI/Pthread.cpp b/stdlib/public/WASI/Pthread.cpp -new file mode 100644 -index 00000000000..5a64d9bdb4c ---- /dev/null -+++ b/stdlib/public/WASI/Pthread.cpp -@@ -0,0 +1,153 @@ -+// SPDX-License-Identifier: 0BSD -+// prototypes taken from opengroup -+#include -+#include -+#include -+#include -+ -+#define STUB() do {fprintf(stderr, "FakePthread: unsupported %s\n", __func__);abort();}while(0) -+ -+// mutexes: just no-ops -+ -+int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) { -+ return 0; -+} -+ -+int pthread_mutex_destroy(pthread_mutex_t *mutex) { -+ return 0; -+} -+ -+int pthread_mutexattr_init(pthread_mutexattr_t *attr) { -+ return 0; -+} -+ -+int pthread_mutexattr_destroy(pthread_mutexattr_t *attr) { -+ return 0; -+} -+ -+int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type) { -+ return 0; -+} -+ -+int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) { -+ return 0; -+} -+ -+int pthread_mutex_lock(pthread_mutex_t *mutex) { -+ return 0; -+} -+ -+int pthread_mutex_trylock(pthread_mutex_t *mutex) { -+ return 0; -+} -+ -+int pthread_mutex_unlock(pthread_mutex_t *mutex) { -+ return 0; -+} -+ -+// pthread_cond: STUB -+ -+int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) { -+ return 0; -+} -+ -+int pthread_cond_destroy(pthread_cond_t *cond) { -+ return 0; -+} -+ -+int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) { -+ STUB(); -+} -+ -+int pthread_cond_timedwait(pthread_cond_t *cond, -+ pthread_mutex_t *mutex, const struct timespec *abstime) { -+ STUB(); -+} -+ -+int pthread_cond_broadcast(pthread_cond_t *cond) { -+ return 0; -+} -+ -+int pthread_cond_signal(pthread_cond_t *cond) { -+ return 0; -+} -+ -+// tls -+ -+int pthread_key_create(pthread_key_t *key, void (*destructor)(void*)) { -+ STUB(); -+} -+ -+void *pthread_getspecific(pthread_key_t key) { -+ STUB(); -+} -+ -+int pthread_setspecific(pthread_key_t key, const void *value) { -+ STUB(); -+} -+ -+// threads -+ -+pthread_t pthread_self() { -+ return (pthread_t)1234; -+} -+ -+#undef pthread_equal -+ -+int pthread_equal(pthread_t t1, pthread_t t2) { -+ return t1 == t2; -+} -+ -+int pthread_join(pthread_t thread, void **value_ptr) { -+ STUB(); -+} -+ -+int pthread_detach(pthread_t thread) { -+ STUB(); -+} -+ -+int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg) { -+ return 0; -+} -+ -+// once -+ -+int pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) { -+ STUB(); -+} -+ -+// rwlock -+ -+int pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) { -+ return 0; -+} -+ -+int pthread_rwlock_destroy(pthread_rwlock_t *rwlock) { -+ return 0; -+} -+ -+int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock) { -+ return 0; -+} -+ -+int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock) { -+ return 0; -+} -+ -+int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock) { -+ return 0; -+} -+ -+int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock) { -+ return 0; -+} -+ -+int pthread_rwlock_unlock(pthread_rwlock_t *rwlock) { -+ return 0; -+} -+ -+// named semaphores -+ -+sem_t *sem_open(const char *name, int oflag, ...) { -+ STUB(); -+} --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0048-wasm-build-Add-support-for-WebAssembly-in-build-scri.patch b/schemes/release-5.9/swift/0048-wasm-build-Add-support-for-WebAssembly-in-build-scri.patch deleted file mode 100644 index fe1e7210..00000000 --- a/schemes/release-5.9/swift/0048-wasm-build-Add-support-for-WebAssembly-in-build-scri.patch +++ /dev/null @@ -1,61 +0,0 @@ -From fa8780526ce5d4e52badd2cb4034f2beb08941a4 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 09:49:27 +0000 -Subject: [PATCH] [wasm][build] Add support for WebAssembly in build-script - ---- - utils/build-script-impl | 11 +++++++++++ - .../host_specific_configuration.py | 2 ++ - 2 files changed, 13 insertions(+) - -diff --git a/utils/build-script-impl b/utils/build-script-impl -index 4a243bd7cab..7325d9b1b98 100755 ---- a/utils/build-script-impl -+++ b/utils/build-script-impl -@@ -116,12 +116,16 @@ KNOWN_SETTINGS=( - darwin-toolchain-require-use-os-runtime "0" "When setting up a plist for a toolchain, require the users of the toolchain to link against the OS instead of the packaged toolchain runtime. 0 for false, 1 for true" - darwin-xcrun-toolchain "default" "the name of the toolchain to use on Darwin" - -+ ## WebAssembly/WASI Options -+ wasi-sysroot "" "An absolute path to the wasi-sysroot that will be used as a libc implementation for Wasm builds" -+ - ## Build Types for Components - swift-stdlib-build-type "Debug" "the CMake build variant for Swift" - - ## Skip Build ... - skip-build "" "set to configure as usual while skipping the build step" - skip-build-android "" "set to skip building Swift stdlibs for Android" -+ skip-build-wasm "" "set to skip building Swift stdlibs for WebAssembly" - skip-build-benchmarks "" "set to skip building Swift Benchmark Suite" - skip-build-clang-tools-extra "" "set to skip building clang-tools-extra as part of llvm" - skip-build-compiler-rt "" "set to skip building Compiler-RT" -@@ -1737,6 +1741,13 @@ for host in "${ALL_HOSTS[@]}"; do - ) - fi - -+ if [[ ! "${SKIP_BUILD_WASM}" ]]; then -+ cmake_options=( -+ "${cmake_options[@]}" -+ -DSWIFT_WASI_SYSROOT_PATH:STRING="${WASI_SYSROOT}" -+ ) -+ fi -+ - if [[ $(is_cross_tools_host ${host}) && "${host}" == "openbsd-"* && -n "${OPENBSD_USE_TOOLCHAIN_FILE}" ]]; then - cmake_options=( - "${cmake_options[@]}" -diff --git a/utils/swift_build_support/swift_build_support/host_specific_configuration.py b/utils/swift_build_support/swift_build_support/host_specific_configuration.py -index e976cc35920..e823935fb56 100644 ---- a/utils/swift_build_support/swift_build_support/host_specific_configuration.py -+++ b/utils/swift_build_support/swift_build_support/host_specific_configuration.py -@@ -260,6 +260,8 @@ class HostSpecificConfiguration(object): - StdlibDeploymentTarget.AppleWatchSimulator) - if not stage_dependent_args.build_android: - platforms_to_skip_build.add(StdlibDeploymentTarget.Android) -+ if not args.build_wasm: -+ platforms_to_skip_build.add(StdlibDeploymentTarget.WASI) - return platforms_to_skip_build - - def __platforms_to_skip_test(self, args, stage_dependent_args): --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0049-wasm-build-HACK-Add-SwiftWasm-compiler-vendor-suppor.patch b/schemes/release-5.9/swift/0049-wasm-build-HACK-Add-SwiftWasm-compiler-vendor-suppor.patch deleted file mode 100644 index 9560bc8a..00000000 --- a/schemes/release-5.9/swift/0049-wasm-build-HACK-Add-SwiftWasm-compiler-vendor-suppor.patch +++ /dev/null @@ -1,78 +0,0 @@ -From 603537cd1a90e8941620bc7af2747406c60bd724 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 20 Jun 2023 09:51:29 +0000 -Subject: [PATCH] [wasm][build] HACK: Add SwiftWasm compiler vendor support - -This patch should not be upstreamed. Maybe we can use -`--compiler-vendor=none` to avoid hardcoding specific downstream names. ---- - .../build_swift/build_swift/driver_arguments.py | 2 +- - .../swift_build_support/products/llvm.py | 7 +++++++ - .../swift_build_support/products/swift.py | 16 ++++++++++++---- - 3 files changed, 20 insertions(+), 5 deletions(-) - -diff --git a/utils/build_swift/build_swift/driver_arguments.py b/utils/build_swift/build_swift/driver_arguments.py -index f2ff30c5617..56eb06a06e7 100644 ---- a/utils/build_swift/build_swift/driver_arguments.py -+++ b/utils/build_swift/build_swift/driver_arguments.py -@@ -459,7 +459,7 @@ def create_argument_parser(): - help='if set, provide a fixed path for the Swift backtracer') - - option('--compiler-vendor', store, -- choices=['none', 'apple'], -+ choices=['none', 'apple', 'swiftwasm'], - default=defaults.COMPILER_VENDOR, - help='Compiler vendor name') - option('--clang-compiler-version', store, -diff --git a/utils/swift_build_support/swift_build_support/products/llvm.py b/utils/swift_build_support/swift_build_support/products/llvm.py -index c0011248316..f38040ae21a 100644 ---- a/utils/swift_build_support/swift_build_support/products/llvm.py -+++ b/utils/swift_build_support/swift_build_support/products/llvm.py -@@ -64,6 +64,13 @@ class LLVM(cmake_product.CMakeProduct): - if self.args.compiler_vendor == "none": - return [] - -+ if self.args.compiler_vendor == "swiftwasm": -+ return [ -+ ('CLANG_VENDOR', 'SwiftWasm'), -+ ('CLANG_VENDOR_UTI', 'org.swiftwasm.compilers.llvm.clang'), -+ ('PACKAGE_VERSION', str(self.args.clang_user_visible_version)) -+ ] -+ - if self.args.compiler_vendor != "apple": - raise RuntimeError("Unknown compiler vendor?!") - -diff --git a/utils/swift_build_support/swift_build_support/products/swift.py b/utils/swift_build_support/swift_build_support/products/swift.py -index de6843b06a1..2e8d1caf41f 100644 ---- a/utils/swift_build_support/swift_build_support/products/swift.py -+++ b/utils/swift_build_support/swift_build_support/products/swift.py -@@ -104,14 +104,22 @@ class Swift(product.Product): - if self.args.compiler_vendor == "none": - return [] - -- if self.args.compiler_vendor != "apple": -- raise RuntimeError("Unknown compiler vendor?! Was build-script \ --updated without updating swift.py?") -- - swift_compiler_version = "" - if self.args.swift_compiler_version is not None: - swift_compiler_version = self.args.swift_compiler_version - -+ if self.args.compiler_vendor == "swiftwasm": -+ return [ -+ ('SWIFT_VENDOR', 'SwiftWasm'), -+ ('SWIFT_VENDOR_UTI', 'org.swiftwasm.compilers.llvm.swift'), -+ ('SWIFT_VERSION', str(self.args.swift_user_visible_version)), -+ ('SWIFT_COMPILER_VERSION', str(swift_compiler_version)), -+ ] -+ -+ if self.args.compiler_vendor != "apple": -+ raise RuntimeError("Unknown compiler vendor?! Was build-script \ -+updated without updating swift.py?") -+ - return [ - ('SWIFT_VENDOR', 'Apple'), - ('SWIFT_VENDOR_UTI', 'com.apple.compilers.llvm.swift'), --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0050-installer-Do-not-follow-an-existing-symbolic-link-wh.patch b/schemes/release-5.9/swift/0050-installer-Do-not-follow-an-existing-symbolic-link-wh.patch deleted file mode 100644 index 76bd8b27..00000000 --- a/schemes/release-5.9/swift/0050-installer-Do-not-follow-an-existing-symbolic-link-wh.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 60034f0d6eb1455827086720f53ad657072ec4f7 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 24 Nov 2020 13:16:58 +0900 -Subject: [PATCH] [installer] Do not follow an existing symbolic link when - overwriting -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Without `-h` option, `ln` command makes a symbolic link under the existing -link destination like `Toolchains/swift-DEVELOPMENT-SNAPSHOT-XX.xctoolchain/`. - -``` -$ ln -fs swift-DEVELOPMENT-SNAPSHOT-XX.xctoolchain swift-latest.xctoolchain -$ ln -fs swift-DEVELOPMENT-SNAPSHOT-YY.xctoolchain swift-latest.xctoolchain -$ tree -|-- swift-DEVELOPMENT-SNAPSHOT-XX.xctoolchain -|   |-- swift-DEVELOPMENT-SNAPSHOT-YY.xctoolchain -> swift-DEVELOPMENT-SNAPSHOT-YY.xctoolchain -|-- swift-DEVELOPMENT-SNAPSHOT-YY.xctoolchain -|-- swift-latest.xctoolchain -> swift-DEVELOPMENT-SNAPSHOT-XX.xctoolchain -``` - -So we should not follow the existing symbolic link even if it already -exists. ---- - utils/darwin-installer-scripts/postinstall | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/utils/darwin-installer-scripts/postinstall b/utils/darwin-installer-scripts/postinstall -index 8f00806645e..e9750f04e95 100755 ---- a/utils/darwin-installer-scripts/postinstall -+++ b/utils/darwin-installer-scripts/postinstall -@@ -13,4 +13,4 @@ - - INSTALLED_TOOLCHAIN=$2 - --ln -fs "${INSTALLED_TOOLCHAIN}" "${INSTALLED_TOOLCHAIN%/*}/swift-latest.xctoolchain" -+ln -fhs "${INSTALLED_TOOLCHAIN}" "${INSTALLED_TOOLCHAIN%/*}/swift-latest.xctoolchain" --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0051-Concurrency-Fix-signature-mismatch-of-_startTaskOnMa.patch b/schemes/release-5.9/swift/0051-Concurrency-Fix-signature-mismatch-of-_startTaskOnMa.patch deleted file mode 100644 index fc36361b..00000000 --- a/schemes/release-5.9/swift/0051-Concurrency-Fix-signature-mismatch-of-_startTaskOnMa.patch +++ /dev/null @@ -1,27 +0,0 @@ -From a450abbb37f2761d7e89d15397ff55cc2c2a9bf3 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Sun, 11 Jun 2023 12:16:07 +0000 -Subject: [PATCH] [Concurrency] Fix signature mismatch of _startTaskOnMainActor - -The function is defined in Task.cpp with a void return type, but -referenced in Task.swift with an pointer return type. ---- - stdlib/public/Concurrency/Task.swift | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/stdlib/public/Concurrency/Task.swift b/stdlib/public/Concurrency/Task.swift -index 6988cbde736..33913b92794 100644 ---- a/stdlib/public/Concurrency/Task.swift -+++ b/stdlib/public/Concurrency/Task.swift -@@ -933,7 +933,7 @@ extension UnsafeCurrentTask: Equatable { - func _getCurrentAsyncTask() -> Builtin.NativeObject? - - @_silgen_name("swift_task_startOnMainActor") --fileprivate func _startTaskOnMainActor(_ task: Builtin.NativeObject) -> Builtin.NativeObject? -+fileprivate func _startTaskOnMainActor(_ task: Builtin.NativeObject) - - @available(SwiftStdlib 5.1, *) - @_silgen_name("swift_task_getJobFlags") --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0052-wasm-stdlib-Fix-return-address-strategy-selection.patch b/schemes/release-5.9/swift/0052-wasm-stdlib-Fix-return-address-strategy-selection.patch deleted file mode 100644 index db3160f4..00000000 --- a/schemes/release-5.9/swift/0052-wasm-stdlib-Fix-return-address-strategy-selection.patch +++ /dev/null @@ -1,37 +0,0 @@ -From e20de32c658080e7612f398aecfdf6212677774f Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Sat, 10 Jun 2023 10:00:19 +0000 -Subject: [PATCH] [wasm][stdlib] Fix return-address strategy selection - -__GNUC__ can be defined on Wasm targets as well, so we need to check -__wasm__ first. ---- - stdlib/public/runtime/Exclusivity.cpp | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/stdlib/public/runtime/Exclusivity.cpp b/stdlib/public/runtime/Exclusivity.cpp -index e0cb4902c49..39a14d73298 100644 ---- a/stdlib/public/runtime/Exclusivity.cpp -+++ b/stdlib/public/runtime/Exclusivity.cpp -@@ -37,14 +37,14 @@ - #include - - // Pick a return-address strategy --#if __GNUC__ -+#if defined(__wasm__) -+// Wasm can't access call frame for security purposes -+#define get_return_address() ((void*) 0) -+#elif __GNUC__ - #define get_return_address() __builtin_return_address(0) - #elif _MSC_VER - #include - #define get_return_address() _ReturnAddress() --#elif defined(__wasm__) --// Wasm can't access call frame for security purposes --#define get_return_address() ((void*) 0) - #else - #error missing implementation for get_return_address - #define get_return_address() ((void*) 0) --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0053-Driver-Use-WebAssembly-toolchain-for-WASI-target.patch b/schemes/release-5.9/swift/0053-Driver-Use-WebAssembly-toolchain-for-WASI-target.patch deleted file mode 100644 index b134131c..00000000 --- a/schemes/release-5.9/swift/0053-Driver-Use-WebAssembly-toolchain-for-WASI-target.patch +++ /dev/null @@ -1,83 +0,0 @@ -From 65443b6171e474b194c86b3ce1d7ed3a10d63256 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Wed, 7 Jun 2023 16:24:46 +0000 -Subject: [PATCH] [Driver] Use WebAssembly toolchain for WASI target - -The toolchain was introduced in 710816d3e0ad55b98fac698072f5e1b5f55237d8 -but was not used. Test cases now use fake resource dir to lookup -static-executable-args.lnk file, which is required by the toolchain but -is not present when not building stdlib for WASI. ---- - lib/Driver/Driver.cpp | 2 +- - .../lib/swift_static/wasi/static-executable-args.lnk | 0 - test/Driver/profiling.swift | 4 ++-- - test/Driver/sdk.swift | 2 +- - test/Driver/wasm.swift | 4 ++-- - 5 files changed, 6 insertions(+), 6 deletions(-) - create mode 100644 test/Driver/Inputs/fake-resource-dir/lib/swift_static/wasi/static-executable-args.lnk - -diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp -index 782bda3b920..023d60b7533 100644 ---- a/lib/Driver/Driver.cpp -+++ b/lib/Driver/Driver.cpp -@@ -367,7 +367,7 @@ Driver::buildToolChain(const llvm::opt::InputArgList &ArgList) { - case llvm::Triple::Haiku: - return std::make_unique(*this, target); - case llvm::Triple::WASI: -- return std::make_unique(*this, target); -+ return std::make_unique(*this, target); - case llvm::Triple::UnknownOS: - return std::make_unique(*this, target); - default: -diff --git a/test/Driver/Inputs/fake-resource-dir/lib/swift_static/wasi/static-executable-args.lnk b/test/Driver/Inputs/fake-resource-dir/lib/swift_static/wasi/static-executable-args.lnk -new file mode 100644 -index 00000000000..e69de29bb2d -diff --git a/test/Driver/profiling.swift b/test/Driver/profiling.swift -index f96cea46e33..45a9f84d12b 100644 ---- a/test/Driver/profiling.swift -+++ b/test/Driver/profiling.swift -@@ -20,7 +20,7 @@ - // RUN: %swiftc_driver -sdk "" -driver-print-jobs -profile-generate -target x86_64-unknown-linux-gnu %s | %FileCheck -check-prefix=CHECK -check-prefix=LINUX %s - // RUN: %swiftc_driver -sdk "" -driver-print-jobs -profile-generate -target x86_64-unknown-windows-msvc %s | %FileCheck -check-prefix=CHECK -check-prefix=WINDOWS %s - --// RUN: %swiftc_driver -sdk "" -driver-print-jobs -profile-generate -target wasm32-unknown-wasi %s | %FileCheck -check-prefix CHECK -check-prefix WASI %s -+// RUN: %swiftc_driver -sdk "" -driver-print-jobs -profile-generate -target wasm32-unknown-wasi -resource-dir %S/Inputs/fake-resource-dir/lib/swift_static %s | %FileCheck -check-prefix CHECK -check-prefix WASI %s - - // CHECK: swift - // CHECK: -profile-generate -@@ -55,7 +55,7 @@ - // WINDOWS: -lclang_rt.profile - - // WASI: clang{{(\.exe)?"? }} --// WASI: lib{{(\\\\|/)}}swift{{(\\\\|/)}}clang{{(\\\\|/)}}lib{{(\\\\|/)}}wasi{{(\\\\|/)}}libclang_rt.profile-wasm32.a -+// WASI: lib{{(\\\\|/)}}{{swift|swift_static}}{{(\\\\|/)}}clang{{(\\\\|/)}}lib{{(\\\\|/)}}wasi{{(\\\\|/)}}libclang_rt.profile-wasm32.a - // WASI: -u__llvm_profile_runtime - - // RUN: not %swiftc_driver -sdk "" -driver-print-jobs -profile-generate -profile-use=/dev/null %s 2>&1 | %FileCheck -check-prefix=MIX_GEN_USE %s -diff --git a/test/Driver/sdk.swift b/test/Driver/sdk.swift -index dc9ad10eae3..6ec138bd8fb 100644 ---- a/test/Driver/sdk.swift -+++ b/test/Driver/sdk.swift -@@ -2,7 +2,7 @@ - // RUN: %swiftc_driver -driver-print-jobs -target x86_64-unknown-linux-gnu -g -sdk %S/../Inputs/clang-importer-sdk %s 2>&1 | %FileCheck %s --check-prefix LINUX - // RUN: %swiftc_driver -driver-print-jobs -target x86_64-unknown-freebsd -g -sdk %S/../Inputs/clang-importer-sdk %s 2>&1 | %FileCheck %s --check-prefix FREEBSD - // RUN: %swiftc_driver -driver-print-jobs -target x86_64-unknown-windows-msvc -g -sdk %S/../Inputs/clang-importer-sdk %s 2>&1 | %FileCheck %s --check-prefix WINDOWS --// RUN: %swiftc_driver -driver-print-jobs -target wasm32-unknown-wasi -g -sdk %S/../Inputs/clang-importer-sdk %s 2>&1 | %FileCheck %s --check-prefix WASI -+// RUN: %swiftc_driver -driver-print-jobs -target wasm32-unknown-wasi -g -sdk %S/../Inputs/clang-importer-sdk -resource-dir %S/Inputs/fake-resource-dir/lib/swift_static %s 2>&1 | %FileCheck %s --check-prefix WASI - - // RUN: env SDKROOT=%S/../Inputs/clang-importer-sdk %swiftc_driver_plain -target x86_64-apple-macosx10.9 -g -driver-print-jobs %s 2>&1 | %FileCheck %s --check-prefix OSX - // RUN: env SDKROOT=%S/../Inputs/clang-importer-sdk %swiftc_driver_plain -target x86_64-unknown-linux-gnu -g -driver-print-jobs %s 2>&1 | %FileCheck %s --check-prefix LINUX -diff --git a/test/Driver/wasm.swift b/test/Driver/wasm.swift -index 80de3cea5c6..04588954e85 100644 ---- a/test/Driver/wasm.swift -+++ b/test/Driver/wasm.swift -@@ -1,4 +1,4 @@ --// RUN: %swiftc_driver -driver-print-jobs -target wasm32-unknown-wasi -v %s 2>&1 | %FileCheck %s -check-prefix=CHECK-WASM -+// RUN: %swiftc_driver -driver-print-jobs -target wasm32-unknown-wasi -resource-dir %S/Inputs/fake-resource-dir/lib/swift_static -v %s 2>&1 | %FileCheck %s -check-prefix=CHECK-WASM - - // CHECK-WASM: swift{{.*}} -frontend -c -primary-file {{.*}} -target wasm32-unknown-wasi -disable-objc-interop --// CHECK-WASM: clang{{.*}} -lswiftCore --target=wasm32-unknown-wasi -v {{.*}}-o -+// CHECK-WASM: clang{{.*}} -target wasm32-unknown-wasi {{.*}}static-executable-args.lnk{{.*}}-v {{.*}}-o --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0054-wasm-Read-autolink-entries-from-custom-section-inste.patch b/schemes/release-5.9/swift/0054-wasm-Read-autolink-entries-from-custom-section-inste.patch deleted file mode 100644 index c835249f..00000000 --- a/schemes/release-5.9/swift/0054-wasm-Read-autolink-entries-from-custom-section-inste.patch +++ /dev/null @@ -1,57 +0,0 @@ -From f02cfefd72ce6505d6a0bee026e9609568c1aace Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Mon, 15 May 2023 10:01:30 +0000 -Subject: [PATCH] [wasm] Read autolink entries from custom section instead of - data segments - -This change is required since -https://github.com/apple/llvm-project/commit/d0f00c4d76d1d3d6595cb8f0ce4aca1afae87781 -and we no longer need wasm custom implementation. ---- - lib/DriverTool/autolink_extract_main.cpp | 30 ------------------------ - 1 file changed, 30 deletions(-) - -diff --git a/lib/DriverTool/autolink_extract_main.cpp b/lib/DriverTool/autolink_extract_main.cpp -index 1f2538e1ac6..4008341b026 100644 ---- a/lib/DriverTool/autolink_extract_main.cpp -+++ b/lib/DriverTool/autolink_extract_main.cpp -@@ -153,36 +153,6 @@ extractLinkerFlagsFromObjectFile(const llvm::object::ObjectFile *ObjectFile, - return false; - } - --/// Look inside the object file 'WasmObjectFile' and append any linker flags --/// found in its ".swift1_autolink_entries" section to 'LinkerFlags'. Return --/// 'true' if there was an error, and 'false' otherwise. --static bool --extractLinkerFlagsFromObjectFile(const llvm::object::WasmObjectFile *ObjectFile, -- std::vector &LinkerFlags, -- std::unordered_map &SwiftRuntimeLibraries, -- CompilerInstance &Instance) { -- // Search for the data segment we hold autolink entries in -- for (const llvm::object::WasmSegment &Segment : ObjectFile->dataSegments()) { -- if (Segment.Data.Name == ".swift1_autolink_entries") { -- -- StringRef SegmentData = llvm::toStringRef(Segment.Data.Content); -- // entries are null-terminated, so extract them and push them into -- // the set. -- llvm::SmallVector SplitFlags; -- SegmentData.split(SplitFlags, llvm::StringRef("\0", 1), -1, -- /*KeepEmpty=*/false); -- for (const auto &Flag : SplitFlags) { -- auto RuntimeLibEntry = SwiftRuntimeLibraries.find(Flag.str()); -- if (RuntimeLibEntry == SwiftRuntimeLibraries.end()) -- LinkerFlags.emplace_back(Flag.str()); -- else -- RuntimeLibEntry->second = true; -- } -- } -- } -- return false; --} -- - /// Look inside the binary 'Bin' and append any linker flags found in its - /// ".swift1_autolink_entries" section to 'LinkerFlags'. If 'Bin' is an archive, - /// recursively look inside all children within the archive. Return 'true' if --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0055-DiscardingTG-Fix-runtime-signature-mismatch-for-stat.patch b/schemes/release-5.9/swift/0055-DiscardingTG-Fix-runtime-signature-mismatch-for-stat.patch deleted file mode 100644 index 191a8b43..00000000 --- a/schemes/release-5.9/swift/0055-DiscardingTG-Fix-runtime-signature-mismatch-for-stat.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 101ce36d4df506773e7b4f9942a9404b21bc2844 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 30 May 2023 16:04:01 +0000 -Subject: [PATCH] [DiscardingTG] Fix runtime signature mismatch for statically - known -> Void closure - -Since https://github.com/apple/swift/pull/65613, DiscardingTG started to -accept `() -> Void` instead of `() -> T`, but it also changed the number -of arguments accepted by the closure from 3 to 2. So it should use -`non_future_adapter` instead of `future_adapter` to avoid runtime signature -mismatch. ---- - stdlib/public/Concurrency/Task.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/stdlib/public/Concurrency/Task.cpp b/stdlib/public/Concurrency/Task.cpp -index 1d4d57d40b0..89250c81e82 100644 ---- a/stdlib/public/Concurrency/Task.cpp -+++ b/stdlib/public/Concurrency/Task.cpp -@@ -832,7 +832,7 @@ static AsyncTaskAndContext swift_task_create_commonImpl( - // the async context to get at the parameters. - // See e.g. FutureAsyncContextPrefix. - -- if (!futureResultType) { -+ if (!futureResultType || taskCreateFlags.isDiscardingTask()) { - auto asyncContextPrefix = reinterpret_cast( - reinterpret_cast(allocation) + headerSize - - sizeof(AsyncContextPrefix)); --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0056-test-Add-missing-default-value-for-target_run_with_l.patch b/schemes/release-5.9/swift/0056-test-Add-missing-default-value-for-target_run_with_l.patch deleted file mode 100644 index 22b2e47b..00000000 --- a/schemes/release-5.9/swift/0056-test-Add-missing-default-value-for-target_run_with_l.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 7253dc1b5c2ab520dd15887fe4847b5615ad3e26 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Fri, 26 May 2023 16:19:37 +0000 -Subject: [PATCH] [test] Add missing default value for target_run_with_leaks - -This property has been reverted in main branch but still exists in this -release branch. -Reverting commit 401e9304f41e0179f631f2e8fbed30b8b20769fc ---- - test/lit.cfg | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/test/lit.cfg b/test/lit.cfg -index e229dc85a09..8a955f0da88 100644 ---- a/test/lit.cfg -+++ b/test/lit.cfg -@@ -1082,6 +1082,7 @@ target_specific_module_triple = config.variant_triple - target_future = target_specific_module_triple - - config.target_run = '' -+config.target_run_with_leaks = '' - config.target_rtti_opt = '-fno-rtti' - config.target_pic_opt = '' - config.target_cxx_lib = '-lc++' --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0057-test-Make-KeyPath-test-pointer-size-agnostic-part-2.patch b/schemes/release-5.9/swift/0057-test-Make-KeyPath-test-pointer-size-agnostic-part-2.patch deleted file mode 100644 index 1c57f323..00000000 --- a/schemes/release-5.9/swift/0057-test-Make-KeyPath-test-pointer-size-agnostic-part-2.patch +++ /dev/null @@ -1,25 +0,0 @@ -From a858c9d561f1c2a8f2bd94bb0ff31ac16f4bf0db Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Thu, 29 Jun 2023 05:57:18 +0000 -Subject: [PATCH] [test] Make KeyPath test pointer-size agnostic part 2 - ---- - test/stdlib/KeyPath.swift | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/test/stdlib/KeyPath.swift b/test/stdlib/KeyPath.swift -index 1358345f2e2..4e929110299 100644 ---- a/test/stdlib/KeyPath.swift -+++ b/test/stdlib/KeyPath.swift -@@ -1097,7 +1097,7 @@ if #available(SwiftStdlib 5.9, *) { - let catNameKp = _createOffsetBasedKeyPath( - root: Cat.self, - value: String.self, -- offset: 16 -+ offset: 2 * MemoryLayout.size - ) as? KeyPath - - expectNotNil(catNameKp) --- -2.40.0 - diff --git a/schemes/release-5.9/swift/0058-lit-Repair-tests-for-stdlib-only-build.patch b/schemes/release-5.9/swift/0058-lit-Repair-tests-for-stdlib-only-build.patch deleted file mode 100644 index 89032871..00000000 --- a/schemes/release-5.9/swift/0058-lit-Repair-tests-for-stdlib-only-build.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 57f5cb6cb91c1a472046f61e28ba3738003e468d Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Sun, 29 Oct 2023 23:27:31 +0000 -Subject: [PATCH] [lit] Repair tests for stdlib-only build - -`config.host_triple` can be None when no host tools are built - -This is based on 21d57e887ad1f2d319b8e89af90d2732d50ecf55 in main branch ---- - test/lit.cfg | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -diff --git a/test/lit.cfg b/test/lit.cfg -index 8a955f0da88..c989777dfd5 100644 ---- a/test/lit.cfg -+++ b/test/lit.cfg -@@ -566,8 +566,10 @@ else: - ) - ) - # Parse the host triple. -- (host_cpu, host_vendor, host_os, host_vers) = re.match('([^-]+)-([^-]+)-([^0-9-]+)(.*)', config.host_triple).groups() -- toolchain_lib_dir = make_path(config.swift_lib_dir, 'swift', host_os) -+ toolchain_lib_dir = None -+ if config.host_triple: -+ (host_cpu, host_vendor, host_os, host_vers) = re.match('([^-]+)-([^-]+)-([^0-9-]+)(.*)', config.host_triple).groups() -+ toolchain_lib_dir = make_path(config.swift_lib_dir, 'swift', host_os) - config.host_build_swift = ( - "%s -target %s -g %s -I %s -L %s %s" % ( - config.swiftc_driver, -@@ -575,7 +577,7 @@ else: - '' if kIsWindows else '-no-toolchain-stdlib-rpath', - config.swift_build_lib_dir, - config.swift_build_lib_dir, -- '' if kIsWindows else '-Xlinker -rpath -Xlinker {}'.format(toolchain_lib_dir) -+ '' if kIsWindows or toolchain_lib_dir is None else '-Xlinker -rpath -Xlinker {}'.format(toolchain_lib_dir) - ) - ) - --- -2.40.0 - diff --git a/schemes/release-5.9/wasi-sysroot/disable_part_modules_for_cxx_interop.patch b/schemes/release-5.9/wasi-sysroot/disable_part_modules_for_cxx_interop.patch deleted file mode 100644 index 4995a603..00000000 --- a/schemes/release-5.9/wasi-sysroot/disable_part_modules_for_cxx_interop.patch +++ /dev/null @@ -1,75 +0,0 @@ -Author: Yuta Saito -Date: Thu Dec 29 10:50:33 2022 +0000 - - Without this patch, Cxx.swiftmodule build fails on macOS host environments - -diff --git a/include/c++/v1/module.modulemap b/include/c++/v1/module.modulemap -index b5781b0..af10440 100644 ---- a/include/c++/v1/module.modulemap -+++ b/include/c++/v1/module.modulemap -@@ -44,10 +44,12 @@ module std [system] { - header "math.h" - export * - } -+ /* XXX(swiftwasm): setjmp.h is unavailable in wasi-libc - module setjmp_h { - header "setjmp.h" - export * - } -+ */ - // FIXME: is missing. - // provided by C library. - // provided by compiler. -@@ -153,10 +155,12 @@ module std [system] { - header "cmath" - export * - } -+ /* XXX(swiftwasm): setjmp.h is unavailable in wasi-libc - module csetjmp { - header "csetjmp" - export * - } -+ */ - module csignal { - header "csignal" - export * -@@ -384,10 +388,12 @@ module std [system] { - header "execution" - export * - } -+ /* XXX(swiftwasm): wasi-sdk configures with LIBCXX_ENABLE_FILESYSTEM=OFF - module filesystem { - header "filesystem" - export * - } -+ */ - module format { - header "format" - export * -@@ -645,11 +651,13 @@ module std [system] { - header "scoped_allocator" - export * - } -+ /* XXX(swiftwasm): semaphore is unavailable due to lack of thread - module semaphore { - requires cplusplus14 - header "semaphore" - export * - } -+ */ - module set { - header "set" - export initializer_list -@@ -816,10 +824,12 @@ module std [system] { - header "experimental/deque" - export * - } -+ /* XXX(swiftwasm): wasi-sdk configures with LIBCXX_ENABLE_FILESYSTEM=OFF - module filesystem { - header "experimental/filesystem" - export * - } -+ */ - module forward_list { - header "experimental/forward_list" - export * diff --git a/schemes/release-6.0/manifest.json b/schemes/release-6.0/manifest.json index 208206e6..46bd1a0f 100644 --- a/schemes/release-6.0/manifest.json +++ b/schemes/release-6.0/manifest.json @@ -1,7 +1,6 @@ { "update-checkout-scheme": "release/6.0", "base-tag": "swift-6.0.3-RELEASE", - "build-compiler": false, "icu4c": ["https://github.com/swiftwasm/icu4c-wasi/releases/download/0.8.0/icu4c-wasi.tar.xz"], "libxml2": ["https://github.com/swiftwasm/libxml2-wasm/releases/download/2.0.0/libxml2-wasm32-unknown-wasi.tar.gz"], "wasi-sysroot": "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-21/wasi-sysroot-21.0.tar.gz", diff --git a/schemes/release-6.1/manifest.json b/schemes/release-6.1/manifest.json index c4919ad8..d8671fc2 100644 --- a/schemes/release-6.1/manifest.json +++ b/schemes/release-6.1/manifest.json @@ -1,7 +1,6 @@ { "update-checkout-scheme": "release/6.1", "base-tag": "swift-6.1-DEVELOPMENT-SNAPSHOT-2025-02-21-a", - "build-compiler": false, "icu4c": [], "libxml2": [ "https://github.com/swiftwasm/libxml2-wasm/releases/download/2.0.0/libxml2-wasm32-unknown-wasi.tar.gz", diff --git a/tools/build/build-host-toolchain.sh b/tools/build/build-host-toolchain.sh deleted file mode 100755 index 8c498506..00000000 --- a/tools/build/build-host-toolchain.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -set -ex -SOURCE_PATH="$(cd "$(dirname "$0")/../../.." && pwd)" -TOOLS_BUILD_PATH="$(cd "$(dirname "$0")" && pwd)" - -PACKAGING_DIR="$SOURCE_PATH/build/Packaging" -HOST_TOOLCHAIN_DESTDIR=$PACKAGING_DIR/host-toolchain - -case $(uname -s) in - Darwin) - HOST_BUILD_PRESET=wasm_buildbot_osx_package - ;; - Linux) - HOST_BUILD_PRESET=wasm_buildbot_linux - ;; - *) - echo "Unrecognised platform $(uname -s)" - exit 1 - ;; -esac - -build_host_toolchain() { - # Build the host toolchain and SDK first. - "$SOURCE_PATH/swift/utils/build-script" \ - --preset-file="$TOOLS_BUILD_PATH/build-presets.ini" \ - --preset=$HOST_BUILD_PRESET \ - HOST_ARCHITECTURE="$(uname -m)" \ - INSTALL_DESTDIR="$HOST_TOOLCHAIN_DESTDIR" -} - -show_sccache_stats() { - # If sccache is installed in PATH - if command -v sccache &> /dev/null; then - sccache --show-stats - else - echo "sccache is not installed in PATH" - fi -} - -build_host_toolchain -echo "==================================" -echo "Host toolchain built successfully!" -echo "==================================" -echo "" -echo "sccache stats:" -show_sccache_stats diff --git a/tools/build/build-toolchain.sh b/tools/build/build-toolchain.sh index 40c14511..1823d9a3 100755 --- a/tools/build/build-toolchain.sh +++ b/tools/build/build-toolchain.sh @@ -10,51 +10,9 @@ TOOLS_BUILD_PATH="$(cd "$(dirname "$0")" && pwd)" BUILD_DIR="$SOURCE_PATH/build" PACKAGING_DIR="$BUILD_DIR/Packaging" +CROSS_COMPILER_DESTDIR=$PACKAGING_DIR/base-snapshot -need_build_cross_compiler() { - # If the scheme does not have any compiler patches, - # we can skip building compiler and use the prebuilt one. - # Return 0 if we need to build compiler, 1 otherwise. - - local patch_dir="$REPO_PATH/schemes/$SCHEME/swift" - - if [ ! -d "$patch_dir" ]; then - return 1 - fi - - if [ -z "$(ls -A "$patch_dir")" ]; then - return 1 - fi - - python3 -c 'import sys, json; exit(0 if json.load(sys.stdin).get("build-compiler", True) else 1)' < $REPO_PATH/schemes/$SCHEME/manifest.json -} - - -if need_build_cross_compiler; then - echo "Building cross compiler..." - "$TOOLS_BUILD_PATH/build-host-toolchain.sh" - CROSS_COMPILER_DESTDIR=$PACKAGING_DIR/host-toolchain - - # package-toolchain will merge the base toolchain and - # target toolchain into one toolchain. We need to overwrite - # compilers in the base toolchain with the just built ones - # in the host toolchain. So we copy the host toolchain to - # target toolchain first. - TARGET_TOOLCHAIN_DESTDIR=$PACKAGING_DIR/target-toolchain/wasm32-unknown-wasi - rm -rf "$TARGET_TOOLCHAIN_DESTDIR" - mkdir -p "$TARGET_TOOLCHAIN_DESTDIR" - rsync -a "$CROSS_COMPILER_DESTDIR/" "$TARGET_TOOLCHAIN_DESTDIR" -else - echo "Using prebuilt cross compiler..." - "$TOOLS_BUILD_PATH/install-base-toolchain" --scheme "$SCHEME" - CROSS_COMPILER_DESTDIR=$PACKAGING_DIR/base-snapshot - - # Only for release-5.9 and release-5.10 - if [ "$SCHEME" = "release-5.9" ] || [ "$SCHEME" = "release-5.10" ]; then - # HACK: Remove swift-driver since the old swift-driver used "ar" instead of "llvm-ar" - rm -f "$CROSS_COMPILER_DESTDIR/usr/bin/swift-driver" - fi -fi +"$TOOLS_BUILD_PATH/install-base-toolchain" --scheme "$SCHEME" "$TOOLS_BUILD_PATH/build-llvm-tools" --toolchain "$CROSS_COMPILER_DESTDIR" "$REPO_PATH/schemes/$SCHEME/build/build-target-toolchain.sh" \