Repository navigation
Closed as not planned
Labels
arch-wasm32-bit and 64-bit WebAssemblybugObserved behavior contradicts documented or intended behaviorenhancementSolving this issue will likely involve adding new logic or components to the codebase.incremental compilationProblem occurs only when reusing compiler state.linking
Milestone
Description
Zig version: 0.14.0-dev.2790+d4fe4698d
The wasm linker backend does not have a way to repeat the "prelink" phase. You can reproduce this by having a C object in the compilation and editing it during an incremental update:
build.zig:
const std = @import("std");
pub fn build(b: *std.Build) void {
const exe = b.addExecutable(.{
.name = "abc",
.root_module = b.createModule(.{
.target = b.resolveTargetQuery(.{
.cpu_arch = .wasm32,
.os_tag = .wasi,
}),
.optimize = .Debug,
}),
.use_llvm = false,
.use_lld = false,
});
exe.addCSourceFiles(.{ .files = &.{"simple.c"} });
exe.entry = .disabled;
b.installArtifact(exe);
}simple.c
int add(int a, int b) {
return a + b;
}
andy@bark ~/t/abc [1]> zig build -fincremental --watch
Build Summary: 3/3 steps succeeded
install success
└─ install abc success
└─ zig build-exe abc Debug wasm32-wasi success 1s
<edit simple.c and save it>
install
└─ install abc
└─ zig build-exe abc Debug wasm32-wasi 1 errors
error: symbol collision: add
note: /home/andy/tmp/abc/.zig-cache/o/fd5f01759518ddb8e2561cbdbac2bbaf/simple.o: exported as (i32, i32) -> i32 here
note: /home/andy/tmp/abc/.zig-cache/o/fd5f01759518ddb8e2561cbdbac2bbaf/simple.o: exported as (i32, i32) -> i32 here
error: 1 compilation errors
Build Summary: 0/3 steps succeeded; 1 failed
install transitive failure
└─ install abc transitive failure
└─ zig build-exe abc Debug wasm32-wasi 1 errors
The update fails because the wasm linker has no way to repeat the prelink phase. It needs to redo all object parsing and then reconnect any references from Zcu to the newly parsed object data.
Metadata
Metadata
Assignees
Labels
arch-wasm32-bit and 64-bit WebAssemblybugObserved behavior contradicts documented or intended behaviorenhancementSolving this issue will likely involve adding new logic or components to the codebase.incremental compilationProblem occurs only when reusing compiler state.linking
Activity
mlugg commentedon Apr 26, 2026
Superseded by https://codeberg.org/ziglang/zig/issues/32081 (which instead suggests handling this in the frontend for now so that linkers need not worry about link inputs changing).