Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/scripts/build-matrix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"main": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-20.04",
# "release-5.9": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-20.04@sha256:cc1b99e352ee207da2c75c7bcf81aa8b1d2c08215fd1d05dc0777c40a62f31f1",
"release-5.10": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-20.04@sha256:cc1b99e352ee207da2c75c7bcf81aa8b1d2c08215fd1d05dc0777c40a62f31f1",
"release-6.0": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-20.04@sha256:cc1b99e352ee207da2c75c7bcf81aa8b1d2c08215fd1d05dc0777c40a62f31f1",
"release-6.0": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-20.04@sha256:9007661fb6d57ebef902618e831458e88068350b0ecc8d85e56441d25a9f4312",
},
"run_stdlib_test": true,
"run_full_test": false,
Expand All @@ -45,7 +45,7 @@
"main": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-22.04",
# "release-5.9": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-20.04@sha256:adfa0a8fbc6e5cc7ce5e38a5a9406d4fa5c557871204a65f0690478022d6b359",
"release-5.10": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-20.04@sha256:adfa0a8fbc6e5cc7ce5e38a5a9406d4fa5c557871204a65f0690478022d6b359",
"release-6.0": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-20.04@sha256:adfa0a8fbc6e5cc7ce5e38a5a9406d4fa5c557871204a65f0690478022d6b359",
"release-6.0": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-20.04@sha256:8060adba9c044b1fc751b9671167320c9cc0094d0a45d7b8fedb707c49b764c2",
},
"run_stdlib_test": true,
"run_full_test": false,
Expand All @@ -63,7 +63,7 @@
"main": "ghcr.io/swiftwasm/swift-ci:main-amazon-linux-2",
# "release-5.9": "ghcr.io/swiftwasm/swift-ci:main-amazon-linux-2@sha256:d5264ac43e935249b1c8777f6809ebbd2836cb0e8f7dac3bfeeb0b3cdb479b70",
"release-5.10": "ghcr.io/swiftwasm/swift-ci:main-amazon-linux-2@sha256:d5264ac43e935249b1c8777f6809ebbd2836cb0e8f7dac3bfeeb0b3cdb479b70",
"release-6.0": "ghcr.io/swiftwasm/swift-ci:main-amazon-linux-2@sha256:d5264ac43e935249b1c8777f6809ebbd2836cb0e8f7dac3bfeeb0b3cdb479b70",
"release-6.0": "ghcr.io/swiftwasm/swift-ci:main-amazon-linux-2@sha256:fc95912c595faecacbb869635fa871f8f31b8d6ed2f0df6792b53628db7ada94",
},
"run_stdlib_test": false,
"run_full_test": false,
Expand Down Expand Up @@ -116,7 +116,7 @@
"target": "ubuntu22.04_x86_64",
"containers": {
"main": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-22.04",
"release-6.0": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-20.04@sha256:adfa0a8fbc6e5cc7ce5e38a5a9406d4fa5c557871204a65f0690478022d6b359",
"release-6.0": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-20.04@sha256:8060adba9c044b1fc751b9671167320c9cc0094d0a45d7b8fedb707c49b764c2",
},
"run_stdlib_test": true,
"run_full_test": false,
Expand Down Expand Up @@ -187,7 +187,7 @@ def main
"main": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-20.04",
# "release-5.9": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-20.04@sha256:0e04dd550557d9f4f773bda55a6ac355c7c9696ea6efc3e59318bd49569aa00e",
"release-5.10": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-20.04@sha256:0e04dd550557d9f4f773bda55a6ac355c7c9696ea6efc3e59318bd49569aa00e",
"release-6.0": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-20.04@sha256:0e04dd550557d9f4f773bda55a6ac355c7c9696ea6efc3e59318bd49569aa00e",
"release-6.0": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-20.04@sha256:2a977060476a0f6f702d59ed0cd4e8506c7c1f1ed48d85a1a684d2d3fb62c297",
},
"run_stdlib_test": false,
"run_full_test": false,
Expand Down
66 changes: 66 additions & 0 deletions schemes/release-6.0/build/build-foundation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash
set -ex
DESTINATION_TOOLCHAIN=$1
LLVM_BIN_DIR=$2
CLANG_BIN_DIR=$3
SWIFT_BIN_DIR=$4
WASI_SYSROOT_PATH=$5
TRIPLE="wasm32-unknown-wasi"

SOURCE_PATH="$(cd "$(dirname $0)/../../../.." && pwd)"
SCHEME_BUILD_PATH="$(cd "$(dirname $0)" && pwd)"
BUILD_SDK_PATH="$SOURCE_PATH/build-sdk"
LIBXML2_PATH="$BUILD_SDK_PATH/libxml2"

FOUNDATION_BUILD="$SOURCE_PATH/build/WebAssembly/foundation-wasi-wasm32"
FOUNDATION_MACROS_BUILD="$SOURCE_PATH/build/WebAssembly/foundation-macros-wasi-wasm32"

swift_extra_flags=""
c_extra_flags=""
if [[ "$TRIPLE" == "wasm32-unknown-wasip1-threads" ]]; then
swift_extra_flags="-Xcc -matomics -Xcc -mbulk-memory -Xcc -mthread-model -Xcc posix -Xcc -pthread -Xcc -ftls-model=local-exec"
c_extra_flags="-mthread-model posix -pthread -ftls-model=local-exec"
fi

cmake -G Ninja \
-D CMAKE_C_COMPILER="$CLANG_BIN_DIR/clang" \
-D CMAKE_CXX_COMPILER="$CLANG_BIN_DIR/clang++" \
-D CMAKE_Swift_COMPILER="$SWIFT_BIN_DIR/swiftc" \
-D BUILD_SHARED_LIBS=ON \
-B "$FOUNDATION_MACROS_BUILD" \
"${SOURCE_PATH}/swift-foundation/Sources/FoundationMacros"

cmake --build "$FOUNDATION_MACROS_BUILD"

cmake -G Ninja \
-D CMAKE_BUILD_TYPE="Release" \
-D CMAKE_SYSROOT="$WASI_SYSROOT_PATH" \
-D CMAKE_Swift_COMPILER="$SWIFT_BIN_DIR/swiftc" \
-D CMAKE_STAGING_PREFIX="$DESTINATION_TOOLCHAIN/usr" \
-D CMAKE_SYSTEM_NAME=WASI \
-D CMAKE_SYSTEM_PROCESSOR=wasm32 \
-D CMAKE_C_COMPILER_TARGET="$TRIPLE" \
-D CMAKE_CXX_COMPILER_TARGET="$TRIPLE" \
-D CMAKE_Swift_COMPILER_TARGET="$TRIPLE" \
-D CMAKE_C_COMPILER="$CLANG_BIN_DIR/clang" \
-D CMAKE_CXX_COMPILER="$CLANG_BIN_DIR/clang++" \
-D CMAKE_AR="$LLVM_BIN_DIR/llvm-ar" \
-D CMAKE_RANLIB="$LLVM_BIN_DIR/llvm-ranlib" \
-D LIBXML2_INCLUDE_DIR="$LIBXML2_PATH/include/libxml2" \
-D LIBXML2_LIBRARY="$LIBXML2_PATH/lib" \
-D BUILD_SHARED_LIBS=OFF \
-D FOUNDATION_BUILD_TOOLS=OFF \
-D CMAKE_Swift_COMPILER_FORCED=ON \
-D CMAKE_C_COMPILER_FORCED=ON \
-D CMAKE_CXX_COMPILER_FORCED=ON \
-D CMAKE_Swift_FLAGS="-sdk $WASI_SYSROOT_PATH -resource-dir $DESTINATION_TOOLCHAIN/usr/lib/swift_static $swift_extra_flags" \
-D CMAKE_C_FLAGS="-resource-dir $DESTINATION_TOOLCHAIN/usr/lib/swift_static/clang -B $LLVM_BIN_DIR $c_extra_flags" \
-D _SwiftCollections_SourceDIR="$SOURCE_PATH/swift-collections" \
-D _SwiftFoundation_SourceDIR="$SOURCE_PATH/swift-foundation" \
-D _SwiftFoundationICU_SourceDIR="$SOURCE_PATH/swift-foundation-icu" \
-D SwiftFoundation_MACRO="$FOUNDATION_MACROS_BUILD/lib" \
-B "$FOUNDATION_BUILD" \
"${SOURCE_PATH}/swift-corelibs-foundation"

cmake --build "$FOUNDATION_BUILD"
cmake --install "$FOUNDATION_BUILD"
3 changes: 2 additions & 1 deletion schemes/release-6.0/build/build-target-toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ build_target_toolchain() {
-D SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING=YES \
-D SWIFT_ENABLE_EXPERIMENTAL_REFLECTION=YES \
-D SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP=YES \
-D SWIFT_ENABLE_SYNCHRONIZATION=YES \
-D SWIFT_PRIMARY_VARIANT_SDK=WASI \
-D SWIFT_PRIMARY_VARIANT_ARCH=wasm32 \
-D SWIFT_SDKS:STRING=WASI \
Expand Down Expand Up @@ -144,7 +145,7 @@ build_target_toolchain() {
"$SWIFT_BIN_DIR"
"$WASI_SYSROOT_PATH"
)
"$TOOLS_BUILD_PATH/build-foundation.sh" "${CORELIBS_ARGS[@]}"
"$SCHEMES_BUILD_PATH/build-foundation.sh" "${CORELIBS_ARGS[@]}"
"$SCHEMES_BUILD_PATH/build-xctest.sh" "${CORELIBS_ARGS[@]}"
}

Expand Down
2 changes: 1 addition & 1 deletion schemes/release-6.0/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"update-checkout-scheme": "release/6.0",
"base-tag": "swift-6.0-DEVELOPMENT-SNAPSHOT-2024-07-19-a",
"base-tag": "swift-6.0-DEVELOPMENT-SNAPSHOT-2024-08-22-a",
"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"],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
From effb33569a926c12dc8e7bae979ac2075c219189 Mon Sep 17 00:00:00 2001
From: Yuta Saito <[email protected]>
Date: Fri, 26 Jul 2024 03:59:24 +0000
Subject: [PATCH] [CMake] Add support for WebAssembly target architectures

To repair the swift-corelibs-foundation build on WebAssembly, we need to
add support for Wasm targets to swift-collections' CMake build system.
---
cmake/modules/SwiftSupport.cmake | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/cmake/modules/SwiftSupport.cmake b/cmake/modules/SwiftSupport.cmake
index 0ce99fb8..21b9d693 100644
--- a/cmake/modules/SwiftSupport.cmake
+++ b/cmake/modules/SwiftSupport.cmake
@@ -45,6 +45,10 @@ function(get_swift_host_arch result_var_name)
set("${result_var_name}" "i686" PARENT_SCOPE)
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686")
set("${result_var_name}" "i686" PARENT_SCOPE)
+ elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "wasm32")
+ set("${result_var_name}" "wasm32" PARENT_SCOPE)
+ elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "wasm64")
+ set("${result_var_name}" "wasm64" PARENT_SCOPE)
else()
message(FATAL_ERROR "Unrecognized architecture on host system: ${CMAKE_SYSTEM_PROCESSOR}")
endif()
--
2.43.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
From 4db45e0b9c75e3a6ac31cf45a06018592af381f5 Mon Sep 17 00:00:00 2001
From: Yuta Saito <[email protected]>
Date: Sat, 30 Mar 2024 10:28:40 +0000
Subject: [PATCH] build: Repair the build on WASI platform

Cherry picked from https://github.com/apple/swift-corelibs-foundation/pull/4934

(cherry picked from commit 51ee6906be0556eb63cd35a16ad4167f69f16a63)
---
Package.swift | 20 ++++++++++++++++++--
Sources/CoreFoundation/CFBundle.c | 8 +++++++-
Sources/CoreFoundation/CFString.c | 2 +-
3 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/Package.swift b/Package.swift
index 6d660388..4949fe4e 100644
--- a/Package.swift
+++ b/Package.swift
@@ -3,6 +3,16 @@

import PackageDescription

+let platformsWithThreads: [Platform] = [
+ .iOS,
+ .macOS,
+ .tvOS,
+ .watchOS,
+ .macCatalyst,
+ .driverKit,
+ .android,
+ .linux,
+]
var dispatchIncludeFlags: [CSetting]
if let environmentPath = Context.environment["DISPATCH_INCLUDE_PATH"] {
dispatchIncludeFlags = [.unsafeFlags([
@@ -31,8 +41,11 @@ let coreFoundationBuildSettings: [CSetting] = [
.define("DEPLOYMENT_ENABLE_LIBDISPATCH"),
.define("DEPLOYMENT_RUNTIME_SWIFT"),
.define("HAVE_STRUCT_TIMESPEC"),
- .define("SWIFT_CORELIBS_FOUNDATION_HAS_THREADS"),
+ .define("SWIFT_CORELIBS_FOUNDATION_HAS_THREADS", .when(platforms: platformsWithThreads)),
.define("_GNU_SOURCE", .when(platforms: [.linux, .android])),
+ .define("_WASI_EMULATED_SIGNAL", .when(platforms: [.wasi])),
+ .define("HAVE_STRLCPY", .when(platforms: [.wasi])),
+ .define("HAVE_STRLCAT", .when(platforms: [.wasi])),
.unsafeFlags([
"-Wno-shorten-64-to-32",
"-Wno-deprecated-declarations",
@@ -61,8 +74,11 @@ let interfaceBuildSettings: [CSetting] = [
.define("CF_BUILDING_CF"),
.define("DEPLOYMENT_ENABLE_LIBDISPATCH"),
.define("HAVE_STRUCT_TIMESPEC"),
- .define("SWIFT_CORELIBS_FOUNDATION_HAS_THREADS"),
+ .define("SWIFT_CORELIBS_FOUNDATION_HAS_THREADS", .when(platforms: platformsWithThreads)),
.define("_GNU_SOURCE", .when(platforms: [.linux, .android])),
+ .define("_WASI_EMULATED_SIGNAL", .when(platforms: [.wasi])),
+ .define("HAVE_STRLCPY", .when(platforms: [.wasi])),
+ .define("HAVE_STRLCAT", .when(platforms: [.wasi])),
.unsafeFlags([
"-Wno-shorten-64-to-32",
"-Wno-deprecated-declarations",
diff --git a/Sources/CoreFoundation/CFBundle.c b/Sources/CoreFoundation/CFBundle.c
index 8026a262..05afe988 100644
--- a/Sources/CoreFoundation/CFBundle.c
+++ b/Sources/CoreFoundation/CFBundle.c
@@ -596,7 +596,13 @@ static CFBundleRef _CFBundleGetBundleWithIdentifier(CFStringRef bundleID, void *

CFBundleRef CFBundleGetBundleWithIdentifier(CFStringRef bundleID) {
// Use the frame that called this as a hint
- return _CFBundleGetBundleWithIdentifier(bundleID, __builtin_return_address(0));
+ void *hint;
+#if TARGET_OS_WASI
+ hint = NULL;
+#else
+ hint = __builtin_frame_address(0);
+#endif
+ return _CFBundleGetBundleWithIdentifier(bundleID, hint);
}

CFBundleRef _CFBundleGetBundleWithIdentifierWithHint(CFStringRef bundleID, void *pointer) {
diff --git a/Sources/CoreFoundation/CFString.c b/Sources/CoreFoundation/CFString.c
index 1de46dac..94a6c86d 100644
--- a/Sources/CoreFoundation/CFString.c
+++ b/Sources/CoreFoundation/CFString.c
@@ -28,7 +28,7 @@
#include "CFRuntime_Internal.h"
#include <assert.h>
#include <_foundation_unicode/uchar.h>
-#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD
+#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_WASI
#include "CFConstantKeys.h"
#include "CFStringLocalizedFormattingInternal.h"
#endif
--
2.43.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
From f8c20b56988da0f649c1645dd4e0ea18af739b95 Mon Sep 17 00:00:00 2001
From: Max Desiatov <[email protected]>
Date: Mon, 5 Aug 2024 20:28:46 +0100
Subject: [PATCH] Reflect `Package.swift` WASI changes in `CMakeLists.txt`

---
CMakeLists.txt | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7f290d16..1fbdee6a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -146,7 +146,6 @@ list(APPEND _Foundation_common_build_flags
"-DCF_BUILDING_CF"
"-DDEPLOYMENT_ENABLE_LIBDISPATCH"
"-DHAVE_STRUCT_TIMESPEC"
- "-DSWIFT_CORELIBS_FOUNDATION_HAS_THREADS"
"-Wno-shorten-64-to-32"
"-Wno-deprecated-declarations"
"-Wno-unreachable-code"
@@ -158,6 +157,18 @@ list(APPEND _Foundation_common_build_flags
"-Wno-switch"
"-fblocks")

+if(CMAKE_SYSTEM_NAME STREQUAL "WASI")
+ list(APPEND _Foundation_common_build_flags
+ "-D_WASI_EMULATED_SIGNAL"
+ "-DHAVE_STRLCPY"
+ "-DHAVE_STRLCAT"
+ )
+else()
+ list(APPEND _Foundation_common_build_flags
+ "-DSWIFT_CORELIBS_FOUNDATION_HAS_THREADS"
+ )
+endif()
+
if(NOT "${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
list(APPEND _Foundation_common_build_flags
"-fconstant-cfstrings"
@@ -185,10 +196,21 @@ set(_Foundation_swift_build_flags)
list(APPEND _Foundation_swift_build_flags
"-swift-version 6"
"-DDEPLOYMENT_RUNTIME_SWIFT"
- "-DSWIFT_CORELIBS_FOUNDATION_HAS_THREADS"
"-Xfrontend"
"-require-explicit-sendable")

+if(CMAKE_SYSTEM_NAME STREQUAL "WASI")
+ list(APPEND _Foundation_swift_build_flags
+ "-D_WASI_EMULATED_SIGNAL"
+ "-DHAVE_STRLCPY"
+ "-DHAVE_STRLCAT"
+ )
+else()
+ list(APPEND _Foundation_swift_build_flags
+ "-DSWIFT_CORELIBS_FOUNDATION_HAS_THREADS"
+ )
+endif()
+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android")
list(APPEND _Foundation_common_build_flags
"-D_GNU_SOURCE")
--
2.43.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From 0c954d9de286e15204240722d717e1928e165cbb Mon Sep 17 00:00:00 2001
From: Max Desiatov <[email protected]>
Date: Mon, 5 Aug 2024 20:16:22 +0100
Subject: [PATCH] Add `.windows` to `platformsWithThreads` in `Package.swift`

(cherry picked from commit bc0dd484adbabdb978e68cf6905e3b44ca5117bd)
---
Package.swift | 1 +
1 file changed, 1 insertion(+)

diff --git a/Package.swift b/Package.swift
index 4949fe4e..aca50e80 100644
--- a/Package.swift
+++ b/Package.swift
@@ -12,6 +12,7 @@ let platformsWithThreads: [Platform] = [
.driverKit,
.android,
.linux,
+ .windows,
]
var dispatchIncludeFlags: [CSetting]
if let environmentPath = Context.environment["DISPATCH_INCLUDE_PATH"] {
--
2.43.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
From 278d6ffde7788d16455f5dbcef9400b75f849adf Mon Sep 17 00:00:00 2001
From: Yuta Saito <[email protected]>
Date: Wed, 7 Aug 2024 05:10:42 +0000
Subject: [PATCH] [CMake] Use LIBXML2_INCLUDE_DIR instead of hardcoding
/usr/include/libxml2

`find_package(LibXml2 REQUIRED)` sets `LIBXML2_INCLUDE_DIR` to the correct
include directory for the libxml2 headers. Use this variable instead of
hardcoding `/usr/include/libxml2`. This allows the build to work with
custom libxml2 builds on WASI.
---
Sources/_CFXMLInterface/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Sources/_CFXMLInterface/CMakeLists.txt b/Sources/_CFXMLInterface/CMakeLists.txt
index d6e63a3f..d550a520 100644
--- a/Sources/_CFXMLInterface/CMakeLists.txt
+++ b/Sources/_CFXMLInterface/CMakeLists.txt
@@ -20,7 +20,7 @@ target_include_directories(_CFXMLInterface
../CoreFoundation/include
PRIVATE
../CoreFoundation/internalInclude
- /usr/include/libxml2/)
+ ${LIBXML2_INCLUDE_DIR})

target_compile_options(_CFXMLInterface INTERFACE
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xcc -fmodule-map-file=${CMAKE_CURRENT_SOURCE_DIR}/../CoreFoundation/include/module.modulemap>"
--
2.43.2

Loading
Loading