Add a build option to remove the freestanding libc

This commit is contained in:
Frank Denis
2026-08-27 12:42:24 +02:00
parent 09dc85e866
commit b8cb059f63
2 changed files with 7 additions and 1 deletions
+1
View File
@@ -78,6 +78,7 @@ jobs:
zig build -Dtarget=x86_64-freebsd
zig build -Dtarget=aarch64-freebsd
zig build -Dtarget=wasm32-freestanding
zig build -Dtarget=wasm32-freestanding -Dwasm_freestanding_libc=false
zig build -Doptimize=ReleaseFast
rm -fr zig-cache zig-out
+6 -1
View File
@@ -183,6 +183,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_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;
@@ -265,7 +270,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,