authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-16 01:49:57-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-01 17:51:20-07:00
log0be97b5ae3d32ca9cd7fbb68d5972538b48d8c76
treed0f1d642243f9cecb35ef481844c959151e9942d
parentd71e6273b6acd766eea6c37b8f53ae03cb2bd9f6

fix population of builtin.zig not making the parent dir


5 files changed, 30 insertions(+), 5 deletions(-)

src/Builtin.zig+1-1
......@@ -276,7 +276,7 @@ pub fn populateFile(comp: *Compilation, mod: *Module, file: *File) !void {
276276}
277277
278278fn writeFile(file: *File, mod: *Module) !void {
279 var af = try mod.root.atomicFile(mod.root_src_path, .{});
279 var af = try mod.root.atomicFile(mod.root_src_path, .{ .make_path = true });
280280 defer af.deinit();
281281 try af.file.writeAll(file.source);
282282 try af.finish();
src/Compilation.zig+8-1
......@@ -1119,6 +1119,11 @@ fn addModuleTableToCacheHash(
11191119 var i: usize = 0;
11201120 while (i < seen_table.count()) : (i += 1) {
11211121 const mod = seen_table.keys()[i];
1122 if (mod.isBuiltin()) {
1123 // Skip builtin.zig; it is useless as an input, and we don't want to
1124 // have to write it before checking for a cache hit.
1125 continue;
1126 }
11221127
11231128 cache_helpers.addResolvedTarget(hash, mod.resolved_target);
11241129 hash.add(mod.optimize_mode);
......@@ -1133,6 +1138,8 @@ fn addModuleTableToCacheHash(
11331138 hash.add(mod.red_zone);
11341139 hash.add(mod.sanitize_c);
11351140 hash.add(mod.sanitize_thread);
1141 hash.add(mod.unwind_tables);
1142 hash.add(mod.structured_cfg);
11361143
11371144 switch (hash_type) {
11381145 .path_bytes => {
......@@ -2371,7 +2378,6 @@ pub const link_hash_implementation_version = 10;
23712378
23722379fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifest) !void {
23732380 const gpa = comp.gpa;
2374 const target = comp.getTarget();
23752381
23762382 var arena_allocator = std.heap.ArenaAllocator.init(gpa);
23772383 defer arena_allocator.deinit();
......@@ -2432,6 +2438,7 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes
24322438 man.hash.add(comp.include_compiler_rt);
24332439 if (comp.config.link_libc) {
24342440 man.hash.add(comp.libc_installation != null);
2441 const target = comp.root_mod.resolved_target.result;
24352442 if (comp.libc_installation) |libc_installation| {
24362443 man.hash.addOptionalBytes(libc_installation.crt_dir);
24372444 if (target.abi == .msvc) {
src/Package.zig+10
......@@ -108,6 +108,16 @@ pub const Path = struct {
108108 return p.root_dir.handle.access(joined_path, flags);
109109 }
110110
111 pub fn makePath(p: Path, sub_path: []const u8) !void {
112 var buf: [fs.MAX_PATH_BYTES]u8 = undefined;
113 const joined_path = if (p.sub_path.len == 0) sub_path else p: {
114 break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{
115 p.sub_path, sub_path,
116 }) catch return error.NameTooLong;
117 };
118 return p.root_dir.handle.makePath(joined_path);
119 }
120
111121 pub fn format(
112122 self: Path,
113123 comptime fmt_string: []const u8,
src/Package/Module.zig+1-1
......@@ -40,7 +40,7 @@ builtin_file: ?*File,
4040pub const Deps = std.StringArrayHashMapUnmanaged(*Module);
4141
4242pub fn isBuiltin(m: Module) bool {
43 return m.file != null;
43 return m.builtin_file != null;
4444}
4545
4646pub const Tree = struct {
src/codegen/llvm.zig+10-2
......@@ -898,14 +898,22 @@ pub const Object = struct {
898898 // very location dependent.
899899 // TODO: the only concern I have with this is WASI as either host or target, should
900900 // we leave the paths as relative then?
901 // TODO: This is totally wrong. In dwarf, paths are encoded as relative to
902 // a particular directory, and then the directory path is specified elsewhere.
903 // In the compiler frontend we have it stored correctly in this
904 // way already, but here we throw all that sweet information
905 // into the garbage can by converting into absolute paths. What
906 // a terrible tragedy.
901907 const compile_unit_dir_z = blk: {
902908 if (comp.module) |zcu| m: {
903909 const d = try zcu.root_mod.root.joinStringZ(arena, "");
904910 if (d.len == 0) break :m;
905911 if (std.fs.path.isAbsolute(d)) break :blk d;
906 break :blk std.fs.realpathAlloc(arena, d) catch d;
912 const realpath = std.fs.realpathAlloc(arena, d) catch break :blk d;
913 break :blk try arena.dupeZ(u8, realpath);
907914 }
908 break :blk try std.process.getCwdAlloc(arena);
915 const cwd = try std.process.getCwdAlloc(arena);
916 break :blk try arena.dupeZ(u8, cwd);
909917 };
910918
911919 builder.llvm.di_compile_unit = builder.llvm.di_builder.?.createCompileUnit(