| ... | @@ -173,6 +173,7 @@ verbose_llvm_bc: ?[]const u8, | ... | @@ -173,6 +173,7 @@ verbose_llvm_bc: ?[]const u8, |
| 173 | verbose_cimport: bool, | 173 | verbose_cimport: bool, |
| 174 | verbose_llvm_cpu_features: bool, | 174 | verbose_llvm_cpu_features: bool, |
| 175 | verbose_link: bool, | 175 | verbose_link: bool, |
| | 176 | link_depfile: ?[]const u8, |
| 176 | disable_c_depfile: bool, | 177 | disable_c_depfile: bool, |
| 177 | stack_report: bool, | 178 | stack_report: bool, |
| 178 | debug_compiler_runtime_libs: bool, | 179 | debug_compiler_runtime_libs: bool, |
| ... | @@ -1403,6 +1404,7 @@ pub const MiscTask = enum { | ... | @@ -1403,6 +1404,7 @@ pub const MiscTask = enum { |
| 1403 | compiler_rt, | 1404 | compiler_rt, |
| 1404 | libzigc, | 1405 | libzigc, |
| 1405 | analyze_mod, | 1406 | analyze_mod, |
| | 1407 | link_depfile, |
| 1406 | docs_copy, | 1408 | docs_copy, |
| 1407 | docs_wasm, | 1409 | docs_wasm, |
| 1408 | | 1410 | |
| ... | @@ -1732,6 +1734,7 @@ pub const CreateOptions = struct { | ... | @@ -1732,6 +1734,7 @@ pub const CreateOptions = struct { |
| 1732 | verbose_generic_instances: bool = false, | 1734 | verbose_generic_instances: bool = false, |
| 1733 | verbose_llvm_ir: ?[]const u8 = null, | 1735 | verbose_llvm_ir: ?[]const u8 = null, |
| 1734 | verbose_llvm_bc: ?[]const u8 = null, | 1736 | verbose_llvm_bc: ?[]const u8 = null, |
| | 1737 | link_depfile: ?[]const u8 = null, |
| 1735 | verbose_cimport: bool = false, | 1738 | verbose_cimport: bool = false, |
| 1736 | verbose_llvm_cpu_features: bool = false, | 1739 | verbose_llvm_cpu_features: bool = false, |
| 1737 | debug_compiler_runtime_libs: bool = false, | 1740 | debug_compiler_runtime_libs: bool = false, |
| ... | @@ -2247,6 +2250,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, | ... | @@ -2247,6 +2250,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, |
| 2247 | .verbose_generic_instances = options.verbose_generic_instances, | 2250 | .verbose_generic_instances = options.verbose_generic_instances, |
| 2248 | .verbose_llvm_ir = options.verbose_llvm_ir, | 2251 | .verbose_llvm_ir = options.verbose_llvm_ir, |
| 2249 | .verbose_llvm_bc = options.verbose_llvm_bc, | 2252 | .verbose_llvm_bc = options.verbose_llvm_bc, |
| | 2253 | .link_depfile = options.link_depfile, |
| 2250 | .verbose_cimport = options.verbose_cimport, | 2254 | .verbose_cimport = options.verbose_cimport, |
| 2251 | .verbose_llvm_cpu_features = options.verbose_llvm_cpu_features, | 2255 | .verbose_llvm_cpu_features = options.verbose_llvm_cpu_features, |
| 2252 | .verbose_link = options.verbose_link, | 2256 | .verbose_link = options.verbose_link, |
| ... | @@ -3099,6 +3103,15 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE | ... | @@ -3099,6 +3103,15 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE |
| 3099 | } | 3103 | } |
| 3100 | } | 3104 | } |
| 3101 | | 3105 | |
| | 3106 | if (comp.link_depfile) |depfile_path| if (comp.bin_file) |lf| { |
| | 3107 | assert(comp.file_system_inputs != null); |
| | 3108 | comp.createDepFile(depfile_path, lf.emit) catch |err| comp.setMiscFailure( |
| | 3109 | .link_depfile, |
| | 3110 | "unable to write linker dependency file: {t}", |
| | 3111 | .{err}, |
| | 3112 | ); |
| | 3113 | }; |
| | 3114 | |
| 3102 | if (anyErrors(comp)) { | 3115 | if (anyErrors(comp)) { |
| 3103 | // Skip flushing and keep source files loaded for error reporting. | 3116 | // Skip flushing and keep source files loaded for error reporting. |
| 3104 | return; | 3117 | return; |
| ... | @@ -5208,6 +5221,43 @@ pub fn separateCodegenThreadOk(comp: *const Compilation) bool { | ... | @@ -5208,6 +5221,43 @@ pub fn separateCodegenThreadOk(comp: *const Compilation) bool { |
| 5208 | return zcu.backendSupportsFeature(.separate_thread); | 5221 | return zcu.backendSupportsFeature(.separate_thread); |
| 5209 | } | 5222 | } |
| 5210 | | 5223 | |
| | 5224 | fn createDepFile( |
| | 5225 | comp: *Compilation, |
| | 5226 | depfile: []const u8, |
| | 5227 | binfile: Cache.Path, |
| | 5228 | ) anyerror!void { |
| | 5229 | var buf: [4096]u8 = undefined; |
| | 5230 | var af = try std.fs.cwd().atomicFile(depfile, .{ .write_buffer = &buf }); |
| | 5231 | defer af.deinit(); |
| | 5232 | |
| | 5233 | comp.writeDepFile(binfile, &af.file_writer.interface) catch return af.file_writer.err.?; |
| | 5234 | |
| | 5235 | try af.finish(); |
| | 5236 | } |
| | 5237 | |
| | 5238 | fn writeDepFile( |
| | 5239 | comp: *Compilation, |
| | 5240 | binfile: Cache.Path, |
| | 5241 | w: *std.Io.Writer, |
| | 5242 | ) std.Io.Writer.Error!void { |
| | 5243 | const prefixes = comp.cache_parent.prefixes(); |
| | 5244 | const fsi = comp.file_system_inputs.?.items; |
| | 5245 | |
| | 5246 | try w.print("{f}:", .{binfile}); |
| | 5247 | |
| | 5248 | { |
| | 5249 | var it = std.mem.splitScalar(u8, fsi, 0); |
| | 5250 | while (it.next()) |input| try w.print(" \\\n {f}{s}", .{ prefixes[input[0] - 1], input[1..] }); |
| | 5251 | } |
| | 5252 | |
| | 5253 | { |
| | 5254 | var it = std.mem.splitScalar(u8, fsi, 0); |
| | 5255 | while (it.next()) |input| try w.print("\n\n{f}{s}:", .{ prefixes[input[0] - 1], input[1..] }); |
| | 5256 | } |
| | 5257 | |
| | 5258 | try w.writeByte('\n'); |
| | 5259 | } |
| | 5260 | |
| 5211 | fn workerDocsCopy(comp: *Compilation) void { | 5261 | fn workerDocsCopy(comp: *Compilation) void { |
| 5212 | docsCopyFallible(comp) catch |err| return comp.lockAndSetMiscFailure( | 5262 | docsCopyFallible(comp) catch |err| return comp.lockAndSetMiscFailure( |
| 5213 | .docs_copy, | 5263 | .docs_copy, |