aboutsummaryrefslogtreecommitdiff
path: root/src/link
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2022-09-08 14:29:51 +0200
committerJakub Konka <kubkon@jakubkonka.com>2022-09-08 14:29:54 +0200
commit0ae2ea671b867e5ecd0bc779405c175f33316559 (patch)
treebe04082be44611973aa36b4d4ebaa260f310d6d9 /src/link
parentb98b3252beea98522c25b88eb29b5e2d8a65adfe (diff)
downloadzig-0ae2ea671b867e5ecd0bc779405c175f33316559.tar.gz
zig-0ae2ea671b867e5ecd0bc779405c175f33316559.zip
wasm: temporarily save curr file pointer before pwriting on Win
This is a temporary workaround to an unclear platform-dependence behavior we have in libstd for `std.fs.File` abstraction. See https://github.com/ziglang/zig/issues/12783 for more information.
Diffstat (limited to 'src/link')
-rw-r--r--src/link/Wasm.zig16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig
index 8c73336e9f..f0f50049b8 100644
--- a/src/link/Wasm.zig
+++ b/src/link/Wasm.zig
@@ -3055,14 +3055,26 @@ fn writeVecSectionHeader(file: fs.File, offset: u64, section: wasm.Section, size
buf[0] = @enumToInt(section);
leb.writeUnsignedFixed(5, buf[1..6], size);
leb.writeUnsignedFixed(5, buf[6..], items);
- try file.pwriteAll(&buf, offset);
+
+ if (builtin.target.os.tag == .windows) {
+ // https://github.com/ziglang/zig/issues/12783
+ const curr_pos = try file.getPos();
+ try file.pwriteAll(&buf, offset);
+ try file.seekTo(curr_pos);
+ } else try file.pwriteAll(&buf, offset);
}
fn writeCustomSectionHeader(file: fs.File, offset: u64, size: u32) !void {
var buf: [1 + 5]u8 = undefined;
buf[0] = 0; // 0 = 'custom' section
leb.writeUnsignedFixed(5, buf[1..6], size);
- try file.pwriteAll(&buf, offset);
+
+ if (builtin.target.os.tag == .windows) {
+ // https://github.com/ziglang/zig/issues/12783
+ const curr_pos = try file.getPos();
+ try file.pwriteAll(&buf, offset);
+ try file.seekTo(curr_pos);
+ } else try file.pwriteAll(&buf, offset);
}
fn emitLinkSection(self: *Wasm, file: fs.File, arena: Allocator, symbol_table: *std.AutoArrayHashMap(SymbolLoc, u32)) !void {