1
1
# C setjmp/longjmp support
2
2
3
+ WASI-SDK provides basic setjmp/longjmp support.
4
+
5
+ Note that it's still under active development and may change in
6
+ future versions.
7
+
3
8
## Build an application
4
9
5
10
To build an application using setjmp/longjmp, you need two things:
@@ -11,13 +16,13 @@ To build an application using setjmp/longjmp, you need two things:
11
16
### Example without LTO
12
17
13
18
``` shell
14
- clang -Os -mllvm -wasm-enable-sjlj -o your_app.wasm your_app.c -lsetjmp
19
+ clang -Os -mllvm -wasm-enable-sjlj -o your_app.legacy. wasm your_app.c -lsetjmp
15
20
```
16
21
17
22
### Example with LTO
18
23
19
24
``` shell
20
- clang -Os -flto=full -mllvm -wasm-enable-sjlj -Wl,-mllvm,-wasm-enable-sjlj -o your_app.wasm your_app.c -lsetjmp
25
+ clang -Os -flto=full -mllvm -wasm-enable-sjlj -Wl,-mllvm,-wasm-enable-sjlj -o your_app.legacy. wasm your_app.c -lsetjmp
21
26
```
22
27
23
28
## Run an application
@@ -30,42 +35,44 @@ Unfortunately, there are two incompatible versions of
30
35
31
36
* The latest version with ` exnref `
32
37
33
- * The [ phase3] version
38
+ * The legacy [ phase3] version
34
39
35
40
### Example with the latest exception handling proposal
36
41
37
- Because the current version of WASI-SDK produces an old version
38
- of [ exception handling proposal] instructions, if your runtime
39
- implements the latest version of the proposal, you need to convert
40
- your module to the latest version.
42
+ By default, the current version of WASI-SDK produces the legacy
43
+ "phase3" version of [ exception handling proposal] instructions.
41
44
42
- [ toywasm] is an example of such runtimes.
45
+ You can tell the llvm to produce the latest version of proposal by
46
+ specifying ` -mllvm -wasm-use-legacy-eh=false ` . This is expected
47
+ to be the default in a future version.
43
48
44
- You can use binaryen ` wasm-opt ` command for the conversion.
49
+ Alternatively, you can use binaryen ` wasm-opt ` command to convert
50
+ existing modules from the legacy "phase3" version to the "exnref" version.
45
51
46
52
``` shell
47
- wasm-opt --translate-to-exnref -all -o your_app.exnref. wasm your_app.wasm
53
+ wasm-opt --translate-to-exnref -all -o your_app.wasm your_app.legacy .wasm
48
54
```
49
55
50
- Then you can run it with a runtime supporting the latest version of
51
- [ exception handling proposal] .
56
+ Then you can run it with a runtime supporting the "exnref" version of
57
+ the proposal.
58
+ [ toywasm] is an example of such runtimes.
52
59
53
60
``` shell
54
- toywasm --wasi your_app.exnref. wasm
61
+ toywasm --wasi your_app.wasm
55
62
```
56
63
(You may need to enable the support with ` -D TOYWASM_ENABLE_WASM_EXCEPTION_HANDLING=ON ` .)
57
64
58
- ### Example with the phase3 exception handling proposal (a bit older version)
65
+ ### Example with the legacy phase3 exception handling proposal
59
66
60
- If your runtime supports the [ phase3] version of
67
+ If your runtime supports the legacy [ phase3] version of
61
68
[ exception handling proposal] , which is the same version as what WASI-SDK
62
- currently produces, you can run the produced module as it is.
69
+ currently produces by default , you can run the produced module as it is.
63
70
64
71
For example, the classic interpreter of [ wasm-micro-runtime] is
65
72
one of such runtimes.
66
73
67
74
``` shell
68
- iwasm your_app.wasm
75
+ iwasm your_app.legacy. wasm
69
76
```
70
77
(You may need to enable the support with ` -D WAMR_BUILD_EXCE_HANDLING=1 -D WAMR_BUILD_FAST_INTERP=0 ` .)
71
78
0 commit comments