diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e437d0f8..327775e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,6 +70,7 @@ jobs: zig build -Dtarget=aarch64-freebsd zig build -Dtarget=wasm32-wasi zig build -Dtarget=wasm32-freestanding + zig build -Dtarget=wasm32-freestanding -Dwasm_freestanding_libc=false zig build -Doptimize=ReleaseFast rm -fr zig-cache zig-out diff --git a/build.zig b/build.zig index e2eeb040..f7688736 100644 --- a/build.zig +++ b/build.zig @@ -201,6 +201,11 @@ pub fn build(b: *std.Build) !void { const enable_benchmarks = b.option(bool, "enable_benchmarks", "Whether tests should be benchmarks.") orelse false; const benchmarks_iterations = b.option(u32, "iterations", "Number of iterations for benchmarks.") orelse 200; const wasm_max_memory = b.option(u64, "wasm_max_memory", "Maximum WebAssembly linear memory size in bytes.") orelse null; + const wasm_freestanding_libc = b.option( + bool, + "wasm_freestanding_libc", + "Include the built-in libc compatibility layer for wasm32-freestanding.", + ) orelse true; var build_static = b.option(bool, "static", "Build libsodium as a static library.") orelse true; var build_shared = b.option(bool, "shared", "Build libsodium as a shared library.") orelse true; @@ -283,7 +288,7 @@ pub fn build(b: *std.Build) !void { "-Werror=vla", }; - if (wasm_freestanding) { + if (wasm_freestanding and wasm_freestanding_libc) { lib.root_module.addCSourceFiles(.{ .files = &.{wasm_libc_path ++ "/libc.c"}, .flags = flags,