unify host programs across targets

This commit is contained in:
2026-04-16 22:36:36 +02:00
parent e73ab0a788
commit 329014aada
11 changed files with 226 additions and 346 deletions

View File

@ -10,7 +10,7 @@ WASI_CFLAGS := "\
-O0 \
-nostdlib \
-Wl,--no-entry \
-Wl,--export-all \
-Wl,--export=wasm_module \
-Wl,--no-gc-sections \
-Wl,--initial-memory=65536 \
-Wl,--export=__heap_base \
@ -101,6 +101,7 @@ build-c-module module target="fail":
exit 1
fi
[private]
copy-c-module module:
cp targets/wasm-module/{{ module }}.cpp {{ BUILD_DIR }}-{{ module }}/wasm-module.cpp
@ -158,8 +159,8 @@ LINUX_BAREMETAL_INCLUDES := f"\
[doc("Insert the AOT array into the host program")]
[group("2: build host")]
prepare-aot-host module target="fail":
cp targets/wasm-host/{{ target }}.c {{ BUILD_DIR }}-{{ module }}/module_host.c
prepare-aot-host module:
cp targets/wasm-host/wasm_host.c {{ BUILD_DIR }}-{{ module }}/module_host.c
sed -i \
-e "s/__WASM_ARRAY_FILE__/wasm_aot_array.c/g" \
-e "s/__WASM_ARRAY__/build_{{ module }}_wasm_module_aot/g" \
@ -168,8 +169,8 @@ prepare-aot-host module target="fail":
[doc("Insert the WASM array into the host program")]
[group("2: build host")]
prepare-interp-host module target="fail":
cp targets/wasm-host/{{ target }}.c {{ BUILD_DIR }}-{{ module }}/module_host.c
prepare-interp-host module:
cp targets/wasm-host/wasm_host.c {{ BUILD_DIR }}-{{ module }}/module_host.c
sed -i \
-e "s/__WASM_ARRAY_FILE__/wasm_interp_array.c/g" \
-e "s/__WASM_ARRAY__/build_{{ module }}_wasm_module_wasm/g" \
@ -179,18 +180,21 @@ prepare-interp-host module target="fail":
[private]
build-wasm-host-fail module:
{{ CROSS_CC }} {{ CROSS_CFLAGS }} {{ CROSS_INCLUDES }} \
-DTARGET_FAIL \
-c {{ BUILD_DIR }}-{{ module }}/module_host.c \
-o {{ BUILD_DIR }}-{{ module }}/system.o
[private]
build-wasm-host-linux module:
{{ LINUX_CC }} {{ LINUX_CFLAGS }} {{ LINUX_INCLUDES }} \
-DTARGET_LINUX \
-c {{ BUILD_DIR }}-{{ module }}/module_host.c \
-o {{ BUILD_DIR }}-{{ module }}/system.o
[private]
build-wasm-host-linux-baremetal module:
{{ CROSS_CC }} {{ LINUX_BAREMETAL_CFLAGS }} {{ LINUX_BAREMETAL_INCLUDES }} \
-DTARGET_LINUX_BAREMETAL \
-c {{ BUILD_DIR }}-{{ module }}/module_host.c \
-o {{ BUILD_DIR }}-{{ module }}/system.o
@ -212,13 +216,15 @@ build-wasm-host module target="fail":
[private]
build-c-host-fail module:
{{ CROSS_CC }} {{ CROSS_CFLAGS_NOWASM }} \
-c targets/c-host/fail.c \
-DTARGET_FAIL \
-c targets/c-host/c_host.c \
-o {{ BUILD_DIR }}-{{ module }}/c_host.o
[private]
build-c-host-linux module:
{{ LINUX_CC }} {{ LINUX_CFLAGS_NOWASM }} \
-c targets/c-host/linux.c \
-DTARGET_LINUX \
-c targets/c-host/c_host.c \
-o {{ BUILD_DIR }}-{{ module }}/c_host.o
[doc("Insert the C function into the host program (no WASM)")]