Problem
The WASM build (zig build wasm) fails with:
wasm-ld: undefined symbol: main
This happens because:
- The primitives dependency includes C libraries (BLST, C-KZG, BN254)
- These require linking with libc (
-lc)
- WASI libc expects a
main function entry point
- Even with
entry = .disabled and -fno-entry, the linker still requires main
Current Workaround
Removed WASM from the default zig build step (commit 2d2119a). The WASM build is now only triggered explicitly via zig build wasm, but it still fails.
Potential Solutions
- Add a stub main function - Export a no-op
main in src/root_c.zig when targeting WASI
- Use freestanding target - Switch from
wasm32-wasi to wasm32-freestanding, but this may break C library compatibility
- Conditional C library linking - Only link crypto libraries when not targeting WASM (would reduce WASM functionality)
- Custom WASI reactor entry - Use
_initialize instead of main for WASI reactor-style modules
References
Problem
The WASM build (
zig build wasm) fails with:This happens because:
-lc)mainfunction entry pointentry = .disabledand-fno-entry, the linker still requiresmainCurrent Workaround
Removed WASM from the default
zig buildstep (commit 2d2119a). The WASM build is now only triggered explicitly viazig build wasm, but it still fails.Potential Solutions
maininsrc/root_c.zigwhen targeting WASIwasm32-wasitowasm32-freestanding, but this may break C library compatibility_initializeinstead ofmainfor WASI reactor-style modulesReferences