aboutsummaryrefslogtreecommitdiff
path: root/src/link.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-12-03 17:35:47 -0800
committerAndrew Kelley <andrew@ziglang.org>2025-01-15 15:11:35 -0800
commitda25ed95fce32449f70942ea77aa5e00e75dbbdd (patch)
tree6e9e979184325aa9f4d73e0c29de5e1f55f5e4f5 /src/link.zig
parent6235cc3da4d2c6ebf7fd31242e8d82d39f5c81cf (diff)
downloadzig-da25ed95fce32449f70942ea77aa5e00e75dbbdd.tar.gz
zig-da25ed95fce32449f70942ea77aa5e00e75dbbdd.zip
macho linker conforms to explicit error sets, again
Diffstat (limited to 'src/link.zig')
-rw-r--r--src/link.zig19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/link.zig b/src/link.zig
index adcad570d4..ce82aa708f 100644
--- a/src/link.zig
+++ b/src/link.zig
@@ -632,15 +632,14 @@ pub const File = struct {
pub const UpdateDebugInfoError = Dwarf.UpdateError;
pub const FlushDebugInfoError = Dwarf.FlushError;
+ /// Note that `LinkFailure` is not a member of this error set because the error message
+ /// must be attached to `Zcu.failed_codegen` rather than `Compilation.link_diags`.
pub const UpdateNavError = error{
Overflow,
OutOfMemory,
/// Indicates the error is already reported and stored in
/// `failed_codegen` on the Zcu.
CodegenFail,
- /// Indicates the error is already reported and stored in `link_diags`
- /// on the Compilation.
- LinkFailure,
};
/// Called from within CodeGen to retrieve the symbol index of a global symbol.
@@ -1284,6 +1283,20 @@ pub const File = struct {
}, llvm_object, prog_node);
}
+ pub fn cgFail(
+ base: *File,
+ nav_index: InternPool.Nav.Index,
+ comptime format: []const u8,
+ args: anytype,
+ ) error{ CodegenFail, OutOfMemory } {
+ @branchHint(.cold);
+ const zcu = base.comp.zcu.?;
+ const gpa = zcu.gpa;
+ try zcu.failed_codegen.ensureUnusedCapacity(gpa, 1);
+ const msg = try Zcu.ErrorMsg.create(gpa, zcu.navSrcLoc(nav_index), format, args);
+ zcu.failed_codegen.putAssumeCapacityNoClobber(gpa, nav_index, msg);
+ }
+
pub const C = @import("link/C.zig");
pub const Coff = @import("link/Coff.zig");
pub const Plan9 = @import("link/Plan9.zig");