authorgravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2022-09-12 21:35:28+02:00
committergravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2022-09-12 21:35:28+02:00
log3edf8c7a6cb912597bbc97ad97d554e6e4d96cdb
tree2039b9fb77c4f3ce9964a6622e51cf01e5fc874a
parent61f317e3862101a22411ac1f6005ef4ef5b8ab56
signaturelock-open Commit is signed but in an unrecognized format.

wasm-linker: reset file pointer for incremental

On each invocation of `flush()` the file pointer is moved. This means that rather than overwriting the binary file, we're appending to the file. With this commit, we're resetting said pointer to '0' and overwrite the existing binary in incremental mode.

1 files changed, 3 insertions(+), 0 deletions(-)

src/link/Wasm.zig+3
......@@ -2218,6 +2218,9 @@ pub fn flushModule(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Nod
22182218 // We write the magic bytes at the end so they will only be written
22192219 // if everything succeeded as expected. So populate with 0's for now.
22202220 try binary_writer.writeAll(&[_]u8{0} ** 8);
2221 // (Re)set file pointer to 0
2222 try wasm.base.file.?.setEndPos(0);
2223 try wasm.base.file.?.seekTo(0);
22212224
22222225 // Type section
22232226 if (wasm.func_types.items.len != 0) {