aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-07-04 14:07:08 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-07-04 14:07:08 -0700
commitf59bd2be539ce736d2ef04d16f48980d9c02a3ab (patch)
treea45a698a1836f350fd7992c7749932e4e1232f73 /src/Compilation.zig
parent6db190cf708d6ddb1c51d294c6f5a9416106277f (diff)
parentd65e248ed130da21e554807c8ce6add9773e0670 (diff)
downloadzig-f59bd2be539ce736d2ef04d16f48980d9c02a3ab.tar.gz
zig-f59bd2be539ce736d2ef04d16f48980d9c02a3ab.zip
Merge remote-tracking branch 'origin/master' into llvm14
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 99b502dbd7..feb9fedceb 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -2321,7 +2321,12 @@ pub fn update(comp: *Compilation) !void {
}
fn flush(comp: *Compilation, prog_node: *std.Progress.Node) !void {
- try comp.bin_file.flush(comp, prog_node); // This is needed before reading the error flags.
+ // This is needed before reading the error flags.
+ comp.bin_file.flush(comp, prog_node) catch |err| switch (err) {
+ error.FlushFailure => {}, // error reported through link_error_flags
+ error.LLDReportedFailure => {}, // error reported through log.err
+ else => |e| return e,
+ };
comp.link_error_flags = comp.bin_file.errorFlags();
const use_stage1 = build_options.omit_stage2 or
@@ -2593,10 +2598,11 @@ pub fn totalErrorCount(self: *Compilation) usize {
}
}
- // The "no entry point found" error only counts if there are no other errors.
+ // The "no entry point found" error only counts if there are no semantic analysis errors.
if (total == 0) {
total += @boolToInt(self.link_error_flags.no_entry_point_found);
}
+ total += @boolToInt(self.link_error_flags.missing_libc);
// Compile log errors only count if there are no other errors.
if (total == 0) {
@@ -2693,10 +2699,30 @@ pub fn getAllErrorsAlloc(self: *Compilation) !AllErrors {
}
}
- if (errors.items.len == 0 and self.link_error_flags.no_entry_point_found) {
+ if (errors.items.len == 0) {
+ if (self.link_error_flags.no_entry_point_found) {
+ try errors.append(.{
+ .plain = .{
+ .msg = try std.fmt.allocPrint(arena_allocator, "no entry point found", .{}),
+ },
+ });
+ }
+ }
+
+ if (self.link_error_flags.missing_libc) {
+ const notes = try arena_allocator.create([2]AllErrors.Message);
+ notes.* = .{
+ .{ .plain = .{
+ .msg = try arena_allocator.dupe(u8, "run 'zig libc -h' to learn about libc installations"),
+ } },
+ .{ .plain = .{
+ .msg = try arena_allocator.dupe(u8, "run 'zig targets' to see the targets for which zig can always provide libc"),
+ } },
+ };
try errors.append(.{
.plain = .{
- .msg = try std.fmt.allocPrint(arena_allocator, "no entry point found", .{}),
+ .msg = try std.fmt.allocPrint(arena_allocator, "libc not available", .{}),
+ .notes = notes,
},
});
}