authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-10-05 00:42:08-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-10-05 00:42:08-07:00
log6152f043c0446ace7c992c33f27174152d9bd8a0
tree3d73c8928927539942ede4ef931d2ca0d8cec9e7
parentf4c6e5d94e1d06a2b438632de0808947f6561798

stage2: resolve file before putting them into cache

This was an accidental misuse of the Cache API which intends to call resolve on all file paths going into it. This one callsite was failing to do that; fixed now. Fixes relative file paths from making it into the global cache manifest. See #13050

1 files changed, 11 insertions(+), 3 deletions(-)

src/Module.zig+11-3
...@@ -4478,9 +4478,17 @@ pub fn semaFile(mod: *Module, file: *File) SemaError!void {...@@ -4478,9 +4478,17 @@ pub fn semaFile(mod: *Module, file: *File) SemaError!void {
4478 try reportRetryableFileError(mod, file, "unable to load source: {s}", .{@errorName(err)});4478 try reportRetryableFileError(mod, file, "unable to load source: {s}", .{@errorName(err)});
4479 return error.AnalysisFail;4479 return error.AnalysisFail;
4480 };4480 };
4481 const resolved_path = try file.pkg.root_src_directory.join(gpa, &.{4481
4482 file.sub_file_path,4482 const resolved_path = std.fs.path.resolve(
4483 });4483 gpa,
4484 if (file.pkg.root_src_directory.path) |pkg_path|
4485 &[_][]const u8{ pkg_path, file.sub_file_path }
4486 else
4487 &[_][]const u8{file.sub_file_path},
4488 ) catch |err| {
4489 try reportRetryableFileError(mod, file, "unable to resolve path: {s}", .{@errorName(err)});
4490 return error.AnalysisFail;
4491 };
4484 errdefer gpa.free(resolved_path);4492 errdefer gpa.free(resolved_path);
44854493
4486 try man.addFilePostContents(resolved_path, source.bytes, source.stat);4494 try man.addFilePostContents(resolved_path, source.bytes, source.stat);