| ... | ... | @@ -4526,7 +4526,12 @@ fn cmdTranslateC( |
| 4526 | 4526 | Compilation.dump_argv(argv.items); |
| 4527 | 4527 | } |
| 4528 | 4528 | |
| 4529 | | const formatted = switch (comp.config.c_frontend) { |
| 4529 | const Result = union(enum) { |
| 4530 | success: []const u8, |
| 4531 | error_bundle: std.zig.ErrorBundle, |
| 4532 | }; |
| 4533 | |
| 4534 | const result: Result = switch (comp.config.c_frontend) { |
| 4530 | 4535 | .aro => f: { |
| 4531 | 4536 | var stdout: []u8 = undefined; |
| 4532 | 4537 | try jitCmd(comp.gpa, arena, argv.items, .{ |
| ... | ... | @@ -4536,7 +4541,7 @@ fn cmdTranslateC( |
| 4536 | 4541 | .capture = &stdout, |
| 4537 | 4542 | .progress_node = prog_node, |
| 4538 | 4543 | }); |
| 4539 | | break :f stdout; |
| 4544 | break :f .{ .success = stdout }; |
| 4540 | 4545 | }, |
| 4541 | 4546 | .clang => f: { |
| 4542 | 4547 | if (!build_options.have_llvm) unreachable; |
| ... | ... | @@ -4564,31 +4569,43 @@ fn cmdTranslateC( |
| 4564 | 4569 | c_headers_dir_path_z, |
| 4565 | 4570 | ) catch |err| switch (err) { |
| 4566 | 4571 | error.OutOfMemory => return error.OutOfMemory, |
| 4567 | | error.SemanticAnalyzeFail => { |
| 4568 | | if (fancy_output) |p| { |
| 4569 | | p.errors = errors; |
| 4570 | | return; |
| 4571 | | } else { |
| 4572 | | errors.renderToStdErr(color.renderOptions()); |
| 4573 | | process.exit(1); |
| 4574 | | } |
| 4575 | | }, |
| 4572 | error.SemanticAnalyzeFail => break :f .{ .error_bundle = errors }, |
| 4576 | 4573 | }; |
| 4577 | 4574 | defer tree.deinit(comp.gpa); |
| 4578 | | break :f try tree.render(arena); |
| 4575 | break :f .{ .success = try tree.render(arena) }; |
| 4579 | 4576 | }, |
| 4580 | 4577 | }; |
| 4581 | 4578 | |
| 4582 | | if (out_dep_path) |dep_file_path| { |
| 4579 | if (out_dep_path) |dep_file_path| add_deps: { |
| 4583 | 4580 | const dep_basename = fs.path.basename(dep_file_path); |
| 4584 | 4581 | // Add the files depended on to the cache system. |
| 4585 | | try man.addDepFilePost(zig_cache_tmp_dir, dep_basename); |
| 4582 | man.addDepFilePost(zig_cache_tmp_dir, dep_basename) catch |err| switch (err) { |
| 4583 | error.FileNotFound => { |
| 4584 | // Clang didn't emit the dep file; nothing to add to the manifest. |
| 4585 | break :add_deps; |
| 4586 | }, |
| 4587 | else => |e| return e, |
| 4588 | }; |
| 4586 | 4589 | // Just to save disk space, we delete the file because it is never needed again. |
| 4587 | 4590 | zig_cache_tmp_dir.deleteFile(dep_basename) catch |err| { |
| 4588 | 4591 | warn("failed to delete '{s}': {s}", .{ dep_file_path, @errorName(err) }); |
| 4589 | 4592 | }; |
| 4590 | 4593 | } |
| 4591 | 4594 | |
| 4595 | const formatted = switch (result) { |
| 4596 | .success => |formatted| formatted, |
| 4597 | .error_bundle => |eb| { |
| 4598 | if (file_system_inputs) |buf| try man.populateFileSystemInputs(buf); |
| 4599 | if (fancy_output) |p| { |
| 4600 | p.errors = eb; |
| 4601 | return; |
| 4602 | } else { |
| 4603 | eb.renderToStdErr(color.renderOptions()); |
| 4604 | process.exit(1); |
| 4605 | } |
| 4606 | }, |
| 4607 | }; |
| 4608 | |
| 4592 | 4609 | const bin_digest = man.finalBin(); |
| 4593 | 4610 | const hex_digest = Cache.binToHex(bin_digest); |
| 4594 | 4611 | |