From 31ca21f41ec5fc5d528efaa1cc765ed92c27d941 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 12:28:58 +0000 Subject: [PATCH 1/3] Update base tag for main to swift-DEVELOPMENT-SNAPSHOT-2024-09-24-a --- schemes/main/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schemes/main/manifest.json b/schemes/main/manifest.json index ed9bd791..f027188d 100644 --- a/schemes/main/manifest.json +++ b/schemes/main/manifest.json @@ -1,5 +1,5 @@ { - "base-tag": "swift-DEVELOPMENT-SNAPSHOT-2024-09-18-a", + "base-tag": "swift-DEVELOPMENT-SNAPSHOT-2024-09-24-a", "build-compiler": false, "icu4c": [], "libxml2": [ From da4efd79e284d70894d603d941a470174a8dab7b Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Wed, 25 Sep 2024 22:14:32 +0900 Subject: [PATCH 2/3] Remove upstreamed patches --- ...ss-compilation-on-macOS-host-machine.patch | 46 ------- ...LVM-for-WebAssembly-target-independe.patch | 123 ------------------ 2 files changed, 169 deletions(-) delete mode 100644 schemes/main/swift/0001-wasm-Fix-cross-compilation-on-macOS-host-machine.patch delete mode 100644 schemes/main/swift/0002-wasm-Configure-LLVM-for-WebAssembly-target-independe.patch diff --git a/schemes/main/swift/0001-wasm-Fix-cross-compilation-on-macOS-host-machine.patch b/schemes/main/swift/0001-wasm-Fix-cross-compilation-on-macOS-host-machine.patch deleted file mode 100644 index f6c627ca..00000000 --- a/schemes/main/swift/0001-wasm-Fix-cross-compilation-on-macOS-host-machine.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 59cda3636a7fddb6e68e7c87f5737c6d127c98c8 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Wed, 18 Sep 2024 17:11:23 +0000 -Subject: [PATCH 1/2] [wasm] Fix cross-compilation on macOS host machine - -We didn't set the CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_PROCESSOR when -cross-compiling stdlib for WASI. This caused the build to fail on macOS -host machines as the build system was trying to build some overlays -assuming the target is macOS. -Additionally, add a default "SWIFT_HOST_VARIANT_SDK" for WASI target -even though we don't support it as a host system yet because it's -required anyway. ---- - CMakeLists.txt | 2 ++ - .../swift_build_support/products/wasmstdlib.py | 2 ++ - 2 files changed, 4 insertions(+) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index edee1dd58e6..f04243464be 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -155,6 +155,8 @@ else() - set(SWIFT_HOST_VARIANT_SDK_default "ANDROID") - elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") - set(SWIFT_HOST_VARIANT_SDK_default "OSX") -+ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "WASI") -+ set(SWIFT_HOST_VARIANT_SDK_default "WASI") - else() - message(FATAL_ERROR "Unable to detect SDK for host system: ${CMAKE_SYSTEM_NAME}") - endif() -diff --git a/utils/swift_build_support/swift_build_support/products/wasmstdlib.py b/utils/swift_build_support/swift_build_support/products/wasmstdlib.py -index 4d8beeaae8a..d042fc38038 100644 ---- a/utils/swift_build_support/swift_build_support/products/wasmstdlib.py -+++ b/utils/swift_build_support/swift_build_support/products/wasmstdlib.py -@@ -44,6 +44,8 @@ class WasmStdlib(cmake_product.CMakeProduct): - def _build(self, host_target, target_triple): - self.cmake_options.define('CMAKE_INSTALL_PREFIX:PATH', '/usr') - self.cmake_options.define('CMAKE_BUILD_TYPE:STRING', self._build_variant) -+ self.cmake_options.define('CMAKE_SYSTEM_NAME:STRING', 'WASI') -+ self.cmake_options.define('CMAKE_SYSTEM_PROCESSOR:STRING', 'wasm32') - self.cmake_options.define( - 'SWIFT_STDLIB_BUILD_TYPE:STRING', self._build_variant) - --- -2.46.0 - diff --git a/schemes/main/swift/0002-wasm-Configure-LLVM-for-WebAssembly-target-independe.patch b/schemes/main/swift/0002-wasm-Configure-LLVM-for-WebAssembly-target-independe.patch deleted file mode 100644 index eca2c256..00000000 --- a/schemes/main/swift/0002-wasm-Configure-LLVM-for-WebAssembly-target-independe.patch +++ /dev/null @@ -1,123 +0,0 @@ -From 24bd384f841df8f357fe35c6cc890cd7b15a4114 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Thu, 19 Sep 2024 04:45:51 +0000 -Subject: [PATCH 2/2] [wasm] Configure LLVM for WebAssembly target - independently from the native LLVM build - -We have been using the host LLVM build directory to configure the Wasm -Swift stdlib. This has been working fine so far as the stdlib build is -configured with `CMAKE_SYSTEM_NAME` having host system name. However, -we fixed the stdlib build to use `WASI` as the system name properly in -the previous commit. This exposed the issue that the host LLVM build -directory is not suitable for configuring the stdlib build. ---- - .../products/wasmstdlib.py | 60 +++++++++++++++++-- - 1 file changed, 54 insertions(+), 6 deletions(-) - -diff --git a/utils/swift_build_support/swift_build_support/products/wasmstdlib.py b/utils/swift_build_support/swift_build_support/products/wasmstdlib.py -index d042fc38038..70299e37885 100644 ---- a/utils/swift_build_support/swift_build_support/products/wasmstdlib.py -+++ b/utils/swift_build_support/swift_build_support/products/wasmstdlib.py -@@ -17,6 +17,8 @@ from . import llvm - from . import swift - from . import wasisysroot - from . import wasmkit -+from .. import cmake -+from .. import shell - - - class WasmStdlib(cmake_product.CMakeProduct): -@@ -39,13 +41,52 @@ class WasmStdlib(cmake_product.CMakeProduct): - return self.args.test_wasmstdlib - - def build(self, host_target): -- self._build(host_target, 'wasm32-wasi') -+ self._build(host_target, 'wasm32-wasi', 'wasi-wasm32') - -- def _build(self, host_target, target_triple): -+ def _build(self, host_target, target_triple, short_triple): -+ llvm_build_dir = self._configure_llvm(target_triple, short_triple) -+ llvm_cmake_dir = os.path.join(llvm_build_dir, 'lib', 'cmake', 'llvm') -+ self._build_stdlib(host_target, target_triple, llvm_cmake_dir) -+ -+ def _configure_llvm(self, target_triple, short_triple): -+ # Configure LLVM for WebAssembly target independently -+ # from the native LLVM build to turn off zlib and libxml2 -+ build_root = os.path.dirname(self.build_dir) -+ build_dir = os.path.join( -+ build_root, 'llvm-%s' % short_triple) -+ llvm_source_dir = os.path.join( -+ os.path.dirname(self.source_dir), 'llvm-project', 'llvm') -+ cmake_options = cmake.CMakeOptions() -+ cmake_options.define('CMAKE_BUILD_TYPE:STRING', self._build_variant) -+ # compiler-rt for WebAssembly target is not installed in the host toolchain -+ # so skip compiler health checks here. -+ cmake_options.define('CMAKE_C_COMPILER_WORKS:BOOL', 'TRUE') -+ cmake_options.define('CMAKE_CXX_COMPILER_WORKS:BOOL', 'TRUE') -+ cmake_options.define('LLVM_COMPILER_CHECKED:BOOL', 'TRUE') -+ cmake_options.define('LLVM_ENABLE_ZLIB:BOOL', 'FALSE') -+ cmake_options.define('LLVM_ENABLE_LIBXML2:BOOL', 'FALSE') -+ cmake_options.define('LLVM_ENABLE_LIBEDIT:BOOL', 'FALSE') -+ cmake_options.define('LLVM_ENABLE_TERMINFO:BOOL', 'FALSE') -+ -+ llvm_cmake = cmake.CMake( -+ self.args, self.toolchain, prefer_native_toolchain=True) -+ # Only configure LLVM, not build it because we just need -+ # LLVM CMake functionalities -+ shell.call(["env", self.toolchain.cmake, "-B", build_dir] -+ + list(llvm_cmake.common_options(self)) -+ + list(cmake_options) -+ + [llvm_source_dir]) -+ return build_dir -+ -+ def _build_stdlib(self, host_target, target_triple, llvm_cmake_dir): - self.cmake_options.define('CMAKE_INSTALL_PREFIX:PATH', '/usr') - self.cmake_options.define('CMAKE_BUILD_TYPE:STRING', self._build_variant) -+ # Teach about the WebAssembly target. UNIX is explicitly set to TRUE -+ # as CMake still doesn't recognize WASI as a UNIX platform and the -+ # variable is used in LLVM CMake configuration. - self.cmake_options.define('CMAKE_SYSTEM_NAME:STRING', 'WASI') - self.cmake_options.define('CMAKE_SYSTEM_PROCESSOR:STRING', 'wasm32') -+ self.cmake_options.define('UNIX:BOOL', 'TRUE') - self.cmake_options.define( - 'SWIFT_STDLIB_BUILD_TYPE:STRING', self._build_variant) - -@@ -71,9 +112,13 @@ class WasmStdlib(cmake_product.CMakeProduct): - self.cmake_options.define('SWIFT_WASI_SYSROOT_PATH:STRING', - self._wasi_sysroot_path(target_triple)) - -- # It's ok to use the host LLVM build dir just for CMake functionalities -- llvm_cmake_dir = os.path.join(self._host_llvm_build_dir( -- host_target), 'lib', 'cmake', 'llvm') -+ # compiler-rt for WebAssembly target is not installed in the host toolchain -+ # so skip compiler health checks here. -+ self.cmake_options.define('CMAKE_C_COMPILER_WORKS:BOOL', 'TRUE') -+ self.cmake_options.define('CMAKE_CXX_COMPILER_WORKS:BOOL', 'TRUE') -+ self.cmake_options.define('CMAKE_Swift_COMPILER_WORKS:BOOL', 'TRUE') -+ self.cmake_options.define('LLVM_COMPILER_CHECKED:BOOL', 'TRUE') -+ - self.cmake_options.define('LLVM_DIR:PATH', llvm_cmake_dir) - - # Standalone stdlib configuration -@@ -90,6 +135,9 @@ class WasmStdlib(cmake_product.CMakeProduct): - self.cmake_options.define('SWIFT_BUILD_STATIC_STDLIB:BOOL', 'TRUE') - self.cmake_options.define('SWIFT_BUILD_DYNAMIC_STDLIB:BOOL', 'FALSE') - self.cmake_options.define('SWIFT_BUILD_STATIC_SDK_OVERLAY:BOOL', 'TRUE') -+ # TODO: Turn off library evolution once we establish a good way to teach -+ # libraries including swift-testing whether to use the stable ABI. -+ self.cmake_options.define('SWIFT_STDLIB_STABLE_ABI:BOOL', 'TRUE') - self.cmake_options.define('SWIFT_STDLIB_TRACING:BOOL', 'FALSE') - self.cmake_options.define('SWIFT_STDLIB_HAS_ASLR:BOOL', 'FALSE') - self.cmake_options.define('SWIFT_STDLIB_CONCURRENCY_TRACING:BOOL', 'FALSE') -@@ -200,7 +248,7 @@ class WasmStdlib(cmake_product.CMakeProduct): - - class WasmThreadsStdlib(WasmStdlib): - def build(self, host_target): -- self._build(host_target, 'wasm32-wasip1-threads') -+ self._build(host_target, 'wasm32-wasip1-threads', 'wasip1-threads-wasm32') - - def should_test_executable(self): - # TODO(katei): Enable tests once WasmKit supports WASI threads --- -2.46.0 - From 269614a45fb7cc110cb22fdbca3325962b98f6bc Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Thu, 26 Sep 2024 00:36:10 +0900 Subject: [PATCH 3/3] Add swift-foundation fix patch --- schemes/main/swift-foundation/944.patch | 38 +++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 schemes/main/swift-foundation/944.patch diff --git a/schemes/main/swift-foundation/944.patch b/schemes/main/swift-foundation/944.patch new file mode 100644 index 00000000..421915a2 --- /dev/null +++ b/schemes/main/swift-foundation/944.patch @@ -0,0 +1,38 @@ +From af1b3ddbb8c43c00a278619dfc8251f0f9554dc5 Mon Sep 17 00:00:00 2001 +From: Yuta Saito +Date: Wed, 25 Sep 2024 15:31:41 +0000 +Subject: [PATCH] [wasm] Fix CocoaError construction for unsupported copy/link + operations + +This is a follow-up fix for 6c0a3e8453cdde633e1c55f6112fd53a0d756979, +which re-organized CocoaError helper functions. +--- + .../FoundationEssentials/FileManager/FileOperations.swift | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/Sources/FoundationEssentials/FileManager/FileOperations.swift b/Sources/FoundationEssentials/FileManager/FileOperations.swift +index 1082e6b0..6f228d80 100644 +--- a/Sources/FoundationEssentials/FileManager/FileOperations.swift ++++ b/Sources/FoundationEssentials/FileManager/FileOperations.swift +@@ -920,10 +920,11 @@ enum _FileOperations { + try delegate.throwIfNecessary(errno, src, dst) + return + } ++ let copyFile = delegate.copyData + guard !stat.isDirectory else { + // wasi-libc does not support FTS for now, so we don't support copying/linking + // directories on WASI for now. +- let error = CocoaError.fileOperationError(.featureUnsupported, src, dst) ++ let error = CocoaError.errorWithFilePath(.featureUnsupported, src, variant: copyFile ? "Copy" : "Link", source: src, destination: dst) + try delegate.throwIfNecessary(error, src, dst) + return + } +@@ -943,7 +944,7 @@ enum _FileOperations { + try delegate.throwIfNecessary(errno, src, dst) + } + } else { +- if delegate.copyData { ++ if copyFile { + try _copyRegularFile(srcPtr, dstPtr, delegate: delegate) + } else { + if link(srcPtr, dstPtr) != 0 {