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