Skip to content

Commit 44035be

Browse files
committed
wip
1 parent 724d866 commit 44035be

File tree

6 files changed

+96
-19
lines changed

6 files changed

+96
-19
lines changed

.github/actions/setup/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ runs:
3535
- name: Install LLVM tools (MacOS)
3636
shell: bash
3737
run: |
38-
curl -sSfL https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ inputs.clang_version }}/clang+llvm-${{ inputs.clang_version }}-${{ inputs.llvm_asset_suffix }}.tar.xz | tar xJf -
39-
export CLANG_DIR=`pwd`/clang+llvm-${{ inputs.clang_version }}-${{ inputs.llvm_asset_suffix }}/bin
38+
curl -sSfL https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ inputs.clang_version }}/LLVM-${{ inputs.clang_version }}-macOS-ARM64.tar.xz | tar xJf -
39+
export CLANG_DIR=`pwd`/LLVM-${{ inputs.clang_version }}-macOS-ARM64/bin
4040
echo "$CLANG_DIR" >> $GITHUB_PATH
4141
echo "CC=$CLANG_DIR/clang" >> $GITHUB_ENV
4242
echo "AR=$CLANG_DIR/llvm-ar" >> $GITHUB_ENV

.github/workflows/main.yml

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
upload: linux-aarch64-clang-19
3030
- name: Build on macOS aarch64
3131
os: macos-15
32-
clang_version: 15.0.7
32+
clang_version: 22.1.0
3333
llvm_asset_suffix: arm64-apple-darwin22.0
3434
upload: macos-clang-15
3535
args: -DBUILD_SHARED=OFF -DCMAKE_C_COMPILER_WORKS=ON
@@ -39,7 +39,7 @@ jobs:
3939
upload: windows-clang-20
4040
- name: Build on WASIp2 Windows x86_64
4141
os: windows-2025
42-
clang_version: 20.1.8
42+
clang_version: 22.1.0
4343
args: -DTARGET_TRIPLE=wasm32-wasip2
4444

4545
# Other versions of LLVM
@@ -60,96 +60,109 @@ jobs:
6060
# but that can be expanded as necessary in the future too.
6161
- name: Test wasm32-wasi
6262
os: ubuntu-24.04
63-
clang_version: 19
63+
clang_version: 20
6464
test: true
6565
upload: wasm32-wasi
6666
args: -DTARGET_TRIPLE=wasm32-wasi
6767

6868
- name: Test wasm32-wasip1
6969
os: ubuntu-24.04
70-
clang_version: 19
70+
clang_version: 20
7171
test: true
7272
upload: wasm32-wasip1
7373
args: -DTARGET_TRIPLE=wasm32-wasip1
7474

7575
- name: Test wasm32-wasip2
7676
os: ubuntu-24.04
77-
clang_version: 19
77+
clang_version: 20
7878
test: true
7979
upload: wasm32-wasip2
8080
args: -DTARGET_TRIPLE=wasm32-wasip2
8181

8282
- name: Test wasm32-wasip1-threads
8383
os: ubuntu-24.04
84-
clang_version: 19
84+
clang_version: 20
8585
test: true
8686
upload: wasm32-wasip1-threads
8787
args: -DTARGET_TRIPLE=wasm32-wasip1-threads
8888

8989
- name: Test wasm32-wasip1 in V8
9090
os: ubuntu-24.04
91-
clang_version: 19
91+
clang_version: 20
9292
test: true
9393
test_with_v8: true
9494
args: -DTARGET_TRIPLE=wasm32-wasip1
9595

9696
- name: Test wasm32-wasip1-threads in V8
9797
os: ubuntu-24.04
98-
clang_version: 19
98+
clang_version: 20
9999
test: true
100100
test_with_v8: true
101101
args: -DTARGET_TRIPLE=wasm32-wasip1-threads
102102

103103
- name: Test wasm32-wasi-simd
104104
os: ubuntu-24.04
105-
clang_version: 19
105+
clang_version: 20
106106
test: true
107107
upload: wasm32-wasi-simd
108108
args: -DSIMD=ON -DCHECK_SYMBOLS=OFF
109109

110110
- name: Test wasm32-wasip1 (debug)
111111
os: ubuntu-24.04
112-
clang_version: 19
112+
clang_version: 20
113113
test: true
114114
args: -DCMAKE_BUILD_TYPE=Debug
115115

116116
- name: Test wasm32-wasip2 (debug)
117117
os: ubuntu-24.04
118-
clang_version: 19
118+
clang_version: 20
119119
test: true
120120
args: -DCMAKE_BUILD_TYPE=Debug -DTARGET_TRIPLE=wasm32-wasip2
121121

122122
- name: Test wasm32-wasip1-threads (debug)
123123
os: ubuntu-24.04
124-
clang_version: 19
124+
clang_version: 20
125125
test: true
126126
args: -DCMAKE_BUILD_TYPE=Debug -DTARGET_TRIPLE=wasm32-wasip1-threads
127127

128128
- name: Test wasm32-wasip3
129129
os: ubuntu-24.04
130-
clang_version: 19
130+
clang_version: 20
131131
test: true
132132
upload: wasm32-wasip3
133133
args: -DTARGET_TRIPLE=wasm32-wasip3
134134

135135
- name: Test wasm32-wasip3 (debug)
136136
os: ubuntu-24.04
137-
clang_version: 19
137+
clang_version: 20
138138
test: true
139139
args: -DCMAKE_BUILD_TYPE=Debug -DTARGET_TRIPLE=wasm32-wasip3
140140

141141
- name: Test emmalloc
142142
os: ubuntu-24.04
143-
clang_version: 19
143+
clang_version: 20
144144
test: true
145145
args: -DMALLOC=emmalloc
146146

147147
- name: Test LTO
148148
os: ubuntu-24.04
149-
clang_version: 19
149+
clang_version: 20
150150
test: true
151151
args: -DLTO=full -DTARGET_TRIPLE=wasm32-wasip2 -DCHECK_SYMBOLS=OFF
152152

153+
- name: Test wasip2 on macOS
154+
os: macos-15
155+
clang_version: 22.1.0
156+
llvm_asset_suffix: arm64-apple-darwin22.0
157+
test: true
158+
args: -DTARGET_TRIPLE=wasm32-wasip2 -DCMAKE_C_COMPILER_WORKS=ON
159+
160+
- name: Test wasip2 on Windows
161+
os: windows-2025
162+
clang_version: 22.1.0
163+
test: true
164+
args: -DTARGET_TRIPLE=wasm32-wasip2
165+
153166
steps:
154167
- uses: actions/checkout@v4.1.7
155168
with:

cmake/clang-format.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ function(clang_format_file file)
3939
endif()
4040

4141
string(REPLACE "/" "_" source_target ${file})
42+
string(REPLACE ":" "_" source_target ${source_target})
4243
add_custom_target(format-${source_target}
4344
COMMAND ${CLANG_FORMAT} -i ${src})
4445
add_custom_target(format-check-${source_target}

cmake/scripts/run-check-symbols.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ foreach(symbol IN LISTS final_undefined_symbols)
7878
if(NOT symbol MATCHES "^__mul" AND
7979
NOT symbol STREQUAL "__memory_base" AND
8080
NOT symbol STREQUAL "__indirect_function_table" AND
81+
NOT symbol STREQUAL "__wasm_first_page_end" AND
8182
NOT symbol STREQUAL "__tls_base")
8283
file(APPEND ${out_undefined_symbols} "${symbol}\n")
8384
endif()

test/CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ endfunction()
110110
# * `NETWORK` - this test uses the network and sockets.
111111
# * `PASS_REGULAR_EXPRESSION` - a regex that must match the test output to pass
112112
# * `FAILP3` - this test fails on wasip3 targets
113+
# * `SETJMP` - this test requires setjmp/longjmp
113114
function(register_test test_name executable_name)
114-
set(options FS NETWORK FAILP3)
115+
set(options FS NETWORK FAILP3 SETJMP)
115116
set(oneValueArgs CLIENT PASS_REGULAR_EXPRESSION)
116117
set(multiValueArgs ARGV ENV LDFLAGS CFLAGS)
117118
cmake_parse_arguments(PARSE_ARGV 1 arg "${options}" "${oneValueArgs}" "${multiValueArgs}")
@@ -135,6 +136,14 @@ function(register_test test_name executable_name)
135136
list(APPEND wasmtime_args --wasm component-model-async)
136137
list(APPEND wasmtime_args --wasi p3)
137138
endif()
139+
if (arg_SETJMP)
140+
list(APPEND wasmtime_args --wasm exceptions)
141+
target_compile_options(${executable_name} PRIVATE
142+
"SHELL:-mllvm -wasm-enable-sjlj"
143+
"SHELL:-mllvm -wasm-use-legacy-eh=false"
144+
)
145+
target_link_options(${executable_name} PRIVATE -lsetjmp)
146+
endif()
138147

139148
add_test(
140149
NAME "${test_name}"
@@ -311,6 +320,11 @@ add_wasilibc_test(sleep.c)
311320
add_wasilibc_test(write.c FS)
312321
add_wasilibc_test(wasi-defines.c)
313322

323+
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER 20.0)
324+
add_wasilibc_test(setjmp.c SETJMP)
325+
set_tests_properties(setjmp.wasm PROPERTIES LABELS v8fail)
326+
endif()
327+
314328
if (TARGET_TRIPLE MATCHES "-threads")
315329
add_wasilibc_test(busywait.c)
316330
add_wasilibc_test(pthread_cond_busywait.c)

test/src/setjmp.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include "test.h"
2+
#include <setjmp.h>
3+
#include <stdlib.h>
4+
5+
#define TEST(c) \
6+
do { \
7+
if (!(c)) \
8+
t_error("%s failed\n", #c); \
9+
} while (0)
10+
11+
static void test_a() {
12+
jmp_buf env;
13+
int val = setjmp(env);
14+
if (val == 0) {
15+
longjmp(env, 42);
16+
abort();
17+
} else {
18+
TEST(val == 42);
19+
}
20+
}
21+
22+
static jmp_buf b_env;
23+
24+
static void b_child2() {
25+
longjmp(b_env, 43);
26+
abort();
27+
}
28+
29+
static void b_child() {
30+
b_child2();
31+
abort();
32+
}
33+
34+
static void test_b() {
35+
int val = setjmp(b_env);
36+
if (val == 0) {
37+
b_child();
38+
abort();
39+
} else {
40+
TEST(val == 43);
41+
}
42+
}
43+
44+
int main() {
45+
test_a();
46+
test_b();
47+
return t_status;
48+
}

0 commit comments

Comments
 (0)