Skip to content

Commit 38c9744

Browse files
authored
SetjmpLongjmp.md: update for LLVM 20 (#523)
1 parent 97506a7 commit 38c9744

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

SetjmpLongjmp.md

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# C setjmp/longjmp support
22

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+
38
## Build an application
49

510
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:
1116
### Example without LTO
1217

1318
```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
1520
```
1621

1722
### Example with LTO
1823

1924
```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
2126
```
2227

2328
## Run an application
@@ -30,42 +35,44 @@ Unfortunately, there are two incompatible versions of
3035

3136
* The latest version with `exnref`
3237

33-
* The [phase3] version
38+
* The legacy [phase3] version
3439

3540
### Example with the latest exception handling proposal
3641

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.
4144

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.
4348

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.
4551

4652
```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
4854
```
4955

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.
5259

5360
```shell
54-
toywasm --wasi your_app.exnref.wasm
61+
toywasm --wasi your_app.wasm
5562
```
5663
(You may need to enable the support with `-D TOYWASM_ENABLE_WASM_EXCEPTION_HANDLING=ON`.)
5764

58-
### Example with the phase3 exception handling proposal (a bit older version)
65+
### Example with the legacy phase3 exception handling proposal
5966

60-
If your runtime supports the [phase3] version of
67+
If your runtime supports the legacy [phase3] version of
6168
[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.
6370

6471
For example, the classic interpreter of [wasm-micro-runtime] is
6572
one of such runtimes.
6673

6774
```shell
68-
iwasm your_app.wasm
75+
iwasm your_app.legacy.wasm
6976
```
7077
(You may need to enable the support with `-D WAMR_BUILD_EXCE_HANDLING=1 -D WAMR_BUILD_FAST_INTERP=0`.)
7178

0 commit comments

Comments
 (0)