diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-10-30 18:33:06 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-10-30 23:43:53 -0700 |
| commit | f2dcfe0e408e1abf0c75293d75c4d92aed033eae (patch) | |
| tree | ac640108ecaa7f43b5c61cc2c46b744093e4926e /src/link/Elf.zig | |
| parent | f5ade5e2071fecf6b8a0b025b6ff9581082b9b5c (diff) | |
| download | zig-f2dcfe0e408e1abf0c75293d75c4d92aed033eae.tar.gz zig-f2dcfe0e408e1abf0c75293d75c4d92aed033eae.zip | |
link.File.Wasm: parse inputs in compilation pipeline
Primarily, this moves linker input parsing from flush() into the linker
task queue, which is executed simultaneously with the frontend.
I also made it avoid redundantly opening the same archive file N times
for each object file inside. Furthermore, hard code fixed buffer stream
rather than using a generic stream type.
Finally, I fixed the error handling of the Wasm.Archive.parse function.
Please pay attention to this pattern of returning a struct rather than
accepting a mutable struct as an argument. This ensures function-level
atomicity and makes resource management straightforward.
Deletes the file and path fields from Archive and Object.
Removed a well-meaning but ultimately misguided suggestion about how to
think about ZigObject since thinking about it that way has led to
problematic anti-DOD patterns.
Diffstat (limited to 'src/link/Elf.zig')
| -rw-r--r-- | src/link/Elf.zig | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/link/Elf.zig b/src/link/Elf.zig index 8a5e8f9282..ccc9e24bf6 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -823,9 +823,8 @@ pub fn flushModule(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_nod const sub_prog_node = prog_node.start("ELF Flush", 0); defer sub_prog_node.end(); - const directory = self.base.emit.root_dir; // Just an alias to make it shorter to type. const module_obj_path: ?Path = if (self.base.zcu_object_sub_path) |path| .{ - .root_dir = directory, + .root_dir = self.base.emit.root_dir, .sub_path = if (fs.path.dirname(self.base.emit.sub_path)) |dirname| try fs.path.join(arena, &.{ dirname, path }) else @@ -1104,7 +1103,7 @@ fn dumpArgvInit(self: *Elf, arena: Allocator) !void { pub fn openParseObjectReportingFailure(self: *Elf, path: Path) void { const diags = &self.base.comp.link_diags; const obj = link.openObject(path, false, false) catch |err| { - switch (diags.failParse(path, "failed to open object {}: {s}", .{ path, @errorName(err) })) { + switch (diags.failParse(path, "failed to open object: {s}", .{@errorName(err)})) { error.LinkFailure => return, } }; |
