Skip to content

Commit 65dd4d3

Browse files
committed
feat: add WebAssembly support and update Makefile for runner integration
1 parent 4a7f881 commit 65dd4d3

3 files changed

Lines changed: 66 additions & 24 deletions

File tree

.github/workflows/ci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,3 +331,42 @@ jobs:
331331
leak-*
332332
oom-*
333333
if-no-files-found: ignore
334+
335+
# ==========================================
336+
# 8. WEBASSEMBLY (wasm32 & wasm64)
337+
# ==========================================
338+
wasm-tests:
339+
name: wasm-${{ matrix.wasm_arch }}
340+
runs-on: ubuntu-latest
341+
strategy:
342+
fail-fast: false
343+
matrix:
344+
include:
345+
- wasm_arch: wasm32
346+
target_flag: ""
347+
- wasm_arch: wasm64
348+
target_flag: "--target=wasm64-wasi"
349+
350+
steps:
351+
- uses: actions/checkout@v6
352+
353+
- name: install-wasmtime
354+
run: |
355+
curl https://wasmtime.dev/install.sh -sSf | bash
356+
echo "$HOME/.wasmtime/bin" >> $GITHUB_PATH
357+
358+
- name: install-wasi-sdk
359+
run: |
360+
WASI_SDK_VERSION=24
361+
curl -LO "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_VERSION}.0-x86_64-linux.tar.gz"
362+
tar -xzf wasi-sdk-${WASI_SDK_VERSION}.0-x86_64-linux.tar.gz
363+
echo "WASI_SDK_PATH=${{ github.workspace }}/$(ls -d wasi-sdk-* | head -n 1)" >> $GITHUB_ENV
364+
365+
- name: run-wasm-matrix-tests
366+
run: |
367+
make test_matrix \
368+
CC="${{ env.WASI_SDK_PATH }}/bin/clang ${{ matrix.target_flag }}" \
369+
RUNNER="wasmtime" \
370+
SAN_FLAGS="" \
371+
MATRIX_OPTS="O0 O1 O2 O3 Os Oz" \
372+
-j$(nproc) -Otarget

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,5 @@ fuzzers/*_fuzzer
6868
.venv
6969

7070
benchmark
71-
benchmark_*
71+
benchmark_*
72+
wasi*

Makefile

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,29 @@ ifneq (,$(filter MINGW% MSYS%,$(UNAME_S)))
2323
endif
2424

2525
CC ?= clang
26+
RUNNER ?=
2627
STD_C ?= c99
2728
BASE_CFLAGS = -Werror -Wall -Wextra \
28-
-Wshadow \
29-
-Wconversion -Wsign-conversion \
30-
-Wundef \
31-
-Wstrict-aliasing=1 \
32-
-Wpointer-arith \
33-
-Wdouble-promotion \
34-
-Wcast-align \
35-
-Wcast-qual \
36-
-Wmissing-declarations \
37-
-Wmissing-prototypes \
38-
-Wstrict-prototypes \
39-
-Wpadded \
40-
-Wint-to-pointer-cast \
41-
-Wpointer-to-int-cast \
42-
-W -std=$(STD_C) \
43-
-g3 \
44-
-fno-omit-frame-pointer \
45-
-fno-sanitize-recover=all \
46-
-I.
29+
-Wshadow \
30+
-Wconversion -Wsign-conversion \
31+
-Wundef \
32+
-Wstrict-aliasing=1 \
33+
-Wpointer-arith \
34+
-Wdouble-promotion \
35+
-Wcast-align \
36+
-Wcast-qual \
37+
-Wmissing-declarations \
38+
-Wmissing-prototypes \
39+
-Wstrict-prototypes \
40+
-Wpadded \
41+
-Wint-to-pointer-cast \
42+
-Wpointer-to-int-cast \
43+
-W -std=$(STD_C) \
44+
-g3 \
45+
-fno-omit-frame-pointer \
46+
-fno-sanitize-recover=all \
47+
-I.
48+
4749
CFLAGS = $(BASE_CFLAGS) $(EXTRA_CFLAGS)
4850
DEBUG_FLAGS = -DDEBUG # Debug flag
4951
COV_FLAGS = -O0 -fprofile-arcs -ftest-coverage --coverage # Coverage flags
@@ -105,7 +107,7 @@ $(TEST_DIR)/%_coverage: $(TEST_DIR)/%.cov.o
105107
# Pattern rule for running individual tests (always with debug)
106108
test_%: $(TEST_DIR)/%_test_debug
107109
@printf "\n--- Running $< (debug mode) ---\n"
108-
@./$<
110+
@$(RUNNER) ./$<
109111
@if [ $$? -ne 0 ]; then \
110112
printf "\nTest $< FAILED!\n"; \
111113
exit 1; \
@@ -138,7 +140,7 @@ tests: build_silent
138140
@exit_code=0; \
139141
for test in $(TEST_SRCS:%.c=%_silent) ; do \
140142
printf "\n--- Running $$test ---\n" ; \
141-
$(LSAN_RUN_FIX) ./$$test ; \
143+
$(LSAN_RUN_FIX) $(RUNNER) ./$$test ; \
142144
if [ $$? -ne 0 ]; then \
143145
printf "\nTest $$test FAILED with exit code $$?\n"; \
144146
exit_code=1; \
@@ -157,7 +159,7 @@ tests_full: build_debug
157159
@exit_code=0; \
158160
for test in $(TEST_SRCS:%.c=%_debug) ; do \
159161
printf "\n--- Running $$test ---\n" ; \
160-
$(LSAN_RUN_FIX) ./$$test ; \
162+
$(LSAN_RUN_FIX) $(RUNNER) ./$$test ; \
161163
if [ $$? -ne 0 ]; then \
162164
printf "\nTest $$test FAILED with exit code $$?\n"; \
163165
exit_code=1; \
@@ -230,7 +232,7 @@ $(MATRIX_DIR)/$(1)_$(2)_p$(3)/$(4): $(TEST_DIR)/$(4).c easy_stack.h $(TEST_DIR)/
230232
.PHONY: run_matrix_$(1)_$(2)_p$(3)_$(4)
231233
run_matrix_$(1)_$(2)_p$(3)_$(4): $(MATRIX_DIR)/$(1)_$(2)_p$(3)/$(4)
232234
@printf "\n=== Running: Std: $(1) | Opt: -$(2) | Pol: $(3) | Test: $(4) ===\n"
233-
@if $$(LSAN_RUN_FIX) ./$$< ; then \
235+
@if $$(LSAN_RUN_FIX) $$(RUNNER) ./$$< ; then \
234236
printf "[OK] Test passed.\n"; \
235237
else \
236238
printf "[FAIL] Test failed!\n"; \

0 commit comments

Comments
 (0)