mirror of
https://github.com/ziglang/zig.git
synced 2026-02-06 06:27:05 +00:00
Compilation: redo whole vs incremental logic in create and update
This commit is contained in:
parent
33cdf33b95
commit
769dea6e37
File diff suppressed because it is too large
Load Diff
@ -52,8 +52,6 @@ comptime {
|
||||
gpa: Allocator,
|
||||
comp: *Compilation,
|
||||
|
||||
/// Where build artifacts and incremental compilation metadata serialization go.
|
||||
zig_cache_artifact_directory: Compilation.Directory,
|
||||
/// Pointer to externally managed resource.
|
||||
root_mod: *Package.Module,
|
||||
/// Normally, `main_mod` and `root_mod` are the same. The exception is `zig test`, in which
|
||||
@ -2508,7 +2506,6 @@ pub fn deinit(mod: *Module) void {
|
||||
emit_h.failed_decls.deinit(gpa);
|
||||
emit_h.decl_table.deinit(gpa);
|
||||
emit_h.allocated_emit_h.deinit(gpa);
|
||||
gpa.destroy(emit_h);
|
||||
}
|
||||
|
||||
for (mod.failed_files.values()) |value| {
|
||||
|
||||
63
src/link.zig
63
src/link.zig
@ -32,8 +32,6 @@ pub const SystemLib = struct {
|
||||
path: ?[]const u8,
|
||||
};
|
||||
|
||||
pub const CacheMode = enum { incremental, whole };
|
||||
|
||||
pub fn hashAddSystemLibs(
|
||||
man: *Cache.Manifest,
|
||||
hm: std.StringArrayHashMapUnmanaged(SystemLib),
|
||||
@ -776,67 +774,6 @@ pub const File = struct {
|
||||
}
|
||||
}
|
||||
|
||||
/// This function is called by the frontend before flush(). It communicates that
|
||||
/// `options.bin_file.emit` directory needs to be renamed from
|
||||
/// `[zig-cache]/tmp/[random]` to `[zig-cache]/o/[digest]`.
|
||||
/// The frontend would like to simply perform a file system rename, however,
|
||||
/// some linker backends care about the file paths of the objects they are linking.
|
||||
/// So this function call tells linker backends to rename the paths of object files
|
||||
/// to observe the new directory path.
|
||||
/// Linker backends which do not have this requirement can fall back to the simple
|
||||
/// implementation at the bottom of this function.
|
||||
/// This function is only called when CacheMode is `whole`.
|
||||
pub fn renameTmpIntoCache(
|
||||
base: *File,
|
||||
cache_directory: Compilation.Directory,
|
||||
tmp_dir_sub_path: []const u8,
|
||||
o_sub_path: []const u8,
|
||||
) !void {
|
||||
// So far, none of the linker backends need to respond to this event, however,
|
||||
// it makes sense that they might want to. So we leave this mechanism here
|
||||
// for now. Once the linker backends get more mature, if it turns out this
|
||||
// is not needed we can refactor this into having the frontend do the rename
|
||||
// directly, and remove this function from link.zig.
|
||||
_ = base;
|
||||
while (true) {
|
||||
if (builtin.os.tag == .windows) {
|
||||
// Work around windows `renameW` can't fail with `PathAlreadyExists`
|
||||
// See https://github.com/ziglang/zig/issues/8362
|
||||
if (cache_directory.handle.access(o_sub_path, .{})) |_| {
|
||||
try cache_directory.handle.deleteTree(o_sub_path);
|
||||
continue;
|
||||
} else |err| switch (err) {
|
||||
error.FileNotFound => {},
|
||||
else => |e| return e,
|
||||
}
|
||||
std.fs.rename(
|
||||
cache_directory.handle,
|
||||
tmp_dir_sub_path,
|
||||
cache_directory.handle,
|
||||
o_sub_path,
|
||||
) catch |err| {
|
||||
log.err("unable to rename cache dir {s} to {s}: {s}", .{ tmp_dir_sub_path, o_sub_path, @errorName(err) });
|
||||
return err;
|
||||
};
|
||||
break;
|
||||
} else {
|
||||
std.fs.rename(
|
||||
cache_directory.handle,
|
||||
tmp_dir_sub_path,
|
||||
cache_directory.handle,
|
||||
o_sub_path,
|
||||
) catch |err| switch (err) {
|
||||
error.PathAlreadyExists => {
|
||||
try cache_directory.handle.deleteTree(o_sub_path);
|
||||
continue;
|
||||
},
|
||||
else => |e| return e,
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn linkAsArchive(base: *File, comp: *Compilation, prog_node: *std.Progress.Node) FlushError!void {
|
||||
const tracy = trace(@src());
|
||||
defer tracy.end();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user