aboutsummaryrefslogtreecommitdiff
path: root/src/link.zig
diff options
context:
space:
mode:
authorRobin Voetter <robin@voetter.nl>2024-08-18 14:35:03 +0200
committerRobin Voetter <robin@voetter.nl>2024-08-19 19:09:12 +0200
commitb4343074d2d6ee81f8e589395a9c045031b86b83 (patch)
tree514fad342ae16a032e1556dec827955334aee2ff /src/link.zig
parent43f73af3595c3174b8e67e9f2792c3774f2192e9 (diff)
downloadzig-b4343074d2d6ee81f8e589395a9c045031b86b83.tar.gz
zig-b4343074d2d6ee81f8e589395a9c045031b86b83.zip
replace Compilation.Emit with std.Build.Cache.Path
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.
Diffstat (limited to 'src/link.zig')
-rw-r--r--src/link.zig19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/link.zig b/src/link.zig
index 213b440c06..894074cdda 100644
--- a/src/link.zig
+++ b/src/link.zig
@@ -11,6 +11,7 @@ const wasi_libc = @import("wasi_libc.zig");
const Air = @import("Air.zig");
const Allocator = std.mem.Allocator;
const Cache = std.Build.Cache;
+const Path = Cache.Path;
const Compilation = @import("Compilation.zig");
const LibCInstallation = std.zig.LibCInstallation;
const Liveness = @import("Liveness.zig");
@@ -56,7 +57,7 @@ pub const File = struct {
/// The owner of this output File.
comp: *Compilation,
- emit: Compilation.Emit,
+ emit: Path,
file: ?fs.File,
/// When linking with LLD, this linker code will output an object file only at
@@ -189,7 +190,7 @@ pub const File = struct {
pub fn open(
arena: Allocator,
comp: *Compilation,
- emit: Compilation.Emit,
+ emit: Path,
options: OpenOptions,
) !*File {
switch (Tag.fromObjectFormat(comp.root_mod.resolved_target.result.ofmt)) {
@@ -204,7 +205,7 @@ pub const File = struct {
pub fn createEmpty(
arena: Allocator,
comp: *Compilation,
- emit: Compilation.Emit,
+ emit: Path,
options: OpenOptions,
) !*File {
switch (Tag.fromObjectFormat(comp.root_mod.resolved_target.result.ofmt)) {
@@ -243,8 +244,8 @@ pub const File = struct {
emit.sub_path, std.crypto.random.int(u32),
});
defer gpa.free(tmp_sub_path);
- try emit.directory.handle.copyFile(emit.sub_path, emit.directory.handle, tmp_sub_path, .{});
- try emit.directory.handle.rename(tmp_sub_path, emit.sub_path);
+ try emit.root_dir.handle.copyFile(emit.sub_path, emit.root_dir.handle, tmp_sub_path, .{});
+ try emit.root_dir.handle.rename(tmp_sub_path, emit.sub_path);
switch (builtin.os.tag) {
.linux => std.posix.ptrace(std.os.linux.PTRACE.ATTACH, pid, 0, 0) catch |err| {
log.warn("ptrace failure: {s}", .{@errorName(err)});
@@ -260,7 +261,7 @@ pub const File = struct {
const use_lld = build_options.have_llvm and comp.config.use_lld;
const output_mode = comp.config.output_mode;
const link_mode = comp.config.link_mode;
- base.file = try emit.directory.handle.createFile(emit.sub_path, .{
+ base.file = try emit.root_dir.handle.createFile(emit.sub_path, .{
.truncate = false,
.read = true,
.mode = determineMode(use_lld, output_mode, link_mode),
@@ -603,7 +604,7 @@ pub const File = struct {
// Until then, we do `lld -r -o output.o input.o` even though the output is the same
// as the input. For the preprocessing case (`zig cc -E -o foo`) we copy the file
// to the final location. See also the corresponding TODO in Coff linking.
- const full_out_path = try emit.directory.join(gpa, &[_][]const u8{emit.sub_path});
+ const full_out_path = try emit.root_dir.join(gpa, &[_][]const u8{emit.sub_path});
defer gpa.free(full_out_path);
assert(comp.c_object_table.count() == 1);
const the_key = comp.c_object_table.keys()[0];
@@ -751,7 +752,7 @@ pub const File = struct {
const comp = base.comp;
const gpa = comp.gpa;
- const directory = base.emit.directory; // Just an alias to make it shorter to type.
+ const directory = base.emit.root_dir; // Just an alias to make it shorter to type.
const full_out_path = try directory.join(arena, &[_][]const u8{base.emit.sub_path});
const full_out_path_z = try arena.dupeZ(u8, full_out_path);
const opt_zcu = comp.module;
@@ -1030,7 +1031,7 @@ pub const File = struct {
prog_node: std.Progress.Node,
) !void {
return base.comp.emitLlvmObject(arena, .{
- .root_dir = base.emit.directory,
+ .root_dir = base.emit.root_dir,
.sub_path = std.fs.path.dirname(base.emit.sub_path) orelse "",
}, .{
.directory = null,