diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-12-12 17:47:40 -0800 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-01-15 15:11:35 -0800 |
| commit | edd592d3710801d263ac2d82ef867db6214e4f47 (patch) | |
| tree | c75769fa3b2c8809d1ed8112dda16386022427e9 /src/link.zig | |
| parent | 968941b535052e2842f47dd9e7e45fa94f8f79c2 (diff) | |
| download | zig-edd592d3710801d263ac2d82ef867db6214e4f47.tar.gz zig-edd592d3710801d263ac2d82ef867db6214e4f47.zip | |
fix compilation when enabling llvm
Diffstat (limited to 'src/link.zig')
| -rw-r--r-- | src/link.zig | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/link.zig b/src/link.zig index eef6e82700..f3685a6b8b 100644 --- a/src/link.zig +++ b/src/link.zig @@ -1031,6 +1031,17 @@ pub const File = struct { defer tracy.end(); const comp = base.comp; + const diags = &comp.link_diags; + + return linkAsArchiveInner(base, arena, tid, prog_node) catch |err| switch (err) { + error.OutOfMemory => return error.OutOfMemory, + error.LinkFailure => return error.LinkFailure, + else => |e| return diags.fail("failed to link as archive: {s}", .{@errorName(e)}), + }; + } + + fn linkAsArchiveInner(base: *File, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: std.Progress.Node) !void { + const comp = base.comp; const directory = base.emit.root_dir; // Just an alias to make it shorter to type. const full_out_path = try directory.join(arena, &[_][]const u8{base.emit.sub_path}); @@ -1528,7 +1539,7 @@ pub fn spawnLld( const exit_code = try lldMain(arena, argv, false); if (exit_code == 0) return; if (comp.clang_passthrough_mode) std.process.exit(exit_code); - return error.LLDReportedFailure; + return error.LinkFailure; } var stderr: []u8 = &.{}; @@ -1605,17 +1616,16 @@ pub fn spawnLld( return error.UnableToSpawnSelf; }; + const diags = &comp.link_diags; switch (term) { .Exited => |code| if (code != 0) { if (comp.clang_passthrough_mode) std.process.exit(code); - const diags = &comp.link_diags; diags.lockAndParseLldStderr(argv[1], stderr); - return error.LLDReportedFailure; + return error.LinkFailure; }, else => { if (comp.clang_passthrough_mode) std.process.abort(); - log.err("{s} terminated with stderr:\n{s}", .{ argv[0], stderr }); - return error.LLDCrashed; + return diags.fail("{s} terminated with stderr:\n{s}", .{ argv[0], stderr }); }, } |
