| ... | ... | @@ -2321,7 +2321,12 @@ pub fn update(comp: *Compilation) !void { |
| 2321 | 2321 | } |
| 2322 | 2322 | |
| 2323 | 2323 | fn flush(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 2324 | | try comp.bin_file.flush(comp, prog_node); // This is needed before reading the error flags. |
| 2324 | // This is needed before reading the error flags. |
| 2325 | comp.bin_file.flush(comp, prog_node) catch |err| switch (err) { |
| 2326 | error.FlushFailure => {}, // error reported through link_error_flags |
| 2327 | error.LLDReportedFailure => {}, // error reported through log.err |
| 2328 | else => |e| return e, |
| 2329 | }; |
| 2325 | 2330 | comp.link_error_flags = comp.bin_file.errorFlags(); |
| 2326 | 2331 | |
| 2327 | 2332 | const use_stage1 = build_options.omit_stage2 or |
| ... | ... | @@ -2593,10 +2598,11 @@ pub fn totalErrorCount(self: *Compilation) usize { |
| 2593 | 2598 | } |
| 2594 | 2599 | } |
| 2595 | 2600 | |
| 2596 | | // The "no entry point found" error only counts if there are no other errors. |
| 2601 | // The "no entry point found" error only counts if there are no semantic analysis errors. |
| 2597 | 2602 | if (total == 0) { |
| 2598 | 2603 | total += @boolToInt(self.link_error_flags.no_entry_point_found); |
| 2599 | 2604 | } |
| 2605 | total += @boolToInt(self.link_error_flags.missing_libc); |
| 2600 | 2606 | |
| 2601 | 2607 | // Compile log errors only count if there are no other errors. |
| 2602 | 2608 | if (total == 0) { |
| ... | ... | @@ -2693,10 +2699,30 @@ pub fn getAllErrorsAlloc(self: *Compilation) !AllErrors { |
| 2693 | 2699 | } |
| 2694 | 2700 | } |
| 2695 | 2701 | |
| 2696 | | if (errors.items.len == 0 and self.link_error_flags.no_entry_point_found) { |
| 2702 | if (errors.items.len == 0) { |
| 2703 | if (self.link_error_flags.no_entry_point_found) { |
| 2704 | try errors.append(.{ |
| 2705 | .plain = .{ |
| 2706 | .msg = try std.fmt.allocPrint(arena_allocator, "no entry point found", .{}), |
| 2707 | }, |
| 2708 | }); |
| 2709 | } |
| 2710 | } |
| 2711 | |
| 2712 | if (self.link_error_flags.missing_libc) { |
| 2713 | const notes = try arena_allocator.create([2]AllErrors.Message); |
| 2714 | notes.* = .{ |
| 2715 | .{ .plain = .{ |
| 2716 | .msg = try arena_allocator.dupe(u8, "run 'zig libc -h' to learn about libc installations"), |
| 2717 | } }, |
| 2718 | .{ .plain = .{ |
| 2719 | .msg = try arena_allocator.dupe(u8, "run 'zig targets' to see the targets for which zig can always provide libc"), |
| 2720 | } }, |
| 2721 | }; |
| 2697 | 2722 | try errors.append(.{ |
| 2698 | 2723 | .plain = .{ |
| 2699 | | .msg = try std.fmt.allocPrint(arena_allocator, "no entry point found", .{}), |
| 2724 | .msg = try std.fmt.allocPrint(arena_allocator, "libc not available", .{}), |
| 2725 | .notes = notes, |
| 2700 | 2726 | }, |
| 2701 | 2727 | }); |
| 2702 | 2728 | } |