Giter Site home page Giter Site logo

swift's Introduction

SwiftWasm

Compile your Swift code to WebAssembly

Build Toolchain Discord

This is the distribution repository for SwiftWasm toolchain and SDK. Please refer to the SwiftWasm book to get started, and to the awesome-swiftwasm list for more links in the SwiftWasm ecosystem.

If you'd like to participate in the growing SwiftWasm community, you're very welcome to join our Discord server.

The actual patches to the toolchain are maintained in the swiftwasm/swiftwasm-build repository. This repository is used only for distribution of the toolchain.

If you'd like to track the status of our builds, please refer to our GitHub Actions page.

Sponsoring

Become a gold or platinum sponsor and contact maintainers to add your logo on our README on Github with a link to your site.

swift's People

Contributors

dependabot[bot] avatar kateinoigakukun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swift's Issues

SwiftPM on macOS produces "error: manifest parse error(s)"

I think this exact issue will be fixed in tonight's snapshot, at least not able to reproduce it locally anymore thanks to c7557be. Nevertheless, there's a different issue with SwiftPM on macOS, which prevents it from working properly. I think it has something to be with how libPackageDescription.dylibthat belongs to SwiftPM is compiled. If you completely clean your .build directory (for any package, not just Tokamak) you get this error:

 error: manifest parse error(s):
<unknown>

The breakage happens when the Package.swift manifest path is compiled, you can infer by passing the -v flag to swift build and checking where exactly the error occurs:

/Users/maxd/.swiftenv/versions/wasm-DEVELOPMENT-SNAPSHOT-2020-06-13-a/usr/bin/swiftc -L /Users/maxd/.swiftenv/versions/wasm-DEVELOPMENT-SNAPSHOT-2020-06-13-a/usr/lib/swift/pm/4_2 -lPackageDescription -Xlinker -rpath -Xlinker /Users/maxd/.swiftenv/versions/wasm-DEVELOPMENT-SNAPSHOT-2020-06-13-a/usr/lib/swift/pm/4_2 -target x86_64-apple-macosx10.15 -swift-version 5 -I /Users/maxd/.swiftenv/versions/wasm-DEVELOPMENT-SNAPSHOT-2020-06-13-a/usr/lib/swift/pm/4_2 -sdk /Applications/Xcode-11.5.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -package-description-version 5.2.0 /Users/maxd/Documents/Tokamak/Package.swift -o /var/folders/r4/5d00qxmn0rz1v00hb9lv3fdr0000gn/T/TemporaryDirectory.MvuBHz/tokamak-manifest
/var/folders/r4/5d00qxmn0rz1v00hb9lv3fdr0000gn/T/TemporaryDirectory.MvuBHz/tokamak-manifest -fileno 7 sandbox-exec -p '(version 1)
(deny default)
(import "system.sb")
(allow file-read*)
(allow process*)
(allow sysctl*)
(allow file-write*
    (regex #"^/private/var/tmp/org\.llvm\.clang.*")
    (regex #"^/var/folders/r4/5d00qxmn0rz1v00hb9lv3fdr0000gn/T/org\.llvm\.clang.*")
    (regex #"^/private/var/folders/r4/5d00qxmn0rz1v00hb9lv3fdr0000gn/T/org\.llvm\.clang.*")
    (regex #"^/private/var/folders/r4/5d00qxmn0rz1v00hb9lv3fdr0000gn/C/org\.llvm\.clang.*")
    (subpath "/Users/maxd/Documents/Tokamak/.build")
)
'
/Users/maxd/Documents/Tokamak: error: manifest parse error(s):
<unknown>

Note that I'm using 2020-06-13-a snapshot in the above output, that's the oldest snapshot where the issue is reproduced. 2020-06-12-a snapshot is working fine. I've also tried to compile the manifest file separately by 2020-06-13-a and 2020-06-12-a versions of the compiler, but using the same version of the libPackageDescription.dylib module from either 2020-06-13-a or 2020-06-12-a. Testing these different combinations, I think that the issues is caused by libPackageDescription.dylib that became broken in 2020-06-13-a and is still broken in the latest snapshots for both swiftwasm-release/5.3 and swiftwasm branches. Looking at file sizes, we can also see that something happened to the library that significantly changed its binary size starting with the 2020-06-13-a snapshot:

892K	/Users/maxd/.swiftenv/versions/wasm-DEVELOPMENT-SNAPSHOT-2020-06-11-a/usr/lib/swift/pm/4_2/libPackageDescription.dylib
892K	/Users/maxd/.swiftenv/versions/wasm-DEVELOPMENT-SNAPSHOT-2020-06-12-a/usr/lib/swift/pm/4_2/libPackageDescription.dylib
752K	/Users/maxd/.swiftenv/versions/wasm-DEVELOPMENT-SNAPSHOT-2020-06-13-a/usr/lib/swift/pm/4_2/libPackageDescription.dylib
756K	/Users/maxd/.swiftenv/versions/swift-wasm-5.3-SNAPSHOT-2020-07-03-a/usr/lib/swift/pm/4_2/libPackageDescription.dylib
752K	/Users/maxd/.swiftenv/versions/wasm-DEVELOPMENT-SNAPSHOT-2020-06-22-a/usr/lib/swift/pm/4_2/libPackageDescription.dylib

There don't seem to be any changes between 2020-06-12-a and 2020-06-13-a in the SwiftPM itself, I think something changed in the compiler that made it miscompile the library.

I'm going to research this further, need to investigate what exactly is different between those two compiler versions and how to fix it.

Originally posted by @MaxDesiatov in #1362 (comment)

SwiftPM regression starting with DEVELOPMENT-SNAPSHOT-2020-04-10-a

Seems to me like a problem with SwiftPM:

error: manifest parse error(s):
<unknown>:0: error: compiled module was created by an older version of the compiler; 
rebuild 'Swift' and try again: .swiftenv/versions/wasm-DEVELOPMENT-SNAPSHOT-2020-04-10-a/usr/lib/swift/macosx/Swift.swiftmodule/x86_64.swiftmodule

I've added a pull configuration to our SwiftPM fork, hoping it will be fixed in the next snapshot

Set up nightly distribution for 5.3 release

Now that release/5.3 branch has been created upstream, I've set up corresponding release/5.3 and swiftwasm-release/5.3 branches, which hopefully will be more stable and more suitable for wider use. There is no nighly distribution for the swiftwasm-release/5.3 branch currently, it would be great to have it so that we could refer to it from the swiftwasm.org landing page directly.

Fix `indirect call type mismatch`

Now, most of test cases that depends on StdlibUnittest fails due to same error.

Environment: wasmtime 0.8.0

Caused by:
    0: Instantiation failed during setup
    1: Trap occurred while invoking start function: wasm trap: indirect call type mismatch, source location: @c0925

To debug this problem, I'm developing a debugger of wasm at first.
This crash may be related with #6 ๐Ÿค”

Could NOT find ICU trying to build the project from source

Running into the following issue trying to invoke a modified version of the vvv.sh script:

CMake Error at /usr/local/Cellar/cmake/3.13.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find ICU (missing: ICU_UC_INCLUDE_DIRS ICU_UC_LIBRARIES
  ICU_I18N_INCLUDE_DIRS ICU_I18N_LIBRARIES)
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.13.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  cmake/modules/FindICU.cmake:39 (find_package_handle_standard_args)
  lib/Driver/CMakeLists.txt:40 (find_package)

Here's my modified script:

utils/build-script --release-debuginfo --wasm \
	--llvm-targets-to-build "X86;ARM;AArch64;PowerPC;SystemZ;WebAssembly" \
	--llvm-max-parallel-lto-link-jobs 1 --swift-tools-max-parallel-lto-link-jobs 1 \
	--wasm-wasi-sdk "/Users/kverrier/repos/wasi-sdk" \
	--wasm-icu-uc "todo" \
	--wasm-icu-uc-include "/Users/kverrier/repos/icu4c-wasi/icu/source/common/" \
	--wasm-icu-i18n "todo" \
	--wasm-icu-i18n-include "todo" \
	--wasm-icu-data "todo" \
	--build-swift-static-stdlib \
	"$@"

_note the --wasm-icu-uc-include is pointing to a clone of https://github.com/swiftwasm/icu4c-wasi.

I've been doing a lot of tinkering between failing builds so maybe I need to do a fresh rebuild... Let me know if you have any insights ๐Ÿ˜„.

ARKit

Is it possible to access ARKit using WASM? If it is, how do I get started? As I understand, there's no instruction yet?

Supply libIndexStore.dylib in the latest snapshots

Currently libIndexStore.dylib is not built with the host toolchain. An attempt to resolve that is available in #1456, but there still issues with header paths.

This dynamic library is required to make the --enable-test-discovery flag work when running swift test, even with packages that target WebAssembly.

Releasing reference whose refcount is already zero

This happens in NavigationView here at this line:

}.environment(\.navigationDestination, subject.$destination)
[Error] Assertion failed: 
	(anonymous function) (dev.js:26)
	(anonymous function) (index.esm.js:168:190)
	forEach
	(anonymous function) (index.esm.js:168:131)
	(anonymous function) (index.esm.js:155:193)
	wasm-stub
	<?>.wasm-function[writev]
	<?>.wasm-function[__stdio_write]
	<?>.wasm-function[__fwritex]
	<?>.wasm-function[printf_core]
	<?>.wasm-function[vfprintf]
	<?>.wasm-function[fprintf]
	<?>.wasm-function[__assert_fail]
	<?>.wasm-function[bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrement<(swift::PerformDeinit)1>(unsigned int)]
	<?>.wasm-function[swift_release]
	<?>.wasm-function[$s11TokamakCore21_ViewModifier_ContentVyAA022_EnvironmentKeyWritingD0VyAA7BindingVyAA03AnyC0VGSgGGWOh]
	<?>.wasm-function[$s11TokamakCore14NavigationViewV0A3DOME12deferredBodyAA03AnyD0VvgAA01_cD5ProxyV4bodyQrvpQOyx_Qo_yXEfU_]
	<?>.wasm-function[$s11TokamakCore14NavigationViewV0A3DOME12deferredBodyAA03AnyD0VvgAA01_cD5ProxyV4bodyQrvpQOyx_Qo_yXEfU_TA]
	<?>.wasm-function[$s10TokamakDOM4HTMLV__9listeners7contentACyxGSS_SDyS2SGSDySSy13JavaScriptKit11JSObjectRefCcGxyXEtcfC]
	<?>.wasm-function[$s11TokamakCore14NavigationViewV0A3DOME12deferredBodyAA03AnyD0Vvg]
	<?>.wasm-function[$s11TokamakCore14NavigationViewVyxGAA0D18DeferredToRenderer0A3DOMAaEP12deferredBodyAA03AnyD0VvgTW]
	<?>.wasm-function[$s11TokamakCore7AnyViewVyACxcAA0D0RzlufcACypcfU_]
	<?>.wasm-function[$s11TokamakCore15StackReconcilerC6render13compositeViewQrAA016MountedCompositeG0CyxG_tF]
	<?>.wasm-function[$s11TokamakCore20MountedCompositeViewC5mount4withyAA15StackReconcilerCyxG_tF]
	<?>.wasm-function[$s11TokamakCore15StackReconcilerC4view6target8renderer9schedulerACyxGqd___10TargetTypeQzxyyycctcAA4ViewRd__lufc]
	<?>.wasm-function[$s11TokamakCore15StackReconcilerC4view6target8renderer9schedulerACyxGqd___10TargetTypeQzxyyycctcAA4ViewRd__lufC]
	<?>.wasm-function[$s10TokamakDOM11DOMRendererCyACx_13JavaScriptKit11JSObjectRefCtc0A4Core4ViewRzlufc]
	<?>.wasm-function[$s10TokamakDOM11DOMRendererCyACx_13JavaScriptKit11JSObjectRefCtc0A4Core4ViewRzlufC]
	<?>.wasm-function[main]
	<?>.wasm-function[__original_main]
	<?>.wasm-function[_start]
	wasm-stub
	_start
	(anonymous function) (index.esm.js:182:184)
	(anonymous function) (dev.js:64)
	asyncFunctionResume
	(anonymous function)
	promiseReactionJobWithoutPromise
	promiseReactionJob
[Error] getStrongExtraRefCount() >= dec && "releasing reference whose refcount is already zero"
	(anonymous function) (dev.js:26)
	(anonymous function) (index.esm.js:168:190)
	forEach
	(anonymous function) (index.esm.js:168:131)
	(anonymous function) (index.esm.js:155:193)
	wasm-stub
	<?>.wasm-function[writev]
	<?>.wasm-function[__stdio_write]
	<?>.wasm-function[__fwritex]
	<?>.wasm-function[printf_core]
	<?>.wasm-function[vfprintf]
	<?>.wasm-function[fprintf]
	<?>.wasm-function[__assert_fail]
	<?>.wasm-function[bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrement<(swift::PerformDeinit)1>(unsigned int)]
	<?>.wasm-function[swift_release]
	<?>.wasm-function[$s11TokamakCore21_ViewModifier_ContentVyAA022_EnvironmentKeyWritingD0VyAA7BindingVyAA03AnyC0VGSgGGWOh]
	<?>.wasm-function[$s11TokamakCore14NavigationViewV0A3DOME12deferredBodyAA03AnyD0VvgAA01_cD5ProxyV4bodyQrvpQOyx_Qo_yXEfU_]
	<?>.wasm-function[$s11TokamakCore14NavigationViewV0A3DOME12deferredBodyAA03AnyD0VvgAA01_cD5ProxyV4bodyQrvpQOyx_Qo_yXEfU_TA]
	<?>.wasm-function[$s10TokamakDOM4HTMLV__9listeners7contentACyxGSS_SDyS2SGSDySSy13JavaScriptKit11JSObjectRefCcGxyXEtcfC]
	<?>.wasm-function[$s11TokamakCore14NavigationViewV0A3DOME12deferredBodyAA03AnyD0Vvg]
	<?>.wasm-function[$s11TokamakCore14NavigationViewVyxGAA0D18DeferredToRenderer0A3DOMAaEP12deferredBodyAA03AnyD0VvgTW]
	<?>.wasm-function[$s11TokamakCore7AnyViewVyACxcAA0D0RzlufcACypcfU_]
	<?>.wasm-function[$s11TokamakCore15StackReconcilerC6render13compositeViewQrAA016MountedCompositeG0CyxG_tF]
	<?>.wasm-function[$s11TokamakCore20MountedCompositeViewC5mount4withyAA15StackReconcilerCyxG_tF]
	<?>.wasm-function[$s11TokamakCore15StackReconcilerC4view6target8renderer9schedulerACyxGqd___10TargetTypeQzxyyycctcAA4ViewRd__lufc]
	<?>.wasm-function[$s11TokamakCore15StackReconcilerC4view6target8renderer9schedulerACyxGqd___10TargetTypeQzxyyycctcAA4ViewRd__lufC]
	<?>.wasm-function[$s10TokamakDOM11DOMRendererCyACx_13JavaScriptKit11JSObjectRefCtc0A4Core4ViewRzlufc]
	<?>.wasm-function[$s10TokamakDOM11DOMRendererCyACx_13JavaScriptKit11JSObjectRefCtc0A4Core4ViewRzlufC]
	<?>.wasm-function[main]
	<?>.wasm-function[__original_main]
	<?>.wasm-function[_start]
	wasm-stub
	_start
	(anonymous function) (index.esm.js:182:184)
	(anonymous function) (dev.js:64)
	asyncFunctionResume
	(anonymous function)
	promiseReactionJobWithoutPromise
	promiseReactionJob
[Error]  (
	(anonymous function) (dev.js:26)
	(anonymous function) (index.esm.js:168:190)
	forEach
	(anonymous function) (index.esm.js:168:131)
	(anonymous function) (index.esm.js:155:193)
	wasm-stub
	<?>.wasm-function[writev]
	<?>.wasm-function[__stdio_write]
	<?>.wasm-function[__fwritex]
	<?>.wasm-function[printf_core]
	<?>.wasm-function[vfprintf]
	<?>.wasm-function[fprintf]
	<?>.wasm-function[__assert_fail]
	<?>.wasm-function[bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrement<(swift::PerformDeinit)1>(unsigned int)]
	<?>.wasm-function[swift_release]
	<?>.wasm-function[$s11TokamakCore21_ViewModifier_ContentVyAA022_EnvironmentKeyWritingD0VyAA7BindingVyAA03AnyC0VGSgGGWOh]
	<?>.wasm-function[$s11TokamakCore14NavigationViewV0A3DOME12deferredBodyAA03AnyD0VvgAA01_cD5ProxyV4bodyQrvpQOyx_Qo_yXEfU_]
	<?>.wasm-function[$s11TokamakCore14NavigationViewV0A3DOME12deferredBodyAA03AnyD0VvgAA01_cD5ProxyV4bodyQrvpQOyx_Qo_yXEfU_TA]
	<?>.wasm-function[$s10TokamakDOM4HTMLV__9listeners7contentACyxGSS_SDyS2SGSDySSy13JavaScriptKit11JSObjectRefCcGxyXEtcfC]
	<?>.wasm-function[$s11TokamakCore14NavigationViewV0A3DOME12deferredBodyAA03AnyD0Vvg]
	<?>.wasm-function[$s11TokamakCore14NavigationViewVyxGAA0D18DeferredToRenderer0A3DOMAaEP12deferredBodyAA03AnyD0VvgTW]
	<?>.wasm-function[$s11TokamakCore7AnyViewVyACxcAA0D0RzlufcACypcfU_]
	<?>.wasm-function[$s11TokamakCore15StackReconcilerC6render13compositeViewQrAA016MountedCompositeG0CyxG_tF]
	<?>.wasm-function[$s11TokamakCore20MountedCompositeViewC5mount4withyAA15StackReconcilerCyxG_tF]
	<?>.wasm-function[$s11TokamakCore15StackReconcilerC4view6target8renderer9schedulerACyxGqd___10TargetTypeQzxyyycctcAA4ViewRd__lufc]
	<?>.wasm-function[$s11TokamakCore15StackReconcilerC4view6target8renderer9schedulerACyxGqd___10TargetTypeQzxyyycctcAA4ViewRd__lufC]
	<?>.wasm-function[$s10TokamakDOM11DOMRendererCyACx_13JavaScriptKit11JSObjectRefCtc0A4Core4ViewRzlufc]
	<?>.wasm-function[$s10TokamakDOM11DOMRendererCyACx_13JavaScriptKit11JSObjectRefCtc0A4Core4ViewRzlufC]
	<?>.wasm-function[main]
	<?>.wasm-function[__original_main]
	<?>.wasm-function[_start]
	wasm-stub
	_start
	(anonymous function) (index.esm.js:182:184)
	(anonymous function) (dev.js:64)
	asyncFunctionResume
	(anonymous function)
	promiseReactionJobWithoutPromise
	promiseReactionJob
[Error] /Users/runner/runners/2.263.0/work/swift/swift/include/swift/Runtime/../../../stdlib/public/SwiftShims/RefCount.h
	(anonymous function) (dev.js:26)
	(anonymous function) (index.esm.js:168:190)
	forEach
	(anonymous function) (index.esm.js:168:131)
	(anonymous function) (index.esm.js:155:193)
	wasm-stub
	<?>.wasm-function[writev]
	<?>.wasm-function[__stdio_write]
	<?>.wasm-function[__fwritex]
	<?>.wasm-function[printf_core]
	<?>.wasm-function[vfprintf]
	<?>.wasm-function[fprintf]
	<?>.wasm-function[__assert_fail]
	<?>.wasm-function[bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrement<(swift::PerformDeinit)1>(unsigned int)]
	<?>.wasm-function[swift_release]
	<?>.wasm-function[$s11TokamakCore21_ViewModifier_ContentVyAA022_EnvironmentKeyWritingD0VyAA7BindingVyAA03AnyC0VGSgGGWOh]
	<?>.wasm-function[$s11TokamakCore14NavigationViewV0A3DOME12deferredBodyAA03AnyD0VvgAA01_cD5ProxyV4bodyQrvpQOyx_Qo_yXEfU_]
	<?>.wasm-function[$s11TokamakCore14NavigationViewV0A3DOME12deferredBodyAA03AnyD0VvgAA01_cD5ProxyV4bodyQrvpQOyx_Qo_yXEfU_TA]
	<?>.wasm-function[$s10TokamakDOM4HTMLV__9listeners7contentACyxGSS_SDyS2SGSDySSy13JavaScriptKit11JSObjectRefCcGxyXEtcfC]
	<?>.wasm-function[$s11TokamakCore14NavigationViewV0A3DOME12deferredBodyAA03AnyD0Vvg]
	<?>.wasm-function[$s11TokamakCore14NavigationViewVyxGAA0D18DeferredToRenderer0A3DOMAaEP12deferredBodyAA03AnyD0VvgTW]
	<?>.wasm-function[$s11TokamakCore7AnyViewVyACxcAA0D0RzlufcACypcfU_]
	<?>.wasm-function[$s11TokamakCore15StackReconcilerC6render13compositeViewQrAA016MountedCompositeG0CyxG_tF]
	<?>.wasm-function[$s11TokamakCore20MountedCompositeViewC5mount4withyAA15StackReconcilerCyxG_tF]
	<?>.wasm-function[$s11TokamakCore15StackReconcilerC4view6target8renderer9schedulerACyxGqd___10TargetTypeQzxyyycctcAA4ViewRd__lufc]
	<?>.wasm-function[$s11TokamakCore15StackReconcilerC4view6target8renderer9schedulerACyxGqd___10TargetTypeQzxyyycctcAA4ViewRd__lufC]
	<?>.wasm-function[$s10TokamakDOM11DOMRendererCyACx_13JavaScriptKit11JSObjectRefCtc0A4Core4ViewRzlufc]
	<?>.wasm-function[$s10TokamakDOM11DOMRendererCyACx_13JavaScriptKit11JSObjectRefCtc0A4Core4ViewRzlufC]
	<?>.wasm-function[main]
	<?>.wasm-function[__original_main]
	<?>.wasm-function[_start]
	wasm-stub
	_start
	(anonymous function) (index.esm.js:182:184)
	(anonymous function) (dev.js:64)
	asyncFunctionResume
	(anonymous function)
	promiseReactionJobWithoutPromise
	promiseReactionJob
[Error] : decrementStrongExtraRefCount: 567)

	(anonymous function) (dev.js:26)
	(anonymous function) (index.esm.js:168:190)
	forEach
	(anonymous function) (index.esm.js:168:131)
	(anonymous function) (index.esm.js:155:193)
	wasm-stub
	<?>.wasm-function[writev]
	<?>.wasm-function[__stdio_write]
	<?>.wasm-function[vfprintf]
	<?>.wasm-function[fprintf]
	<?>.wasm-function[__assert_fail]
	<?>.wasm-function[bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrement<(swift::PerformDeinit)1>(unsigned int)]
	<?>.wasm-function[swift_release]
	<?>.wasm-function[$s11TokamakCore21_ViewModifier_ContentVyAA022_EnvironmentKeyWritingD0VyAA7BindingVyAA03AnyC0VGSgGGWOh]
	<?>.wasm-function[$s11TokamakCore14NavigationViewV0A3DOME12deferredBodyAA03AnyD0VvgAA01_cD5ProxyV4bodyQrvpQOyx_Qo_yXEfU_]
	<?>.wasm-function[$s11TokamakCore14NavigationViewV0A3DOME12deferredBodyAA03AnyD0VvgAA01_cD5ProxyV4bodyQrvpQOyx_Qo_yXEfU_TA]
	<?>.wasm-function[$s10TokamakDOM4HTMLV__9listeners7contentACyxGSS_SDyS2SGSDySSy13JavaScriptKit11JSObjectRefCcGxyXEtcfC]
	<?>.wasm-function[$s11TokamakCore14NavigationViewV0A3DOME12deferredBodyAA03AnyD0Vvg]
	<?>.wasm-function[$s11TokamakCore14NavigationViewVyxGAA0D18DeferredToRenderer0A3DOMAaEP12deferredBodyAA03AnyD0VvgTW]
	<?>.wasm-function[$s11TokamakCore7AnyViewVyACxcAA0D0RzlufcACypcfU_]
	<?>.wasm-function[$s11TokamakCore15StackReconcilerC6render13compositeViewQrAA016MountedCompositeG0CyxG_tF]
	<?>.wasm-function[$s11TokamakCore20MountedCompositeViewC5mount4withyAA15StackReconcilerCyxG_tF]
	<?>.wasm-function[$s11TokamakCore15StackReconcilerC4view6target8renderer9schedulerACyxGqd___10TargetTypeQzxyyycctcAA4ViewRd__lufc]
	<?>.wasm-function[$s11TokamakCore15StackReconcilerC4view6target8renderer9schedulerACyxGqd___10TargetTypeQzxyyycctcAA4ViewRd__lufC]
	<?>.wasm-function[$s10TokamakDOM11DOMRendererCyACx_13JavaScriptKit11JSObjectRefCtc0A4Core4ViewRzlufc]
	<?>.wasm-function[$s10TokamakDOM11DOMRendererCyACx_13JavaScriptKit11JSObjectRefCtc0A4Core4ViewRzlufC]
	<?>.wasm-function[main]
	<?>.wasm-function[__original_main]
	<?>.wasm-function[_start]
	wasm-stub
	_start
	(anonymous function) (index.esm.js:182:184)
	(anonymous function) (dev.js:64)
	asyncFunctionResume
	(anonymous function)
	promiseReactionJobWithoutPromise
	promiseReactionJob
[Error] Unhandled Promise Rejection: RuntimeError: Unreachable code should not be executed (evaluating 'a._start()')
	<?>.wasm-function[abort]
	<?>.wasm-function[__assert_fail]
	<?>.wasm-function[bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrement<(swift::PerformDeinit)1>(unsigned int)]
	<?>.wasm-function[swift_release]
	<?>.wasm-function[$s11TokamakCore21_ViewModifier_ContentVyAA022_EnvironmentKeyWritingD0VyAA7BindingVyAA03AnyC0VGSgGGWOh]
	<?>.wasm-function[$s11TokamakCore14NavigationViewV0A3DOME12deferredBodyAA03AnyD0VvgAA01_cD5ProxyV4bodyQrvpQOyx_Qo_yXEfU_]
	<?>.wasm-function[$s11TokamakCore14NavigationViewV0A3DOME12deferredBodyAA03AnyD0VvgAA01_cD5ProxyV4bodyQrvpQOyx_Qo_yXEfU_TA]
	<?>.wasm-function[$s10TokamakDOM4HTMLV__9listeners7contentACyxGSS_SDyS2SGSDySSy13JavaScriptKit11JSObjectRefCcGxyXEtcfC]
	<?>.wasm-function[$s11TokamakCore14NavigationViewV0A3DOME12deferredBodyAA03AnyD0Vvg]
	<?>.wasm-function[$s11TokamakCore14NavigationViewVyxGAA0D18DeferredToRenderer0A3DOMAaEP12deferredBodyAA03AnyD0VvgTW]
	<?>.wasm-function[$s11TokamakCore7AnyViewVyACxcAA0D0RzlufcACypcfU_]
	<?>.wasm-function[$s11TokamakCore15StackReconcilerC6render13compositeViewQrAA016MountedCompositeG0CyxG_tF]
	<?>.wasm-function[$s11TokamakCore20MountedCompositeViewC5mount4withyAA15StackReconcilerCyxG_tF]
	<?>.wasm-function[$s11TokamakCore15StackReconcilerC4view6target8renderer9schedulerACyxGqd___10TargetTypeQzxyyycctcAA4ViewRd__lufc]
	<?>.wasm-function[$s11TokamakCore15StackReconcilerC4view6target8renderer9schedulerACyxGqd___10TargetTypeQzxyyycctcAA4ViewRd__lufC]
	<?>.wasm-function[$s10TokamakDOM11DOMRendererCyACx_13JavaScriptKit11JSObjectRefCtc0A4Core4ViewRzlufc]
	<?>.wasm-function[$s10TokamakDOM11DOMRendererCyACx_13JavaScriptKit11JSObjectRefCtc0A4Core4ViewRzlufC]
	<?>.wasm-function[main]
	<?>.wasm-function[__original_main]
	<?>.wasm-function[_start]
	wasm-stub
	_start
	(anonymous function) (index.esm.js:182:184)
	(anonymous function) (dev.js:64)
	asyncFunctionResume
	(anonymous function)
	promiseReactionJobWithoutPromise
	promiseReactionJob

Compiled module was created by a newer version of the compiler

With the Tokamak demo, a clean .build/wasm32-unknown-wasi directory, and .swift-version specified as wasm-5.3-SNAPSHOT-2020-07-02-a, I get this error:

$ carton dev --product TokamakDemo
Polyfill integrity verified: /Users/jed/.carton/static/dev.js
Inferring basic settings...
- swift executable: /Users/jed/.carton/sdk/wasm-5.3-SNAPSHOT-2020-07-02-a/usr/bin/swift
Swift version 5.3-dev (LLVM 52273b3a73, Swift a970a7362c)
Target: x86_64-apple-darwin19.5.0
Parsing package manifest: /Users/jed/.carton/sdk/wasm-5.3-SNAPSHOT-2020-07-02-a/usr/bin/swift package dump-package
Error: Process failed with non-zero exit status and following error output:
/Users/jed/Documents/github-clones/Forks/Tokamak: error: manifest parse error(s):
<unknown>:0: error: compiled module was created by a newer version of the compiler: /Users/jed/.carton/sdk/wasm-5.3-SNAPSHOT-2020-07-02-a/usr/lib/swift/macosx/Swift.swiftmodule/x86_64-apple-macos.swiftmodule

Re-enable the test suite

Currently the test suite is completely disabled, it needs to be re-enabled and failing tests should be investigated and fixed.

symbol(s) not found for architecture x86_64

With the Tokamak demo, a clean .build/wasm32-unknown-wasi directory, and .swift-version specified as wasm-DEVELOPMENT-SNAPSHOT-2020-07-02-a, I get this error:

$ carton dev --product TokamakDemo
Polyfill integrity verified: /Users/jed/.carton/static/dev.js
Inferring basic settings...
- swift executable: /Users/jed/.carton/sdk/wasm-DEVELOPMENT-SNAPSHOT-2020-07-02-a/usr/bin/swift
Swift version 5.3-dev (LLVM c5b1848323200a8, Swift 66efa1272c2973b)
Target: x86_64-apple-darwin19.5.0
Parsing package manifest: /Users/jed/.carton/sdk/wasm-DEVELOPMENT-SNAPSHOT-2020-07-02-a/usr/bin/swift package dump-package
Error: Process failed with non-zero exit status and following error output:
/Users/jed/Documents/github-clones/Forks/Tokamak: error: manifest parse error(s):
Undefined symbols for architecture x86_64:
  "_$s18PackageDescription17SupportedPlatformV12MacOSVersionV6v10_15AEvau", referenced from:
      _main in Package-98b7ab.o
ld: symbol(s) not found for architecture x86_64
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)

Linker warnings when building with the new 5.3 toolchain

I'm receiving a lot of warnings such as these at the linking stage:

wasm-ld: warning: unexpected existing value for R_WASM_MEMORY_ADDR_SLEB: existing=72140 expected=72236
wasm-ld: warning: unexpected existing value for R_WASM_MEMORY_ADDR_SLEB: existing=65108 expected=65136
wasm-ld: warning: unexpected existing value for R_WASM_MEMORY_ADDR_SLEB: existing=65108 expected=65152
wasm-ld: warning: unexpected existing value for R_WASM_MEMORY_ADDR_SLEB: existing=65108 expected=65136
wasm-ld: warning: unexpected existing value for R_WASM_MEMORY_ADDR_SLEB: existing=65108 expected=65144
wasm-ld: warning: unexpected existing value for R_WASM_MEMORY_ADDR_SLEB: existing=65108 expected=65136
wasm-ld: warning: unexpected existing value for R_WASM_MEMORY_ADDR_SLEB: existing=65108 expected=65144
wasm-ld: warning: unexpected existing value for R_WASM_MEMORY_ADDR_SLEB: existing=65108 expected=65136

I'm using the wasm-5.3-SNAPSHOT-2020-09-23-a snapshot. Things seem to be working, but I'm not sure what are the implications of this warning.

Add WASI module to use instead of Glibc

Since glibc and musl behave slightly differently, we wouldn't want our WASI users to type import Glibc believing they are actually getting glibc behaviour. Makes much more sense to implement a new Musl module that can be imported and used accordingly on WASI. Linux could benefit from this as well.

I'm currently trying to implement this in my swift-alpine repository, but any help and feedback here on possible different approaches is welcome as usual.

This should unblock apple#29871.

Include XCTest in the distribution archive

I'm able to build XCTest outside of the toolchain build process, this generates the supporting .swiftmodule, .swiftdoc etc files. The problem is that there's no static archive available for XCTest (libXCTest.a) to be linked as a system framework as a result of a swift build run in our fork of XCTest. One option is to make it buildable as a part of build-script (with CMake as far as I understand), another option is to continue building it with SwiftPM outside of build-script, but to enable static library archives in SwiftPM for WASI. I'm currently inclined to do the latter, which could become useful for distributing binary SwiftWasm libraries in general.

Cannot run SwiftWasm on macOS 10.15

I got this error after updating Tokamak to the latest SwiftWasm. Running macOS 10.15.5 (19F101).

$ carton dev --product TokamakDemo                                                                                                                                                                 
Polyfill integrity verified: /Users/jed/.carton/static/dev.js
Inferring basic settings...
- swift executable: /Users/jed/.carton/sdk/wasm-DEVELOPMENT-SNAPSHOT-2020-06-27-a/usr/bin/swift
Swift version 5.3-dev (LLVM a6315d2e8323dd3, Swift b80daa10576d040)
Target: x86_64-apple-darwin19.5.0
Parsing package manifest: /Users/jed/.carton/sdk/wasm-DEVELOPMENT-SNAPSHOT-2020-06-27-a/usr/bin/swift package dump-package
Error: Process failed with non-zero exit status and following error output:
/Users/jed/Documents/github-clones/Forks/Tokamak: error: manifest parse error(s):
Undefined symbols for architecture x86_64:
  "_$s18PackageDescription17SupportedPlatformV12MacOSVersionV6v10_15AEvau", referenced from:
      _main in Package-964a9c.o
ld: symbol(s) not found for architecture x86_64
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)

`if` does not work in a `ViewBuilder` body

Currently if you try and use if, you are met with:

Value of optional type 'view type?' must be unwrapped to a value of type 'view type'

This can be resolved with an else statement, but then it crashes with:

RuntimeError: memory access out of bounds

Implement time zones support

Currently, none of the CFTimeZone, NSTimeZone and TimeZone types work in Foundation. This is caused by the fact that WASI doesn't ship time zone files. The big problem here is that DateFormatter depends on these types, which makes it impossible to print dates. We can use an implementation based on strftime as a workaround, but this needs a better solution long term.

I don't think that embedding time zone files in the distribution is a good option, on the other hand, JavaScript folks have the same problem.

Mention Ubuntu version in the linux installable

Now that upstream supports Ubuntu 20.04, Fedora, and other distributions, we should be explicit that our builds are for Ubuntu 18.04. Maybe we should also support Ubuntu 20.04 and Fedora at some point.

SwiftWasm CI should use presets

All upstream CI buildbots are required to use presets instead of passing configuration arguments to the build script directly. We should use presets too, which will also make it easier to upstream later.

Latest 5.3 toolchain crashes when building in release mode

This is reproducible with the wasm-5.3-SNAPSHOT-2020-09-02-a snapshot. Full stacktrace:

1.      Swift version 5.3-dev (LLVM 8613c6bef0, Swift d913218013)
2.      While evaluating request ExecuteSILPipelineRequest(Run pipelines { EarlyModulePasses, HighLevel+EarlyLoopOpt, MidModulePasses+StackPromote, MidLevel, ClosureSpecialize, LowLevel, LateLoopOpt, SIL Debug Info Generator } on SIL for TokamakCore.TokamakCore)
3.      While running pass #93679 SILFunctionTransform "EarlyInliner" on SILFunction "@$s11TokamakCore4TextV8_StorageO03rawC0SSvg".
 for getter for rawText (at /Users/maxd/Documents/Tokamak/Sources/TokamakCore/Views/Text/Text.swift:81:14)
4.      While inlining SIL function "@$s11TokamakCore4TextV8_StorageO03rawC0SSvplAETK".
 for expression at [/Users/maxd/Documents/Tokamak/Sources/TokamakCore/Views/Text/Text.swift:85:14 - line:85:18] RangeText="\.0."
5.      While ...into SIL function "@$s11TokamakCore4TextV8_StorageO03rawC0SSvg".
 for getter for rawText (at /Users/maxd/Documents/Tokamak/Sources/TokamakCore/Views/Text/Text.swift:81:14)
0  swift                    0x00000001082d38a5 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x00000001082d2878 llvm::sys::RunSignalHandlers() + 248
2  swift                    0x00000001082d3e86 SignalHandler(int) + 262
3  libsystem_platform.dylib 0x00007fff67c855fd _sigtramp + 29
4  swift                    0x000000010a5f1db8 cmark_strbuf__initbuf + 170171
5  libsystem_c.dylib        0x00007fff67b5b808 abort + 120
6  libsystem_c.dylib        0x00007fff67b5aac6 err + 0
7  swift                    0x000000010859a503 swift::SILInlineCloner::cloneInline(llvm::ArrayRef<swift::SILValue>) (.cold.29) + 35
8  swift                    0x0000000104bce16c swift::SILInlineCloner::cloneInline(llvm::ArrayRef<swift::SILValue>) + 2620
9  swift                    0x0000000104bcd627 swift::SILInliner::inlineFunction(swift::SILFunction*, swift::FullApplySite, llvm::ArrayRef<swift::SILValue>) + 343
10 swift                    0x0000000104bce363 swift::SILInliner::inlineFullApply(swift::FullApplySite, swift::SILInliner::InlineKind, swift::SILOptFunctionBuilder&) + 435
11 swift                    0x0000000104a16181 (anonymous namespace)::SILPerformanceInlinerPass::run() + 1569
12 swift                    0x000000010495f991 swift::SILPassManager::runPassOnFunction(unsigned int, swift::SILFunction*) + 1809
13 swift                    0x00000001049607da swift::SILPassManager::runFunctionPasses(unsigned int, unsigned int) + 1290
14 swift                    0x000000010495dd18 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 72
15 swift                    0x000000010495dcb3 swift::ExecuteSILPipelineRequest::evaluate(swift::Evaluator&, swift::SILPipelineExecutionDescriptor) const + 51
16 swift                    0x000000010497ee1d swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::__1::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) + 29
ecuteSILPipelineRequest const&) + 365
18 swift                    0x000000010495df14 swift::executePassPipelinePlan(swift::SILModule*, swift::SILPassPipelinePlan const&, bool, swift::irgen::IRGenModule*) + 68
19 swift                    0x000000010496a837 swift::runSILOptimizationPasses(swift::SILModule&) + 151
20 swift                    0x00000001043f878b swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 619
21 swift                    0x0000000104303a91 performCompileStepsPostSILGen(swift::CompilerInstance&, swift::CompilerInvocation const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 897
22 swift                    0x00000001042f889f performCompile(swift::CompilerInstance&, swift::CompilerInvocation const&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 7743
23 swift                    0x00000001042f59be swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3454
24 swift                    0x000000010428519d main + 861
25 libdyld.dylib            0x00007fff67a8ccc9 start + 1

.wasm binaries from macOS and Linux aren't exactly the same

% md5 ~/Downloads/{macos-hello.wasm,linux-hello.wasm}/hello.wasm
MD5 (/Users/maxd/Downloads/macos-hello.wasm/hello.wasm) = 719b7fd14533c95f6a0294c8d7edbe5f
MD5 (/Users/maxd/Downloads/linux-hello.wasm/hello.wasm) = a788870a0e9d370261df7dbc9a145720
% du ~/Downloads/{macos-hello.wasm,linux-hello.wasm}/hello.wasm
9.5M	/Users/maxd/Downloads/macos-hello.wasm/hello.wasm
9.4M	/Users/maxd/Downloads/linux-hello.wasm/hello.wasm
 19M	total

I don't think there should be a reason for these binaries to differ as they were compiled from exactly the same compiler source tree.

Foundation expects undefined symbol: objc_retainAutoreleasedReturnValue

Currently, when linking with libFoundation.a compiled to WASI you get these errors:

wasm-ld: error: /usr/lib/swift_static/wasi/libFoundation.a(NSCalendar.swift.obj): 
undefined symbol: objc_retainAutoreleasedReturnValue
wasm-ld: error: /usr/lib/swift_static/wasi/libFoundation.a(DateFormatter.swift.obj): undefined symbol: objc_retainAutoreleasedReturnValue

I've been able to track it down to this line in DateFormatter.swift:

return CFDateFormatterGetFormat(_cfObject)._swiftObject

and this line in NSCalendar.swift:

return Identifier(rawValue: CFCalendarGetIdentifier(_cfObject)._swiftObject)

Looks like objc_retainAutoreleasedReturnValue intrinsic is emmitted in certain cases when bridging from CoreFoundation objects to Swift values (strings in this case). I haven't been able to find where this intrinsic is available to link it to avoid linker errors, and I'm also not sure how to stop the compiler from emitting it. I've checked the upstream Linux SDK (targeting Linux, no WebAssembly and cross-compilation involved) and it also has references to this intrinsic. If it actually works for Swift on Linux, I'm not even sure if turning it off for WebAssembly is a good idea.

Metadata doesn't work on runtime

As far as I investigated, it fails to deference absolute pointer.

Absolute Pointer?

In apple/swift, they use relative pointer which has an offset between its own address and pointee. But linker support is necessary to calculate the offset and wasm-ld doesn't have the subtraction relocation type yet.

To avoid relative pointer, @zhuowei changed to replace the offset with absolute pointer instead and it works well.

But there are some issues in this way.

Issues

  • @zhuowei's change doesn't work in latest swiftwasm branch and I don't know when this way was broken.

  • @zhuowei's patch was applied into RelativePointer.h directly. This change makes it difficult to support wasm64 because the relative pointer's offset is designed to be int32.

What we need to do

There are some ways to solve these issues.

  1. Implement subtraction relocation type in wasm-ld.

If wasm-ld supports the relocation type, we need nothing to do except reverting absolute pointer patch.

I'm contacting llvm people now for this topic. WebAssembly/tool-conventions#132

  1. Support absolute pointer in correct way

I'm implementing AbsolutePointer type and make it more robust to support 64bit environment.

Consider UTF-16 for Strings to improve performance

JavaScript strings are UTF-8, obviously converting back and forth between UTF-16 and UTF-8 has some overhead. It would be great if an option to use UTF-16 by default existed so that we could measure how big the overhead is.

Build Foundation and enable its test suite

We haven't verified how much of the Foundation module works on WASI. At a glance there don't seem to be any obvious blockers that prevent something like FoundationXML from working, but it's clear that FoundationNetworking would have to look quite differently. This needs to be verified by enabling the test suite and checking which of the tests fail.

SwiftWasm 5.3.0 release checklist

These are the things that would be great to see before SwiftWasm 5.3.0 is tagged:

  • Re-enable stdlib test suite on CI for at least macOS in swiftwasm-release/5.3 branch, ideally on Linux too (it currently fails, but CI passes anyway). If this is blocked by Wasmer, we need to report this issue to them and link it here.
  • Rename Glibc module to WASI in SwiftWasm 5.3 snapshots (tracked in #196, fixed in #1773 for swiftwasm-release/5.3 and in #1832 for swiftwasm)
  • Fix linking issues in test targets (tracked in #1824).
  • Fix linker warnings in 5.3 toolchains (tracked in #1823).
  • Add a guide for carton usage to the SwiftWasm book.
  • Allow building JavaScriptKit without unsafe flags in its Package.swift (tracked in swiftwasm/JavaScriptKit#6)
  • Ship working IndexStore in SwiftWasm 5.3 snapshots to allow swift test --enable-test-discovery (done in #1845 and #1851)
  • Ship SourceKit-LSP in SwiftWasm 5.3 snapshots (done in #1845 and #1851)
  • Fix missing Info.plist warning (tracked in #2072).
  • Patch SourceKit-LSP to allow --destination option to be passed to it (tracked in #1935)
  • Attempt integrating new LTO into swiftwasm-release/5.3 branch? I'm probably fine releasing 5.3.0 without it.

As usual, feedback is welcome. Lmk if you see anything's missing, but also bear in mind that the upstream 5.3.0 is going to be released very soon, almost certainly with iOS 14, so this list can't grow much more.

Fix compile error on test cases depending on platform

Now, failing over 400 test cases
https://gist.githack.com/kateinoigakukun/4967df0206477c913b7997862689a1b5/raw/319552867efc78d246432c72413b40eaf53d42f7/index.html

  • test/stdlib/mmap.swift
  • test/stdlib/simd_diagnostics.swift
  • test/stdlib/tgmath_optimized.swift
  • test/stdlib/VarArgs.swift
  • test/stdlib/tgmath.swift.gyb
    • Maybe related with clang importer
  • test/stdlib/simd.swift.gyb
    • Maybe related with clang importer
  • etc...
    Swift(wasi-wasm32) :: ClangImporter/cfuncs_parse.swift
    Swift(wasi-wasm32) :: ClangImporter/clang-function-types.swift
    Swift(wasi-wasm32) :: ClangImporter/cstring_parse.swift
    Swift(wasi-wasm32) :: ClangImporter/ctypes_parse.swift
    Swift(wasi-wasm32) :: ClangImporter/ctypes_parse_bitfields.swift
    Swift(wasi-wasm32) :: ClangImporter/ctypes_parse_swift4.swift
    Swift(wasi-wasm32) :: ClangImporter/ctypes_parse_union.swift
    Swift(wasi-wasm32) :: ClangImporter/cvars_parse.swift
    Swift(wasi-wasm32) :: ClangImporter/cxx_interop.swift
    Swift(wasi-wasm32) :: ClangImporter/cxx_interop_ir.swift
    Swift(wasi-wasm32) :: ClangImporter/enum-cxx.swift
    Swift(wasi-wasm32) :: ClangImporter/inlinable_bitfields.swift
    Swift(wasi-wasm32) :: ClangImporter/long-long-promotion.swift
    Swift(wasi-wasm32) :: ClangImporter/macro_literals.swift
    Swift(wasi-wasm32) :: ClangImporter/mapped-integers.swift.gyb
    Swift(wasi-wasm32) :: ClangImporter/simd.swift
    Swift(wasi-wasm32) :: ClangImporter/submodules.swift
    Swift(wasi-wasm32) :: ClangImporter/submodules_scoped.swift
    Swift(wasi-wasm32) :: ClangImporter/unserializable-clang-function-types.swift

    Swift(wasi-wasm32) :: Constraints/function_builder.swift
    Swift(wasi-wasm32) :: DebugInfo/Errors.swift
    Swift(wasi-wasm32) :: DebugInfo/variables.swift
    Swift(wasi-wasm32) :: DebuggerTestingTransform/basic-assignments.swift
    Swift(wasi-wasm32) :: Driver/SourceRanges/range-incremental-no-build-record.swift
    Swift(wasi-wasm32) :: Driver/SourceRanges/range-lifecycle.swift
    Swift(wasi-wasm32) :: Driver/autolink-force-load-comdat.swift
    Swift(wasi-wasm32) :: Driver/batch_mode_dependencies_make_wrong_order.swift
    Swift(wasi-wasm32) :: Driver/driver_mode.swift
    Swift(wasi-wasm32) :: Driver/embed-bitcode.swift
    Swift(wasi-wasm32) :: Driver/linker.swift
    Swift(wasi-wasm32) :: Driver/lock_interface.swift
    Swift(wasi-wasm32) :: Driver/multi-threaded.swift
    Swift(wasi-wasm32) :: Driver/opt-record.swift
    Swift(wasi-wasm32) :: Driver/opt-remark.swift
    Swift(wasi-wasm32) :: Driver/options.swift
    Swift(wasi-wasm32) :: Driver/profiling.swift
    Swift(wasi-wasm32) :: Driver/response-file.swift
    Swift(wasi-wasm32) :: Driver/sdk.swift
    Swift(wasi-wasm32) :: Driver/unknown-inputs.swift
    Swift(wasi-wasm32) :: Frontend/crash-in-user-code.swift
    Swift(wasi-wasm32) :: Frontend/type-fingerprint.swift
    Swift(wasi-wasm32) :: IDE/complete_cache.swift
    Swift(wasi-wasm32) :: IDE/complete_from_clang_importer_framework.swift
    Swift(wasi-wasm32) :: IDE/module_api_smoketest.swift
    Swift(wasi-wasm32) :: IRGen/access_markers.sil
    Swift(wasi-wasm32) :: IRGen/address_sanitizer_recover.swift
    Swift(wasi-wasm32) :: IRGen/asan-attributes.swift
    Swift(wasi-wasm32) :: IRGen/big_types_corner_cases.swift
    Swift(wasi-wasm32) :: IRGen/c_layout.sil
    Swift(wasi-wasm32) :: IRGen/errors.sil
    Swift(wasi-wasm32) :: IRGen/module_hash.swift
    Swift(wasi-wasm32) :: IRGen/objc_simd.sil
    Swift(wasi-wasm32) :: IRGen/pic.swift
    Swift(wasi-wasm32) :: IRGen/prespecialized-metadata/enum-inmodule-evolution-1argument-1distinct_use-external_resilient-nonfrozen.swift
    Swift(wasi-wasm32) :: IRGen/protocol_conformance_records.swift
    Swift(wasi-wasm32) :: IRGen/protocol_resilience.sil
    Swift(wasi-wasm32) :: IRGen/report_dead_method_call.swift
    Swift(wasi-wasm32) :: IRGen/sanitize_coverage.swift
    Swift(wasi-wasm32) :: Interpreter/arrays.swift
    Swift(wasi-wasm32) :: Interpreter/dynamicReplacement_property_observer.swift
    Swift(wasi-wasm32) :: Interpreter/dynamic_replacement.swift
    Swift(wasi-wasm32) :: Interpreter/dynamic_replacement_chaining.swift
    Swift(wasi-wasm32) :: Interpreter/dynamic_replacement_without_previous_calls.swift
    Swift(wasi-wasm32) :: Interpreter/enforce_exclusive_access.swift
    Swift(wasi-wasm32) :: Interpreter/enum-nonexhaustivity.swift
    Swift(wasi-wasm32) :: Interpreter/enum.swift
    Swift(wasi-wasm32) :: Interpreter/error_self_conformance.swift
    Swift(wasi-wasm32) :: Interpreter/external_key_path_ref.swift
    Swift(wasi-wasm32) :: Interpreter/keypath.swift
    Swift(wasi-wasm32) :: Interpreter/polymorphic_builtins.swift
    Swift(wasi-wasm32) :: Interpreter/property_wrappers.swift
    Swift(wasi-wasm32) :: Interpreter/switch_resilience.swift
    Swift(wasi-wasm32) :: Interpreter/testable_key_path.swift
    Swift(wasi-wasm32) :: Interpreter/tuple_casts.swift
    Swift(wasi-wasm32) :: Interpreter/unresolvable_dynamic_metadata_cycles.swift
    Swift(wasi-wasm32) :: Interpreter/withoutActuallyEscaping.swift
    Swift(wasi-wasm32) :: Misc/stats_dir_plausible_maxrss.swift
    Swift(wasi-wasm32) :: Misc/stats_dir_profiler.swift
    Swift(wasi-wasm32) :: Misc/stats_dir_tracer.swift
    Swift(wasi-wasm32) :: ModuleInterface/ModuleCache/SDKDependencies-disable-validation.swift
    Swift(wasi-wasm32) :: ModuleInterface/ModuleCache/SDKDependencies.swift
    Swift(wasi-wasm32) :: ModuleInterface/ModuleCache/SystemDependencies.swiftinterface
    Swift(wasi-wasm32) :: ModuleInterface/ModuleCache/forwarding-module-dependencies.swift
    Swift(wasi-wasm32) :: ModuleInterface/SmokeTest.swiftinterface
    Swift(wasi-wasm32) :: ModuleInterface/linking-to-module.swift
    Swift(wasi-wasm32) :: ModuleInterface/stored-properties-client.swift
    Swift(wasi-wasm32) :: ModuleInterface/swift_build_sdk_interfaces/track-system-dependencies.swift
    Swift(wasi-wasm32) :: Prototypes/Result.swift
    Swift(wasi-wasm32) :: Reflection/capture_descriptors.sil
    Swift(wasi-wasm32) :: Reflection/typeref_decoding.swift
    Swift(wasi-wasm32) :: Reflection/typeref_decoding_imported.swift
    Swift(wasi-wasm32) :: Reflection/typeref_lowering.swift
    Swift(wasi-wasm32) :: Runtime/backtrace.swift
    Swift(wasi-wasm32) :: Runtime/demangleToMetadata.swift
    Swift(wasi-wasm32) :: SIL/Parser/unnamed_struct_identifiers.sil
    Swift(wasi-wasm32) :: SIL/whole_module_optimization.swift
    Swift(wasi-wasm32) :: SILGen/auto_closures.swift
    Swift(wasi-wasm32) :: SILGen/closure_script_global_escape.swift
    Swift(wasi-wasm32) :: SILGen/closures.swift
    Swift(wasi-wasm32) :: SILGen/closures_callee_guaranteed.swift
    Swift(wasi-wasm32) :: SILGen/decls.swift
    Swift(wasi-wasm32) :: SILGen/erasure_reabstraction.swift
    Swift(wasi-wasm32) :: SILGen/function_conversion.swift
    Swift(wasi-wasm32) :: SILGen/generic_closures.swift
    Swift(wasi-wasm32) :: SILGen/implicitly_unwrapped_optional.swift
    Swift(wasi-wasm32) :: SILGen/property_abstraction.swift
    Swift(wasi-wasm32) :: SILGen/reabstract-tuple.swift
    Swift(wasi-wasm32) :: SILGen/reabstract.swift
    Swift(wasi-wasm32) :: SILGen/reabstract_lvalue.swift
    Swift(wasi-wasm32) :: SILGen/rethrows.swift
    Swift(wasi-wasm32) :: SILGen/switch_abstraction.swift
    Swift(wasi-wasm32) :: SILOptimizer/closure_lifetime_fixup.swift
    Swift(wasi-wasm32) :: SILOptimizer/closure_spec_and_inline.swift
    Swift(wasi-wasm32) :: SILOptimizer/cross-module-optimization.swift
    Swift(wasi-wasm32) :: SILOptimizer/predictable_memopt_unreferenceable_storage.swift
    Swift(wasi-wasm32) :: SILOptimizer/sil_combine1.swift
    Swift(wasi-wasm32) :: SILOptimizer/specialize_opaque_type_archetypes.swift
    Swift(wasi-wasm32) :: SILOptimizer/specialize_partial_apply.swift
    Swift(wasi-wasm32) :: Sema/clang_types_in_ast.swift
    Swift(wasi-wasm32) :: Serialization/android-modules.swift
    Swift(wasi-wasm32) :: Serialization/clang-function-types.swift
    Swift(wasi-wasm32) :: attr/attr_implements_fp.swift
    Swift(wasi-wasm32) :: multifile/resilient-module.swift
    Swift(wasi-wasm32) :: multifile/resilient-witness.swift
    Swift(wasi-wasm32) :: stdlib/Error.swift
    Swift(wasi-wasm32) :: stdlib/InputStream.swift.gyb
    Swift(wasi-wasm32) :: stdlib/Mirror.swift
    Swift(wasi-wasm32) :: stdlib/NumericParsing.swift.gyb
    Swift(wasi-wasm32) :: stdlib/Runtime.swift.gyb
    Swift(wasi-wasm32) :: stdlib/StringAPI.swift
    Swift(wasi-wasm32) :: stdlib/VarArgs.swift

Tips

To execute a single test case, run-test is very useful.

$ ./utils/run-test --build-dir ../build/Ninja-ReleaseAssert test/Runtime/foo.swift

Browser version support in platform checks

When writing requirements for swiftwasm/JavaScriptKit#56, it reminded me of my old idea for browser version checks in Swift:

@available(Safari 14, Edge 79, Firefox 68, Chrome 67)
final class JSBigInt {
  //...
}

Then user code could look like:

if #available(Safari 14, Edge 79, Firefox 68, Chrome 67) {
  // code that uses `JSBigInt`
else {
  // backward-compatible code
}

Ideally, one would write:

if #available(JSBigInt) {
  // code that uses `JSBigInt`
else {
  // backward-compatible code
}

but this doesn't match the existing semantics of #available, which checks for platforms, not features. And making the toolchain aware of every feature is not realistic in my opinion. Besides, AFAIR Xcode (and hopefully SourceKit-LSP) fix-its propose adding corresponding platform version checks automatically after you attempt to use a "future" API when targeting older platforms.

Build XCTest for the wasm32-unknown-wasi triple

Currently the XCTest module is not bult as a part of CI run, so swift test --triple wasm32-unknown-wasi fails with this error:

LifeGameTests.swift:1:8: error: could not find module 'XCTest' for target 'wasm32-unknown-wasi'; found: x86_64-apple-ios-macabi, x86_64, x86_64-apple-macos
import XCTest
       ^
LifeGameTests.swift:1:8: error: could not find module 'XCTest' for target 'wasm32-unknown-wasi'; found: x86_64-apple-ios-macabi, x86_64, x86_64-apple-macos
import XCTest
       ^

I understand that just building it for the triple probably won't fix swift test and it needs to learn how to call Wasmer for a test run, but buliding XCTest for the triple is probably a good first step.

Upstream all the changes ๐Ÿ™Œ

This issue is for tracking the overall progress of upstreaming our changes, please post here if you create any new PRs with our changes in the upstream repository:

I think these capture only about a half of our changes, maybe much less, so more upstreaming effort is needed and welcome ๐Ÿ™

For upstreaming it's best to have a look at our umbrella PR apple#24684 and its diff and pick a self-contained and a relatively small patch that doesn't overlap or conflict with the rest of open PRs in the list above.

Add SwiftPM smoke test to CI

Frequently a single Swift file can be compiled, but SwiftPM is broken in an installable distribution due to broken paths. This has to be tested on CI end-to-end.

Clang optimization breaks stdlib

enum E {
    case x(Bool)
}
_ = "\(E.x(true))"

This swift code fails to run while destroying heap object.
This crash happens with only optimized stdlib. When using --debug-swift-stdlib version stdlib, it works well.

Here is crash message and backtrace.
(The value 18446744073709551612 means -4 as signed int)

(wasminspect) run
Function exec failure Memory(AccessOutOfBounds(Some(18446744073709551612), 28573696))
(wasminspect) bt
0: _swift_release_dealloc
1: bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int)
2: swift_release
3: $ss15LazyMapSequenceVwxx
4: $ss14_CollectionBoxCfD
5: _swift_release_dealloc
6: bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int)
7: swift_release
8: $ss20_adHocPrint_unlocked___07isDebugC0yx_s6MirrorVq_zSbts16TextOutputStreamR_r0_lF
9: $ss15_print_unlockedyyx_q_zts16TextOutputStreamR_r0_lF
10: $ss26DefaultStringInterpolationV06appendC0yyxlF
11: main
12: __original_main
13: _start
(wasminspect)

https://gist.github.com/kateinoigakukun/819302b29a5f4af79a89cb172e0db9d0

Building a test bundle fails with 5.3 snapshots

The error is raised by wasm-ld:

wasm-ld: error: 
/Users/maxd/.carton/sdk/wasm-5.3-SNAPSHOT-2020-09-23-a/usr/share/wasi-sysroot/lib/wasm32-wasi/
libc.a(__original_main.o): undefined symbol: main

The build command is

/Users/maxd/.carton/sdk/wasm-5.3-SNAPSHOT-2020-09-23-a/usr/bin/swift \
  build -c debug --build-tests --destination /Users/maxd/.carton/sdk/wasm-5.3-SNAPSHOT-2020-09-23-a.json -Xswiftc -color-diagnostics

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.