| author | |
| committer | |
| log | b4343074d2d6ee81f8e589395a9c045031b86b83 |
| tree | 514fad342ae16a032e1556dec827955334aee2ff |
| parent | 43f73af3595c3174b8e67e9f2792c3774f2192e9 |
| signature |
This type is exactly the same as std.Build.Cache.Path, except for
one function which is not used anymore. Therefore we can replace
it without consequences.13 files changed, 80 insertions(+), 94 deletions(-)
src/Compilation.zig+21-44| ... | ... | @@ -72,9 +72,9 @@ bin_file: ?*link.File, |
| 72 | 72 | /// The root path for the dynamic linker and system libraries (as well as frameworks on Darwin) |
| 73 | 73 | sysroot: ?[]const u8, |
| 74 | 74 | /// This is `null` when not building a Windows DLL, or when `-fno-emit-implib` is used. |
| 75 | implib_emit: ?Emit, | |
| 75 | implib_emit: ?Path, | |
| 76 | 76 | /// This is non-null when `-femit-docs` is provided. |
| 77 | docs_emit: ?Emit, | |
| 77 | docs_emit: ?Path, | |
| 78 | 78 | root_name: [:0]const u8, |
| 79 | 79 | include_compiler_rt: bool, |
| 80 | 80 | objects: []Compilation.LinkObject, |
| ... | ... | @@ -275,29 +275,6 @@ file_system_inputs: ?*std.ArrayListUnmanaged(u8), |
| 275 | 275 | /// This digest will be known after update() is called. |
| 276 | 276 | digest: ?[Cache.bin_digest_len]u8 = null, |
| 277 | 277 | |
| 278 | /// TODO(robin): Remove because it is the same as Cache.Path | |
| 279 | pub const Emit = struct { | |
| 280 | /// Where the output will go. | |
| 281 | directory: Directory, | |
| 282 | /// Path to the output file, relative to `directory`. | |
| 283 | sub_path: []const u8, | |
| 284 | ||
| 285 | /// Returns the full path to `basename` if it were in the same directory as the | |
| 286 | /// `Emit` sub_path. | |
| 287 | pub fn basenamePath(emit: Emit, arena: Allocator, basename: []const u8) ![:0]const u8 { | |
| 288 | const full_path = if (emit.directory.path) |p| | |
| 289 | try std.fs.path.join(arena, &[_][]const u8{ p, emit.sub_path }) | |
| 290 | else | |
| 291 | emit.sub_path; | |
| 292 | ||
| 293 | if (std.fs.path.dirname(full_path)) |dirname| { | |
| 294 | return try std.fs.path.joinZ(arena, &.{ dirname, basename }); | |
| 295 | } else { | |
| 296 | return try arena.dupeZ(u8, basename); | |
| 297 | } | |
| 298 | } | |
| 299 | }; | |
| 300 | ||
| 301 | 278 | pub const default_stack_protector_buffer_size = target_util.default_stack_protector_buffer_size; |
| 302 | 279 | pub const SemaError = Zcu.SemaError; |
| 303 | 280 | |
| ... | ... | @@ -1695,8 +1672,8 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 1695 | 1672 | comp.cache_use = .{ .incremental = incremental }; |
| 1696 | 1673 | |
| 1697 | 1674 | if (options.emit_bin) |emit_bin| { |
| 1698 | const emit: Emit = .{ | |
| 1699 | .directory = emit_bin.directory orelse artifact_directory, | |
| 1675 | const emit: Path = .{ | |
| 1676 | .root_dir = emit_bin.directory orelse artifact_directory, | |
| 1700 | 1677 | .sub_path = emit_bin.basename, |
| 1701 | 1678 | }; |
| 1702 | 1679 | comp.bin_file = try link.File.open(arena, comp, emit, lf_open_opts); |
| ... | ... | @@ -1704,14 +1681,14 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 1704 | 1681 | |
| 1705 | 1682 | if (options.emit_implib) |emit_implib| { |
| 1706 | 1683 | comp.implib_emit = .{ |
| 1707 | .directory = emit_implib.directory orelse artifact_directory, | |
| 1684 | .root_dir = emit_implib.directory orelse artifact_directory, | |
| 1708 | 1685 | .sub_path = emit_implib.basename, |
| 1709 | 1686 | }; |
| 1710 | 1687 | } |
| 1711 | 1688 | |
| 1712 | 1689 | if (options.emit_docs) |emit_docs| { |
| 1713 | 1690 | comp.docs_emit = .{ |
| 1714 | .directory = emit_docs.directory orelse artifact_directory, | |
| 1691 | .root_dir = emit_docs.directory orelse artifact_directory, | |
| 1715 | 1692 | .sub_path = emit_docs.basename, |
| 1716 | 1693 | }; |
| 1717 | 1694 | } |
| ... | ... | @@ -2164,21 +2141,21 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void { |
| 2164 | 2141 | |
| 2165 | 2142 | if (whole.implib_sub_path) |sub_path| { |
| 2166 | 2143 | comp.implib_emit = .{ |
| 2167 | .directory = tmp_artifact_directory, | |
| 2144 | .root_dir = tmp_artifact_directory, | |
| 2168 | 2145 | .sub_path = std.fs.path.basename(sub_path), |
| 2169 | 2146 | }; |
| 2170 | 2147 | } |
| 2171 | 2148 | |
| 2172 | 2149 | if (whole.docs_sub_path) |sub_path| { |
| 2173 | 2150 | comp.docs_emit = .{ |
| 2174 | .directory = tmp_artifact_directory, | |
| 2151 | .root_dir = tmp_artifact_directory, | |
| 2175 | 2152 | .sub_path = std.fs.path.basename(sub_path), |
| 2176 | 2153 | }; |
| 2177 | 2154 | } |
| 2178 | 2155 | |
| 2179 | 2156 | if (whole.bin_sub_path) |sub_path| { |
| 2180 | const emit: Emit = .{ | |
| 2181 | .directory = tmp_artifact_directory, | |
| 2157 | const emit: Path = .{ | |
| 2158 | .root_dir = tmp_artifact_directory, | |
| 2182 | 2159 | .sub_path = std.fs.path.basename(sub_path), |
| 2183 | 2160 | }; |
| 2184 | 2161 | comp.bin_file = try link.File.createEmpty(arena, comp, emit, whole.lf_open_opts); |
| ... | ... | @@ -2394,7 +2371,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void { |
| 2394 | 2371 | // references object file paths. |
| 2395 | 2372 | if (comp.bin_file) |lf| { |
| 2396 | 2373 | lf.emit = .{ |
| 2397 | .directory = comp.local_cache_directory, | |
| 2374 | .root_dir = comp.local_cache_directory, | |
| 2398 | 2375 | .sub_path = whole.bin_sub_path.?, |
| 2399 | 2376 | }; |
| 2400 | 2377 | |
| ... | ... | @@ -2543,7 +2520,7 @@ fn wholeCacheModeSetBinFilePath( |
| 2543 | 2520 | @memcpy(sub_path[digest_start..][0..digest.len], digest); |
| 2544 | 2521 | |
| 2545 | 2522 | comp.implib_emit = .{ |
| 2546 | .directory = comp.local_cache_directory, | |
| 2523 | .root_dir = comp.local_cache_directory, | |
| 2547 | 2524 | .sub_path = sub_path, |
| 2548 | 2525 | }; |
| 2549 | 2526 | } |
| ... | ... | @@ -2552,7 +2529,7 @@ fn wholeCacheModeSetBinFilePath( |
| 2552 | 2529 | @memcpy(sub_path[digest_start..][0..digest.len], digest); |
| 2553 | 2530 | |
| 2554 | 2531 | comp.docs_emit = .{ |
| 2555 | .directory = comp.local_cache_directory, | |
| 2532 | .root_dir = comp.local_cache_directory, | |
| 2556 | 2533 | .sub_path = sub_path, |
| 2557 | 2534 | }; |
| 2558 | 2535 | } |
| ... | ... | @@ -3045,7 +3022,7 @@ pub fn saveState(comp: *Compilation) !void { |
| 3045 | 3022 | |
| 3046 | 3023 | // Using an atomic file prevents a crash or power failure from corrupting |
| 3047 | 3024 | // the previous incremental compilation state. |
| 3048 | var af = try lf.emit.directory.handle.atomicFile(basename, .{}); | |
| 3025 | var af = try lf.emit.root_dir.handle.atomicFile(basename, .{}); | |
| 3049 | 3026 | defer af.deinit(); |
| 3050 | 3027 | try af.file.pwritevAll(bufs.items, 0); |
| 3051 | 3028 | try af.finish(); |
| ... | ... | @@ -4010,11 +3987,11 @@ fn docsCopyFallible(comp: *Compilation) anyerror!void { |
| 4010 | 3987 | return comp.lockAndSetMiscFailure(.docs_copy, "no Zig code to document", .{}); |
| 4011 | 3988 | |
| 4012 | 3989 | const emit = comp.docs_emit.?; |
| 4013 | var out_dir = emit.directory.handle.makeOpenPath(emit.sub_path, .{}) catch |err| { | |
| 3990 | var out_dir = emit.root_dir.handle.makeOpenPath(emit.sub_path, .{}) catch |err| { | |
| 4014 | 3991 | return comp.lockAndSetMiscFailure( |
| 4015 | 3992 | .docs_copy, |
| 4016 | 3993 | "unable to create output directory '{}{s}': {s}", |
| 4017 | .{ emit.directory, emit.sub_path, @errorName(err) }, | |
| 3994 | .{ emit.root_dir, emit.sub_path, @errorName(err) }, | |
| 4018 | 3995 | ); |
| 4019 | 3996 | }; |
| 4020 | 3997 | defer out_dir.close(); |
| ... | ... | @@ -4034,7 +4011,7 @@ fn docsCopyFallible(comp: *Compilation) anyerror!void { |
| 4034 | 4011 | return comp.lockAndSetMiscFailure( |
| 4035 | 4012 | .docs_copy, |
| 4036 | 4013 | "unable to create '{}{s}/sources.tar': {s}", |
| 4037 | .{ emit.directory, emit.sub_path, @errorName(err) }, | |
| 4014 | .{ emit.root_dir, emit.sub_path, @errorName(err) }, | |
| 4038 | 4015 | ); |
| 4039 | 4016 | }; |
| 4040 | 4017 | defer tar_file.close(); |
| ... | ... | @@ -4233,11 +4210,11 @@ fn workerDocsWasmFallible(comp: *Compilation, prog_node: std.Progress.Node) anye |
| 4233 | 4210 | try comp.updateSubCompilation(sub_compilation, .docs_wasm, prog_node); |
| 4234 | 4211 | |
| 4235 | 4212 | const emit = comp.docs_emit.?; |
| 4236 | var out_dir = emit.directory.handle.makeOpenPath(emit.sub_path, .{}) catch |err| { | |
| 4213 | var out_dir = emit.root_dir.handle.makeOpenPath(emit.sub_path, .{}) catch |err| { | |
| 4237 | 4214 | return comp.lockAndSetMiscFailure( |
| 4238 | 4215 | .docs_copy, |
| 4239 | 4216 | "unable to create output directory '{}{s}': {s}", |
| 4240 | .{ emit.directory, emit.sub_path, @errorName(err) }, | |
| 4217 | .{ emit.root_dir, emit.sub_path, @errorName(err) }, | |
| 4241 | 4218 | ); |
| 4242 | 4219 | }; |
| 4243 | 4220 | defer out_dir.close(); |
| ... | ... | @@ -4251,7 +4228,7 @@ fn workerDocsWasmFallible(comp: *Compilation, prog_node: std.Progress.Node) anye |
| 4251 | 4228 | return comp.lockAndSetMiscFailure(.docs_copy, "unable to copy '{}{s}' to '{}{s}': {s}", .{ |
| 4252 | 4229 | sub_compilation.local_cache_directory, |
| 4253 | 4230 | sub_compilation.cache_use.whole.bin_sub_path.?, |
| 4254 | emit.directory, | |
| 4231 | emit.root_dir, | |
| 4255 | 4232 | emit.sub_path, |
| 4256 | 4233 | @errorName(err), |
| 4257 | 4234 | }); |
| ... | ... | @@ -4803,7 +4780,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr |
| 4803 | 4780 | try argv.appendSlice(c_object.src.cache_exempt_flags); |
| 4804 | 4781 | |
| 4805 | 4782 | const out_obj_path = if (comp.bin_file) |lf| |
| 4806 | try lf.emit.directory.join(arena, &.{lf.emit.sub_path}) | |
| 4783 | try lf.emit.root_dir.join(arena, &.{lf.emit.sub_path}) | |
| 4807 | 4784 | else |
| 4808 | 4785 | "/dev/null"; |
| 4809 | 4786 |
src/link.zig+10-9| ... | ... | @@ -11,6 +11,7 @@ const wasi_libc = @import("wasi_libc.zig"); |
| 11 | 11 | const Air = @import("Air.zig"); |
| 12 | 12 | const Allocator = std.mem.Allocator; |
| 13 | 13 | const Cache = std.Build.Cache; |
| 14 | const Path = Cache.Path; | |
| 14 | 15 | const Compilation = @import("Compilation.zig"); |
| 15 | 16 | const LibCInstallation = std.zig.LibCInstallation; |
| 16 | 17 | const Liveness = @import("Liveness.zig"); |
| ... | ... | @@ -56,7 +57,7 @@ pub const File = struct { |
| 56 | 57 | |
| 57 | 58 | /// The owner of this output File. |
| 58 | 59 | comp: *Compilation, |
| 59 | emit: Compilation.Emit, | |
| 60 | emit: Path, | |
| 60 | 61 | |
| 61 | 62 | file: ?fs.File, |
| 62 | 63 | /// When linking with LLD, this linker code will output an object file only at |
| ... | ... | @@ -189,7 +190,7 @@ pub const File = struct { |
| 189 | 190 | pub fn open( |
| 190 | 191 | arena: Allocator, |
| 191 | 192 | comp: *Compilation, |
| 192 | emit: Compilation.Emit, | |
| 193 | emit: Path, | |
| 193 | 194 | options: OpenOptions, |
| 194 | 195 | ) !*File { |
| 195 | 196 | switch (Tag.fromObjectFormat(comp.root_mod.resolved_target.result.ofmt)) { |
| ... | ... | @@ -204,7 +205,7 @@ pub const File = struct { |
| 204 | 205 | pub fn createEmpty( |
| 205 | 206 | arena: Allocator, |
| 206 | 207 | comp: *Compilation, |
| 207 | emit: Compilation.Emit, | |
| 208 | emit: Path, | |
| 208 | 209 | options: OpenOptions, |
| 209 | 210 | ) !*File { |
| 210 | 211 | switch (Tag.fromObjectFormat(comp.root_mod.resolved_target.result.ofmt)) { |
| ... | ... | @@ -243,8 +244,8 @@ pub const File = struct { |
| 243 | 244 | emit.sub_path, std.crypto.random.int(u32), |
| 244 | 245 | }); |
| 245 | 246 | defer gpa.free(tmp_sub_path); |
| 246 | try emit.directory.handle.copyFile(emit.sub_path, emit.directory.handle, tmp_sub_path, .{}); | |
| 247 | try emit.directory.handle.rename(tmp_sub_path, emit.sub_path); | |
| 247 | try emit.root_dir.handle.copyFile(emit.sub_path, emit.root_dir.handle, tmp_sub_path, .{}); | |
| 248 | try emit.root_dir.handle.rename(tmp_sub_path, emit.sub_path); | |
| 248 | 249 | switch (builtin.os.tag) { |
| 249 | 250 | .linux => std.posix.ptrace(std.os.linux.PTRACE.ATTACH, pid, 0, 0) catch |err| { |
| 250 | 251 | log.warn("ptrace failure: {s}", .{@errorName(err)}); |
| ... | ... | @@ -260,7 +261,7 @@ pub const File = struct { |
| 260 | 261 | const use_lld = build_options.have_llvm and comp.config.use_lld; |
| 261 | 262 | const output_mode = comp.config.output_mode; |
| 262 | 263 | const link_mode = comp.config.link_mode; |
| 263 | base.file = try emit.directory.handle.createFile(emit.sub_path, .{ | |
| 264 | base.file = try emit.root_dir.handle.createFile(emit.sub_path, .{ | |
| 264 | 265 | .truncate = false, |
| 265 | 266 | .read = true, |
| 266 | 267 | .mode = determineMode(use_lld, output_mode, link_mode), |
| ... | ... | @@ -603,7 +604,7 @@ pub const File = struct { |
| 603 | 604 | // Until then, we do `lld -r -o output.o input.o` even though the output is the same |
| 604 | 605 | // as the input. For the preprocessing case (`zig cc -E -o foo`) we copy the file |
| 605 | 606 | // to the final location. See also the corresponding TODO in Coff linking. |
| 606 | const full_out_path = try emit.directory.join(gpa, &[_][]const u8{emit.sub_path}); | |
| 607 | const full_out_path = try emit.root_dir.join(gpa, &[_][]const u8{emit.sub_path}); | |
| 607 | 608 | defer gpa.free(full_out_path); |
| 608 | 609 | assert(comp.c_object_table.count() == 1); |
| 609 | 610 | const the_key = comp.c_object_table.keys()[0]; |
| ... | ... | @@ -751,7 +752,7 @@ pub const File = struct { |
| 751 | 752 | const comp = base.comp; |
| 752 | 753 | const gpa = comp.gpa; |
| 753 | 754 | |
| 754 | const directory = base.emit.directory; // Just an alias to make it shorter to type. | |
| 755 | const directory = base.emit.root_dir; // Just an alias to make it shorter to type. | |
| 755 | 756 | const full_out_path = try directory.join(arena, &[_][]const u8{base.emit.sub_path}); |
| 756 | 757 | const full_out_path_z = try arena.dupeZ(u8, full_out_path); |
| 757 | 758 | const opt_zcu = comp.module; |
| ... | ... | @@ -1030,7 +1031,7 @@ pub const File = struct { |
| 1030 | 1031 | prog_node: std.Progress.Node, |
| 1031 | 1032 | ) !void { |
| 1032 | 1033 | return base.comp.emitLlvmObject(arena, .{ |
| 1033 | .root_dir = base.emit.directory, | |
| 1034 | .root_dir = base.emit.root_dir, | |
| 1034 | 1035 | .sub_path = std.fs.path.dirname(base.emit.sub_path) orelse "", |
| 1035 | 1036 | }, .{ |
| 1036 | 1037 | .directory = null, |
src/link/C.zig+4-3| ... | ... | @@ -3,6 +3,7 @@ const mem = std.mem; |
| 3 | 3 | const assert = std.debug.assert; |
| 4 | 4 | const Allocator = std.mem.Allocator; |
| 5 | 5 | const fs = std.fs; |
| 6 | const Path = std.Build.Cache.Path; | |
| 6 | 7 | |
| 7 | 8 | const C = @This(); |
| 8 | 9 | const build_options = @import("build_options"); |
| ... | ... | @@ -104,7 +105,7 @@ pub fn addString(this: *C, s: []const u8) Allocator.Error!String { |
| 104 | 105 | pub fn open( |
| 105 | 106 | arena: Allocator, |
| 106 | 107 | comp: *Compilation, |
| 107 | emit: Compilation.Emit, | |
| 108 | emit: Path, | |
| 108 | 109 | options: link.File.OpenOptions, |
| 109 | 110 | ) !*C { |
| 110 | 111 | return createEmpty(arena, comp, emit, options); |
| ... | ... | @@ -113,7 +114,7 @@ pub fn open( |
| 113 | 114 | pub fn createEmpty( |
| 114 | 115 | arena: Allocator, |
| 115 | 116 | comp: *Compilation, |
| 116 | emit: Compilation.Emit, | |
| 117 | emit: Path, | |
| 117 | 118 | options: link.File.OpenOptions, |
| 118 | 119 | ) !*C { |
| 119 | 120 | const target = comp.root_mod.resolved_target.result; |
| ... | ... | @@ -127,7 +128,7 @@ pub fn createEmpty( |
| 127 | 128 | assert(!use_lld); |
| 128 | 129 | assert(!use_llvm); |
| 129 | 130 | |
| 130 | const file = try emit.directory.handle.createFile(emit.sub_path, .{ | |
| 131 | const file = try emit.root_dir.handle.createFile(emit.sub_path, .{ | |
| 131 | 132 | // Truncation is done on `flush`. |
| 132 | 133 | .truncate = false, |
| 133 | 134 | }); |
src/link/Coff.zig+4-3| ... | ... | @@ -219,7 +219,7 @@ pub const min_text_capacity = padToIdeal(minimum_text_block_size); |
| 219 | 219 | pub fn createEmpty( |
| 220 | 220 | arena: Allocator, |
| 221 | 221 | comp: *Compilation, |
| 222 | emit: Compilation.Emit, | |
| 222 | emit: Path, | |
| 223 | 223 | options: link.File.OpenOptions, |
| 224 | 224 | ) !*Coff { |
| 225 | 225 | const target = comp.root_mod.resolved_target.result; |
| ... | ... | @@ -315,7 +315,7 @@ pub fn createEmpty( |
| 315 | 315 | // If using LLD to link, this code should produce an object file so that it |
| 316 | 316 | // can be passed to LLD. |
| 317 | 317 | const sub_path = if (use_lld) zcu_object_sub_path.? else emit.sub_path; |
| 318 | self.base.file = try emit.directory.handle.createFile(sub_path, .{ | |
| 318 | self.base.file = try emit.root_dir.handle.createFile(sub_path, .{ | |
| 319 | 319 | .truncate = true, |
| 320 | 320 | .read = true, |
| 321 | 321 | .mode = link.File.determineMode(use_lld, output_mode, link_mode), |
| ... | ... | @@ -416,7 +416,7 @@ pub fn createEmpty( |
| 416 | 416 | pub fn open( |
| 417 | 417 | arena: Allocator, |
| 418 | 418 | comp: *Compilation, |
| 419 | emit: Compilation.Emit, | |
| 419 | emit: Path, | |
| 420 | 420 | options: link.File.OpenOptions, |
| 421 | 421 | ) !*Coff { |
| 422 | 422 | // TODO: restore saved linker state, don't truncate the file, and |
| ... | ... | @@ -2714,6 +2714,7 @@ const math = std.math; |
| 2714 | 2714 | const mem = std.mem; |
| 2715 | 2715 | |
| 2716 | 2716 | const Allocator = std.mem.Allocator; |
| 2717 | const Path = std.Build.Cache.Path; | |
| 2717 | 2718 | |
| 2718 | 2719 | const codegen = @import("../codegen.zig"); |
| 2719 | 2720 | const link = @import("../link.zig"); |
src/link/Coff/lld.zig+2-2| ... | ... | @@ -27,7 +27,7 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_no |
| 27 | 27 | const comp = self.base.comp; |
| 28 | 28 | const gpa = comp.gpa; |
| 29 | 29 | |
| 30 | const directory = self.base.emit.directory; // Just an alias to make it shorter to type. | |
| 30 | const directory = self.base.emit.root_dir; // Just an alias to make it shorter to type. | |
| 31 | 31 | const full_out_path = try directory.join(arena, &[_][]const u8{self.base.emit.sub_path}); |
| 32 | 32 | |
| 33 | 33 | // If there is no Zig code to compile, then we should skip flushing the output file because it |
| ... | ... | @@ -248,7 +248,7 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_no |
| 248 | 248 | try argv.append(try allocPrint(arena, "-OUT:{s}", .{full_out_path})); |
| 249 | 249 | |
| 250 | 250 | if (comp.implib_emit) |emit| { |
| 251 | const implib_out_path = try emit.directory.join(arena, &[_][]const u8{emit.sub_path}); | |
| 251 | const implib_out_path = try emit.root_dir.join(arena, &[_][]const u8{emit.sub_path}); | |
| 252 | 252 | try argv.append(try allocPrint(arena, "-IMPLIB:{s}", .{implib_out_path})); |
| 253 | 253 | } |
| 254 | 254 |
src/link/Elf.zig+7-6| ... | ... | @@ -204,7 +204,7 @@ pub const SortSection = enum { name, alignment }; |
| 204 | 204 | pub fn createEmpty( |
| 205 | 205 | arena: Allocator, |
| 206 | 206 | comp: *Compilation, |
| 207 | emit: Compilation.Emit, | |
| 207 | emit: Path, | |
| 208 | 208 | options: link.File.OpenOptions, |
| 209 | 209 | ) !*Elf { |
| 210 | 210 | const target = comp.root_mod.resolved_target.result; |
| ... | ... | @@ -321,7 +321,7 @@ pub fn createEmpty( |
| 321 | 321 | // If using LLD to link, this code should produce an object file so that it |
| 322 | 322 | // can be passed to LLD. |
| 323 | 323 | const sub_path = if (use_lld) zcu_object_sub_path.? else emit.sub_path; |
| 324 | self.base.file = try emit.directory.handle.createFile(sub_path, .{ | |
| 324 | self.base.file = try emit.root_dir.handle.createFile(sub_path, .{ | |
| 325 | 325 | .truncate = true, |
| 326 | 326 | .read = true, |
| 327 | 327 | .mode = link.File.determineMode(use_lld, output_mode, link_mode), |
| ... | ... | @@ -401,7 +401,7 @@ pub fn createEmpty( |
| 401 | 401 | pub fn open( |
| 402 | 402 | arena: Allocator, |
| 403 | 403 | comp: *Compilation, |
| 404 | emit: Compilation.Emit, | |
| 404 | emit: Path, | |
| 405 | 405 | options: link.File.OpenOptions, |
| 406 | 406 | ) !*Elf { |
| 407 | 407 | // TODO: restore saved linker state, don't truncate the file, and |
| ... | ... | @@ -999,7 +999,7 @@ pub fn flushModule(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_nod |
| 999 | 999 | |
| 1000 | 1000 | const target = comp.root_mod.resolved_target.result; |
| 1001 | 1001 | const link_mode = comp.config.link_mode; |
| 1002 | const directory = self.base.emit.directory; // Just an alias to make it shorter to type. | |
| 1002 | const directory = self.base.emit.root_dir; // Just an alias to make it shorter to type. | |
| 1003 | 1003 | const full_out_path = try directory.join(arena, &[_][]const u8{self.base.emit.sub_path}); |
| 1004 | 1004 | const module_obj_path: ?[]const u8 = if (self.base.zcu_object_sub_path) |path| blk: { |
| 1005 | 1005 | if (fs.path.dirname(full_out_path)) |dirname| { |
| ... | ... | @@ -1356,7 +1356,7 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void { |
| 1356 | 1356 | |
| 1357 | 1357 | const target = self.base.comp.root_mod.resolved_target.result; |
| 1358 | 1358 | const link_mode = self.base.comp.config.link_mode; |
| 1359 | const directory = self.base.emit.directory; // Just an alias to make it shorter to type. | |
| 1359 | const directory = self.base.emit.root_dir; // Just an alias to make it shorter to type. | |
| 1360 | 1360 | const full_out_path = try directory.join(arena, &[_][]const u8{self.base.emit.sub_path}); |
| 1361 | 1361 | const module_obj_path: ?[]const u8 = if (self.base.zcu_object_sub_path) |path| blk: { |
| 1362 | 1362 | if (fs.path.dirname(full_out_path)) |dirname| { |
| ... | ... | @@ -2054,7 +2054,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s |
| 2054 | 2054 | const comp = self.base.comp; |
| 2055 | 2055 | const gpa = comp.gpa; |
| 2056 | 2056 | |
| 2057 | const directory = self.base.emit.directory; // Just an alias to make it shorter to type. | |
| 2057 | const directory = self.base.emit.root_dir; // Just an alias to make it shorter to type. | |
| 2058 | 2058 | const full_out_path = try directory.join(arena, &[_][]const u8{self.base.emit.sub_path}); |
| 2059 | 2059 | |
| 2060 | 2060 | // If there is no Zig code to compile, then we should skip flushing the output file because it |
| ... | ... | @@ -6016,6 +6016,7 @@ const Allocator = std.mem.Allocator; |
| 6016 | 6016 | const Archive = @import("Elf/Archive.zig"); |
| 6017 | 6017 | pub const Atom = @import("Elf/Atom.zig"); |
| 6018 | 6018 | const Cache = std.Build.Cache; |
| 6019 | const Path = Cache.Path; | |
| 6019 | 6020 | const Compilation = @import("../Compilation.zig"); |
| 6020 | 6021 | const ComdatGroupSection = synthetic_sections.ComdatGroupSection; |
| 6021 | 6022 | const CopyRelSection = synthetic_sections.CopyRelSection; |
src/link/MachO.zig+9-8| ... | ... | @@ -156,7 +156,7 @@ pub fn hashAddFrameworks(man: *Cache.Manifest, hm: []const Framework) !void { |
| 156 | 156 | pub fn createEmpty( |
| 157 | 157 | arena: Allocator, |
| 158 | 158 | comp: *Compilation, |
| 159 | emit: Compilation.Emit, | |
| 159 | emit: Path, | |
| 160 | 160 | options: link.File.OpenOptions, |
| 161 | 161 | ) !*MachO { |
| 162 | 162 | const target = comp.root_mod.resolved_target.result; |
| ... | ... | @@ -221,7 +221,7 @@ pub fn createEmpty( |
| 221 | 221 | } |
| 222 | 222 | errdefer self.base.destroy(); |
| 223 | 223 | |
| 224 | self.base.file = try emit.directory.handle.createFile(emit.sub_path, .{ | |
| 224 | self.base.file = try emit.root_dir.handle.createFile(emit.sub_path, .{ | |
| 225 | 225 | .truncate = true, |
| 226 | 226 | .read = true, |
| 227 | 227 | .mode = link.File.determineMode(false, output_mode, link_mode), |
| ... | ... | @@ -260,7 +260,7 @@ pub fn createEmpty( |
| 260 | 260 | pub fn open( |
| 261 | 261 | arena: Allocator, |
| 262 | 262 | comp: *Compilation, |
| 263 | emit: Compilation.Emit, | |
| 263 | emit: Path, | |
| 264 | 264 | options: link.File.OpenOptions, |
| 265 | 265 | ) !*MachO { |
| 266 | 266 | // TODO: restore saved linker state, don't truncate the file, and |
| ... | ... | @@ -353,7 +353,7 @@ pub fn flushModule(self: *MachO, arena: Allocator, tid: Zcu.PerThread.Id, prog_n |
| 353 | 353 | const sub_prog_node = prog_node.start("MachO Flush", 0); |
| 354 | 354 | defer sub_prog_node.end(); |
| 355 | 355 | |
| 356 | const directory = self.base.emit.directory; | |
| 356 | const directory = self.base.emit.root_dir; | |
| 357 | 357 | const full_out_path = try directory.join(arena, &[_][]const u8{self.base.emit.sub_path}); |
| 358 | 358 | const module_obj_path: ?[]const u8 = if (self.base.zcu_object_sub_path) |path| blk: { |
| 359 | 359 | if (fs.path.dirname(full_out_path)) |dirname| { |
| ... | ... | @@ -586,7 +586,7 @@ pub fn flushModule(self: *MachO, arena: Allocator, tid: Zcu.PerThread.Id, prog_n |
| 586 | 586 | if (codesig) |*csig| { |
| 587 | 587 | try self.writeCodeSignature(csig); // code signing always comes last |
| 588 | 588 | const emit = self.base.emit; |
| 589 | try invalidateKernelCache(emit.directory.handle, emit.sub_path); | |
| 589 | try invalidateKernelCache(emit.root_dir.handle, emit.sub_path); | |
| 590 | 590 | } |
| 591 | 591 | } |
| 592 | 592 | |
| ... | ... | @@ -597,7 +597,7 @@ fn dumpArgv(self: *MachO, comp: *Compilation) !void { |
| 597 | 597 | defer arena_allocator.deinit(); |
| 598 | 598 | const arena = arena_allocator.allocator(); |
| 599 | 599 | |
| 600 | const directory = self.base.emit.directory; | |
| 600 | const directory = self.base.emit.root_dir; | |
| 601 | 601 | const full_out_path = try directory.join(arena, &[_][]const u8{self.base.emit.sub_path}); |
| 602 | 602 | const module_obj_path: ?[]const u8 = if (self.base.zcu_object_sub_path) |path| blk: { |
| 603 | 603 | if (fs.path.dirname(full_out_path)) |dirname| { |
| ... | ... | @@ -3199,7 +3199,7 @@ fn copyRangeAllZeroOut(self: *MachO, old_offset: u64, new_offset: u64, size: u64 |
| 3199 | 3199 | } |
| 3200 | 3200 | |
| 3201 | 3201 | const InitMetadataOptions = struct { |
| 3202 | emit: Compilation.Emit, | |
| 3202 | emit: Path, | |
| 3203 | 3203 | zo: *ZigObject, |
| 3204 | 3204 | symbol_count_hint: u64, |
| 3205 | 3205 | program_code_size_hint: u64, |
| ... | ... | @@ -3271,7 +3271,7 @@ fn initMetadata(self: *MachO, options: InitMetadataOptions) !void { |
| 3271 | 3271 | ); |
| 3272 | 3272 | defer gpa.free(d_sym_path); |
| 3273 | 3273 | |
| 3274 | var d_sym_bundle = try options.emit.directory.handle.makeOpenPath(d_sym_path, .{}); | |
| 3274 | var d_sym_bundle = try options.emit.root_dir.handle.makeOpenPath(d_sym_path, .{}); | |
| 3275 | 3275 | defer d_sym_bundle.close(); |
| 3276 | 3276 | |
| 3277 | 3277 | const d_sym_file = try d_sym_bundle.createFile(options.emit.sub_path, .{ |
| ... | ... | @@ -4603,6 +4603,7 @@ pub const Atom = @import("MachO/Atom.zig"); |
| 4603 | 4603 | const AtomicBool = std.atomic.Value(bool); |
| 4604 | 4604 | const Bind = bind.Bind; |
| 4605 | 4605 | const Cache = std.Build.Cache; |
| 4606 | const Path = Cache.Path; | |
| 4606 | 4607 | const CodeSignature = @import("MachO/CodeSignature.zig"); |
| 4607 | 4608 | const Compilation = @import("../Compilation.zig"); |
| 4608 | 4609 | const DataInCode = synthetic.DataInCode; |
src/link/MachO/load_commands.zig+2-2| ... | ... | @@ -53,7 +53,7 @@ pub fn calcLoadCommandsSize(macho_file: *MachO, assume_max_path_len: bool) !u32 |
| 53 | 53 | if (macho_file.base.isDynLib()) { |
| 54 | 54 | const emit = macho_file.base.emit; |
| 55 | 55 | const install_name = macho_file.install_name orelse |
| 56 | try emit.directory.join(gpa, &.{emit.sub_path}); | |
| 56 | try emit.root_dir.join(gpa, &.{emit.sub_path}); | |
| 57 | 57 | defer if (macho_file.install_name == null) gpa.free(install_name); |
| 58 | 58 | sizeofcmds += calcInstallNameLen( |
| 59 | 59 | @sizeOf(macho.dylib_command), |
| ... | ... | @@ -237,7 +237,7 @@ pub fn writeDylibIdLC(macho_file: *MachO, writer: anytype) !void { |
| 237 | 237 | assert(comp.config.output_mode == .Lib and comp.config.link_mode == .dynamic); |
| 238 | 238 | const emit = macho_file.base.emit; |
| 239 | 239 | const install_name = macho_file.install_name orelse |
| 240 | try emit.directory.join(gpa, &.{emit.sub_path}); | |
| 240 | try emit.root_dir.join(gpa, &.{emit.sub_path}); | |
| 241 | 241 | defer if (macho_file.install_name == null) gpa.free(install_name); |
| 242 | 242 | const curr = comp.version orelse std.SemanticVersion{ |
| 243 | 243 | .major = 1, |
src/link/NvPtx.zig+3-2| ... | ... | @@ -11,6 +11,7 @@ const builtin = @import("builtin"); |
| 11 | 11 | const Allocator = std.mem.Allocator; |
| 12 | 12 | const assert = std.debug.assert; |
| 13 | 13 | const log = std.log.scoped(.link); |
| 14 | const Path = std.Build.Cache.Path; | |
| 14 | 15 | |
| 15 | 16 | const Zcu = @import("../Zcu.zig"); |
| 16 | 17 | const InternPool = @import("../InternPool.zig"); |
| ... | ... | @@ -28,7 +29,7 @@ llvm_object: LlvmObject.Ptr, |
| 28 | 29 | pub fn createEmpty( |
| 29 | 30 | arena: Allocator, |
| 30 | 31 | comp: *Compilation, |
| 31 | emit: Compilation.Emit, | |
| 32 | emit: Path, | |
| 32 | 33 | options: link.File.OpenOptions, |
| 33 | 34 | ) !*NvPtx { |
| 34 | 35 | const target = comp.root_mod.resolved_target.result; |
| ... | ... | @@ -70,7 +71,7 @@ pub fn createEmpty( |
| 70 | 71 | pub fn open( |
| 71 | 72 | arena: Allocator, |
| 72 | 73 | comp: *Compilation, |
| 73 | emit: Compilation.Emit, | |
| 74 | emit: Path, | |
| 74 | 75 | options: link.File.OpenOptions, |
| 75 | 76 | ) !*NvPtx { |
| 76 | 77 | const target = comp.root_mod.resolved_target.result; |
src/link/Plan9.zig+4-3| ... | ... | @@ -23,6 +23,7 @@ const mem = std.mem; |
| 23 | 23 | const Allocator = std.mem.Allocator; |
| 24 | 24 | const log = std.log.scoped(.link); |
| 25 | 25 | const assert = std.debug.assert; |
| 26 | const Path = std.Build.Cache.Path; | |
| 26 | 27 | |
| 27 | 28 | base: link.File, |
| 28 | 29 | sixtyfour_bit: bool, |
| ... | ... | @@ -275,7 +276,7 @@ pub fn defaultBaseAddrs(arch: std.Target.Cpu.Arch) Bases { |
| 275 | 276 | pub fn createEmpty( |
| 276 | 277 | arena: Allocator, |
| 277 | 278 | comp: *Compilation, |
| 278 | emit: Compilation.Emit, | |
| 279 | emit: Path, | |
| 279 | 280 | options: link.File.OpenOptions, |
| 280 | 281 | ) !*Plan9 { |
| 281 | 282 | const target = comp.root_mod.resolved_target.result; |
| ... | ... | @@ -1199,7 +1200,7 @@ pub fn deinit(self: *Plan9) void { |
| 1199 | 1200 | pub fn open( |
| 1200 | 1201 | arena: Allocator, |
| 1201 | 1202 | comp: *Compilation, |
| 1202 | emit: Compilation.Emit, | |
| 1203 | emit: Path, | |
| 1203 | 1204 | options: link.File.OpenOptions, |
| 1204 | 1205 | ) !*Plan9 { |
| 1205 | 1206 | const target = comp.root_mod.resolved_target.result; |
| ... | ... | @@ -1213,7 +1214,7 @@ pub fn open( |
| 1213 | 1214 | const self = try createEmpty(arena, comp, emit, options); |
| 1214 | 1215 | errdefer self.base.destroy(); |
| 1215 | 1216 | |
| 1216 | const file = try emit.directory.handle.createFile(emit.sub_path, .{ | |
| 1217 | const file = try emit.root_dir.handle.createFile(emit.sub_path, .{ | |
| 1217 | 1218 | .read = true, |
| 1218 | 1219 | .mode = link.File.determineMode( |
| 1219 | 1220 | use_lld, |
src/link/SpirV.zig+4-3| ... | ... | @@ -26,6 +26,7 @@ const std = @import("std"); |
| 26 | 26 | const Allocator = std.mem.Allocator; |
| 27 | 27 | const assert = std.debug.assert; |
| 28 | 28 | const log = std.log.scoped(.link); |
| 29 | const Path = std.Build.Cache.Path; | |
| 29 | 30 | |
| 30 | 31 | const Zcu = @import("../Zcu.zig"); |
| 31 | 32 | const InternPool = @import("../InternPool.zig"); |
| ... | ... | @@ -54,7 +55,7 @@ object: codegen.Object, |
| 54 | 55 | pub fn createEmpty( |
| 55 | 56 | arena: Allocator, |
| 56 | 57 | comp: *Compilation, |
| 57 | emit: Compilation.Emit, | |
| 58 | emit: Path, | |
| 58 | 59 | options: link.File.OpenOptions, |
| 59 | 60 | ) !*SpirV { |
| 60 | 61 | const gpa = comp.gpa; |
| ... | ... | @@ -95,7 +96,7 @@ pub fn createEmpty( |
| 95 | 96 | pub fn open( |
| 96 | 97 | arena: Allocator, |
| 97 | 98 | comp: *Compilation, |
| 98 | emit: Compilation.Emit, | |
| 99 | emit: Path, | |
| 99 | 100 | options: link.File.OpenOptions, |
| 100 | 101 | ) !*SpirV { |
| 101 | 102 | const target = comp.root_mod.resolved_target.result; |
| ... | ... | @@ -110,7 +111,7 @@ pub fn open( |
| 110 | 111 | errdefer spirv.base.destroy(); |
| 111 | 112 | |
| 112 | 113 | // TODO: read the file and keep valid parts instead of truncating |
| 113 | const file = try emit.directory.handle.createFile(emit.sub_path, .{ | |
| 114 | const file = try emit.root_dir.handle.createFile(emit.sub_path, .{ | |
| 114 | 115 | .truncate = true, |
| 115 | 116 | .read = true, |
| 116 | 117 | }); |
src/link/Wasm.zig+6-5| ... | ... | @@ -22,6 +22,7 @@ const Air = @import("../Air.zig"); |
| 22 | 22 | const Allocator = std.mem.Allocator; |
| 23 | 23 | const Archive = @import("Wasm/Archive.zig"); |
| 24 | 24 | const Cache = std.Build.Cache; |
| 25 | const Path = Cache.Path; | |
| 25 | 26 | const CodeGen = @import("../arch/wasm/CodeGen.zig"); |
| 26 | 27 | const Compilation = @import("../Compilation.zig"); |
| 27 | 28 | const Dwarf = @import("Dwarf.zig"); |
| ... | ... | @@ -346,7 +347,7 @@ pub const StringTable = struct { |
| 346 | 347 | pub fn open( |
| 347 | 348 | arena: Allocator, |
| 348 | 349 | comp: *Compilation, |
| 349 | emit: Compilation.Emit, | |
| 350 | emit: Path, | |
| 350 | 351 | options: link.File.OpenOptions, |
| 351 | 352 | ) !*Wasm { |
| 352 | 353 | // TODO: restore saved linker state, don't truncate the file, and |
| ... | ... | @@ -357,7 +358,7 @@ pub fn open( |
| 357 | 358 | pub fn createEmpty( |
| 358 | 359 | arena: Allocator, |
| 359 | 360 | comp: *Compilation, |
| 360 | emit: Compilation.Emit, | |
| 361 | emit: Path, | |
| 361 | 362 | options: link.File.OpenOptions, |
| 362 | 363 | ) !*Wasm { |
| 363 | 364 | const gpa = comp.gpa; |
| ... | ... | @@ -430,7 +431,7 @@ pub fn createEmpty( |
| 430 | 431 | // can be passed to LLD. |
| 431 | 432 | const sub_path = if (use_lld) zcu_object_sub_path.? else emit.sub_path; |
| 432 | 433 | |
| 433 | wasm.base.file = try emit.directory.handle.createFile(sub_path, .{ | |
| 434 | wasm.base.file = try emit.root_dir.handle.createFile(sub_path, .{ | |
| 434 | 435 | .truncate = true, |
| 435 | 436 | .read = true, |
| 436 | 437 | .mode = if (fs.has_executable_bit) |
| ... | ... | @@ -2496,7 +2497,7 @@ pub fn flushModule(wasm: *Wasm, arena: Allocator, tid: Zcu.PerThread.Id, prog_no |
| 2496 | 2497 | const sub_prog_node = prog_node.start("Wasm Flush", 0); |
| 2497 | 2498 | defer sub_prog_node.end(); |
| 2498 | 2499 | |
| 2499 | const directory = wasm.base.emit.directory; // Just an alias to make it shorter to type. | |
| 2500 | const directory = wasm.base.emit.root_dir; // Just an alias to make it shorter to type. | |
| 2500 | 2501 | const full_out_path = try directory.join(arena, &[_][]const u8{wasm.base.emit.sub_path}); |
| 2501 | 2502 | const module_obj_path: ?[]const u8 = if (wasm.base.zcu_object_sub_path) |path| blk: { |
| 2502 | 2503 | if (fs.path.dirname(full_out_path)) |dirname| { |
| ... | ... | @@ -3346,7 +3347,7 @@ fn linkWithLLD(wasm: *Wasm, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: |
| 3346 | 3347 | |
| 3347 | 3348 | const gpa = comp.gpa; |
| 3348 | 3349 | |
| 3349 | const directory = wasm.base.emit.directory; // Just an alias to make it shorter to type. | |
| 3350 | const directory = wasm.base.emit.root_dir; // Just an alias to make it shorter to type. | |
| 3350 | 3351 | const full_out_path = try directory.join(arena, &[_][]const u8{wasm.base.emit.sub_path}); |
| 3351 | 3352 | |
| 3352 | 3353 | // If there is no Zig code to compile, then we should skip flushing the output file because it |
src/main.zig+4-4| ... | ... | @@ -3519,7 +3519,7 @@ fn buildOutputType( |
| 3519 | 3519 | if (test_exec_args.items.len == 0 and target.ofmt == .c) default_exec_args: { |
| 3520 | 3520 | // Default to using `zig run` to execute the produced .c code from `zig test`. |
| 3521 | 3521 | const c_code_loc = emit_bin_loc orelse break :default_exec_args; |
| 3522 | const c_code_directory = c_code_loc.directory orelse comp.bin_file.?.emit.directory; | |
| 3522 | const c_code_directory = c_code_loc.directory orelse comp.bin_file.?.emit.root_dir; | |
| 3523 | 3523 | const c_code_path = try fs.path.join(arena, &[_][]const u8{ |
| 3524 | 3524 | c_code_directory.path orelse ".", c_code_loc.basename, |
| 3525 | 3525 | }); |
| ... | ... | @@ -4256,7 +4256,7 @@ fn runOrTest( |
| 4256 | 4256 | // A naive `directory.join` here will indeed get the correct path to the binary, |
| 4257 | 4257 | // however, in the case of cwd, we actually want `./foo` so that the path can be executed. |
| 4258 | 4258 | const exe_path = try fs.path.join(arena, &[_][]const u8{ |
| 4259 | lf.emit.directory.path orelse ".", lf.emit.sub_path, | |
| 4259 | lf.emit.root_dir.path orelse ".", lf.emit.sub_path, | |
| 4260 | 4260 | }); |
| 4261 | 4261 | |
| 4262 | 4262 | var argv = std.ArrayList([]const u8).init(gpa); |
| ... | ... | @@ -4368,7 +4368,7 @@ fn runOrTestHotSwap( |
| 4368 | 4368 | // tmp zig-cache and use it to spawn the child process. This way we are free to update |
| 4369 | 4369 | // the binary with each requested hot update. |
| 4370 | 4370 | .windows => blk: { |
| 4371 | try lf.emit.directory.handle.copyFile(lf.emit.sub_path, comp.local_cache_directory.handle, lf.emit.sub_path, .{}); | |
| 4371 | try lf.emit.root_dir.handle.copyFile(lf.emit.sub_path, comp.local_cache_directory.handle, lf.emit.sub_path, .{}); | |
| 4372 | 4372 | break :blk try fs.path.join(gpa, &[_][]const u8{ |
| 4373 | 4373 | comp.local_cache_directory.path orelse ".", lf.emit.sub_path, |
| 4374 | 4374 | }); |
| ... | ... | @@ -4377,7 +4377,7 @@ fn runOrTestHotSwap( |
| 4377 | 4377 | // A naive `directory.join` here will indeed get the correct path to the binary, |
| 4378 | 4378 | // however, in the case of cwd, we actually want `./foo` so that the path can be executed. |
| 4379 | 4379 | else => try fs.path.join(gpa, &[_][]const u8{ |
| 4380 | lf.emit.directory.path orelse ".", lf.emit.sub_path, | |
| 4380 | lf.emit.root_dir.path orelse ".", lf.emit.sub_path, | |
| 4381 | 4381 | }), |
| 4382 | 4382 | }; |
| 4383 | 4383 | defer gpa.free(exe_path); |