m4 — GNU M4 for WASIX
GNU m4 1.4.21 (Debian trixie's version), built for WASIX. The macro processor that autoconf, bison and many configure scripts are driven by.
wasmer run icedcoffee/m4 -- -Dname=value file.m4
wasmer run icedcoffee/m4 -- --prefix-builtins file.m4
What is in the package
The full m4 language: define, undefine, defn, pushdef/popdef,
indir, builtin, changequote, changecom, ifdef/ifelse/shift,
foreach/forloop, arithmetic (eval, incr, decr) with --gnu 64-bit
semantics, the string builtins (len, index, substr, translit, regexp,
patsubst, format, dumpdef, traceon/traceoff, debugfile), include/
sinclude, and divert/undivert/divnum. Options: -D, -U, -I, -G,
--posix, --traditional, -P, -s, -E, -F/-R frozen state files.
Shell escapes work: syscmd and esyscmd spawn /bin/sh, and sysval /
esyscmd report status and captured output. mkstemp creates real files.
Verified
$ printf "define(foo, bar)dnl\nfoo and FOO\n" > t.m4 && m4 t.m4
bar and FOO
$ m4 t3.m4 # eval(2+3) / esyscmd(echo hi) / syscmd(true) / ifelse(1,1,yes,no) / len(abc)
5
hi
yes
3
include(), -D, --version and stdin-as-- all behave as upstream.
Two patches needed
lib/getlocalename_l-unsafe.c. gnulib'sgetlocalename_lends in#error "Please port ... to your platform!"for any OS it does not know, and WASIX lands there. WASIX has no locale objects beyond"C", so that branch now returns"C"with indefinite storage instead of aborting the build.- asyncify.
syscmd/esyscmdfork, and m4 longjmps on error; on WASIX both are driven through the module's asyncify exports. Without it every run exits 45. 510 KiB raw, 1.4 MB asyncified.
Building
./configure --host=wasm32-wasi --build=x86_64-linux-gnu --disable-nls
make
wasm-opt --asyncify --enable-threads --enable-bulk-memory src/m4 -o m4.wasm
with -matomics -mbulk-memory -pthread -mthread-model posix -ftls-model=local-exec, -D_WASI_EMULATED_{MMAN,SIGNAL,PROCESS_CLOCKS,GETPID},
-lwasi-emulated-{mman,process-clocks,getpid}, -Wl,--shared-memory -Wl,--max-memory=4294967296 -Wl,--import-memory, and the
__heap_base/__stack_pointer/__wasm_init_tls/__tls_* exports.
License: GPL-3.0-or-later, as upstream.