From 2e902218b930b8c09ddf9b348031f331df58b85c Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 23 Aug 2024 11:55:12 +0900 Subject: [PATCH 1/6] llvmorg-19.1.0-rc3 --- src/llvm-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llvm-project b/src/llvm-project index 26a1d6601..437434df2 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 26a1d6601d727a96f4301d0d8647b5a42760ae0c +Subproject commit 437434df21d839becb453f6821564662e9824f02 From 69dd16983eacf0fea10842ce36eee5fd4fb8d10f Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 23 Aug 2024 16:19:47 +0900 Subject: [PATCH 2/6] document setjmp/longjmp support --- SetjmpLongjmp.md | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 SetjmpLongjmp.md diff --git a/SetjmpLongjmp.md b/SetjmpLongjmp.md new file mode 100644 index 000000000..df8c4af13 --- /dev/null +++ b/SetjmpLongjmp.md @@ -0,0 +1,75 @@ +# C setjmp/longjmp support + +## Build an application + +To build an application using setjmp/longjmp, you need two things: + +* Enable the necessary LLVM translation (`-mllvm -wasm-enable-sjlj`) + +* Link the setjmp library (`-lsetjmp`) + +### Example without LTO + +```shell +clang -Os -mllvm -wasm-enable-sjlj -o your_app.wasm your_app.c -lsetjmp +``` + +### Example with LTO + +```shell +clang -Os -flto=full -mllvm -wasm-enable-sjlj -Wl,-mllvm,-wasm-enable-sjlj -o your_app.wasm your_app.c -lsetjmp +``` + +## Run an application + +To run the application built as in the previous section, +you need to use a runtime with [exception handling proposal] support. + +Unfortunately, there are two incompatible versions of +[exception handling proposal], which is commonly implemented by runtimes. + +* The latest version with `exnref` + +* The [phase3] version + +### Example with the latest exception handling proposal + +Because the current version of WASI-SDK produces an old version +of [exception handling proposal] instructions, if your runtime +implements the latest version of the proposal, you need to convert +your module to the latest version. + +[toywasm] is an example of such runtimes. + +You can use binaryen `wasm-opt` command for the conversion. + +```shell +wasm-opt --translate-to-exnref -all -o your_app.exnref.wasm your_app.wasm +``` + +Then you can run it with a runtime supporting the latest version of +[exception handling proposal]. + +```shell +toywasm --wasi your_app.exnref.wasm +``` +(You may need to enable the support with `-D TOYWASM_ENABLE_WASM_EXCEPTION_HANDLING=ON`.) + +### Example with the phase3 exception handling proposal (a bit older version) + +If your runtime supports the [phase3] version of +[exception handling proposal], which is the same version as what WASI-SDK +currently produces, you can run the produced module as it is. + +For example, the classic interpreter of [wasm-micro-runtime] is +one of such runtimes. + +```shell +iwasm your_app.wasm +``` +(You may need to enable the support with `-D WAMR_BUILD_EXCE_HANDLING=1 -D WAMR_BUILD_FAST_INTERP=0`.) + +[exception handling proposal]: https://github.com/WebAssembly/exception-handling/ +[phase3]: https://github.com/WebAssembly/exception-handling/tree/main/proposals/exception-handling/legacy +[toywasm]: https://github.com/yamt/toywasm +[wasm-micro-runtime]: https://github.com/bytecodealliance/wasm-micro-runtime From e98bace3f7d2f1413920e961bf9389aa69cd14e9 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 23 Aug 2024 16:20:11 +0900 Subject: [PATCH 3/6] README.md: mention SetjmpLongjmp.md --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3b506ff1a..cb1b9e409 100644 --- a/README.md +++ b/README.md @@ -201,12 +201,16 @@ disabled in a configure step before building with WASI SDK. ## Notable Limitations This repository does not yet support __C++ exceptions__. C++ code is supported -only with -fno-exceptions for now. Similarly, there is not yet support for -setjmp/longjmp. Work on support for [exception handling] is underway at the -language level which will support both of these features. +only with -fno-exceptions for now. +Work on support for [exception handling] is underway at the +language level which will support the features. [exception handling]: https://github.com/WebAssembly/exception-handling/ +See [C setjmp/longjmp support] about setjmp/longjmp support. + +[C setjmp/longjmp support]: SetjmpLongjmp.md + This repository experimentally supports __threads__ with `--target=wasm32-wasi-threads`. It uses WebAssembly's [threads] primitives (atomics, `wait`/`notify`, shared memory) and [wasi-threads] for spawning From 7b33e75675f6085a0121d4abee6c7113086f3db3 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 28 Aug 2024 13:46:38 +0900 Subject: [PATCH 4/6] bump wasi-libc For following changes: * https://github.com/WebAssembly/wasi-libc/pull/526 * https://github.com/WebAssembly/wasi-libc/pull/529 --- src/wasi-libc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wasi-libc b/src/wasi-libc index b9ef79d7d..1b19fc65a 160000 --- a/src/wasi-libc +++ b/src/wasi-libc @@ -1 +1 @@ -Subproject commit b9ef79d7dbd47c6c5bafdae760823467c2f60b70 +Subproject commit 1b19fc65ad84b223876c50dd4fcd7d5a08c311dc From 85972e08591fdf01a22e958b3b2d53429787eb7d Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 3 Sep 2024 23:16:40 +0900 Subject: [PATCH 5/6] bump llvm to llvmorg-19.1.0-rc4 --- src/llvm-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llvm-project b/src/llvm-project index 437434df2..0c6415685 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 437434df21d839becb453f6821564662e9824f02 +Subproject commit 0c641568515a797473394694f05937e1f1913d87 From 254a9e74cf2efdfcc7e0639a8d701ae65a67d916 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 18 Sep 2024 09:10:21 +0900 Subject: [PATCH 6/6] bump llvm to llvmorg-19.1.0 --- src/llvm-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llvm-project b/src/llvm-project index 0c6415685..a4bf6cd7c 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 0c641568515a797473394694f05937e1f1913d87 +Subproject commit a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4