| author | |
| committer | |
| log | 0be97b5ae3d32ca9cd7fbb68d5972538b48d8c76 |
| tree | d0f1d642243f9cecb35ef481844c959151e9942d |
| parent | d71e6273b6acd766eea6c37b8f53ae03cb2bd9f6 |
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 { | ... | @@ -276,7 +276,7 @@ pub fn populateFile(comp: *Compilation, mod: *Module, file: *File) !void { |
| 276 | } | 276 | } |
| 277 | 277 | ||
| 278 | fn writeFile(file: *File, mod: *Module) !void { | 278 | fn 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 }); |
| 280 | defer af.deinit(); | 280 | defer af.deinit(); |
| 281 | try af.file.writeAll(file.source); | 281 | try af.file.writeAll(file.source); |
| 282 | try af.finish(); | 282 | try af.finish(); |
src/Compilation.zig+8-1| ... | @@ -1119,6 +1119,11 @@ fn addModuleTableToCacheHash( | ... | @@ -1119,6 +1119,11 @@ fn addModuleTableToCacheHash( |
| 1119 | var i: usize = 0; | 1119 | var i: usize = 0; |
| 1120 | while (i < seen_table.count()) : (i += 1) { | 1120 | while (i < seen_table.count()) : (i += 1) { |
| 1121 | const mod = seen_table.keys()[i]; | 1121 | 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 | } | ||
| 1122 | 1127 | ||
| 1123 | cache_helpers.addResolvedTarget(hash, mod.resolved_target); | 1128 | cache_helpers.addResolvedTarget(hash, mod.resolved_target); |
| 1124 | hash.add(mod.optimize_mode); | 1129 | hash.add(mod.optimize_mode); |
| ... | @@ -1133,6 +1138,8 @@ fn addModuleTableToCacheHash( | ... | @@ -1133,6 +1138,8 @@ fn addModuleTableToCacheHash( |
| 1133 | hash.add(mod.red_zone); | 1138 | hash.add(mod.red_zone); |
| 1134 | hash.add(mod.sanitize_c); | 1139 | hash.add(mod.sanitize_c); |
| 1135 | hash.add(mod.sanitize_thread); | 1140 | hash.add(mod.sanitize_thread); |
| 1141 | hash.add(mod.unwind_tables); | ||
| 1142 | hash.add(mod.structured_cfg); | ||
| 1136 | 1143 | ||
| 1137 | switch (hash_type) { | 1144 | switch (hash_type) { |
| 1138 | .path_bytes => { | 1145 | .path_bytes => { |
| ... | @@ -2371,7 +2378,6 @@ pub const link_hash_implementation_version = 10; | ... | @@ -2371,7 +2378,6 @@ pub const link_hash_implementation_version = 10; |
| 2371 | 2378 | ||
| 2372 | fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifest) !void { | 2379 | fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifest) !void { |
| 2373 | const gpa = comp.gpa; | 2380 | const gpa = comp.gpa; |
| 2374 | const target = comp.getTarget(); | ||
| 2375 | 2381 | ||
| 2376 | var arena_allocator = std.heap.ArenaAllocator.init(gpa); | 2382 | var arena_allocator = std.heap.ArenaAllocator.init(gpa); |
| 2377 | defer arena_allocator.deinit(); | 2383 | defer arena_allocator.deinit(); |
| ... | @@ -2432,6 +2438,7 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes | ... | @@ -2432,6 +2438,7 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes |
| 2432 | man.hash.add(comp.include_compiler_rt); | 2438 | man.hash.add(comp.include_compiler_rt); |
| 2433 | if (comp.config.link_libc) { | 2439 | if (comp.config.link_libc) { |
| 2434 | man.hash.add(comp.libc_installation != null); | 2440 | man.hash.add(comp.libc_installation != null); |
| 2441 | const target = comp.root_mod.resolved_target.result; | ||
| 2435 | if (comp.libc_installation) |libc_installation| { | 2442 | if (comp.libc_installation) |libc_installation| { |
| 2436 | man.hash.addOptionalBytes(libc_installation.crt_dir); | 2443 | man.hash.addOptionalBytes(libc_installation.crt_dir); |
| 2437 | if (target.abi == .msvc) { | 2444 | if (target.abi == .msvc) { |
src/Package.zig+10| ... | @@ -108,6 +108,16 @@ pub const Path = struct { | ... | @@ -108,6 +108,16 @@ pub const Path = struct { |
| 108 | return p.root_dir.handle.access(joined_path, flags); | 108 | return p.root_dir.handle.access(joined_path, flags); |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 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 | |||
| 111 | pub fn format( | 121 | pub fn format( |
| 112 | self: Path, | 122 | self: Path, |
| 113 | comptime fmt_string: []const u8, | 123 | comptime fmt_string: []const u8, |
src/Package/Module.zig+1-1| ... | @@ -40,7 +40,7 @@ builtin_file: ?*File, | ... | @@ -40,7 +40,7 @@ builtin_file: ?*File, |
| 40 | pub const Deps = std.StringArrayHashMapUnmanaged(*Module); | 40 | pub const Deps = std.StringArrayHashMapUnmanaged(*Module); |
| 41 | 41 | ||
| 42 | pub fn isBuiltin(m: Module) bool { | 42 | pub fn isBuiltin(m: Module) bool { |
| 43 | return m.file != null; | 43 | return m.builtin_file != null; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | pub const Tree = struct { | 46 | pub const Tree = struct { |
src/codegen/llvm.zig+10-2| ... | @@ -898,14 +898,22 @@ pub const Object = struct { | ... | @@ -898,14 +898,22 @@ pub const Object = struct { |
| 898 | // very location dependent. | 898 | // very location dependent. |
| 899 | // TODO: the only concern I have with this is WASI as either host or target, should | 899 | // TODO: the only concern I have with this is WASI as either host or target, should |
| 900 | // we leave the paths as relative then? | 900 | // 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. | ||
| 901 | const compile_unit_dir_z = blk: { | 907 | const compile_unit_dir_z = blk: { |
| 902 | if (comp.module) |zcu| m: { | 908 | if (comp.module) |zcu| m: { |
| 903 | const d = try zcu.root_mod.root.joinStringZ(arena, ""); | 909 | const d = try zcu.root_mod.root.joinStringZ(arena, ""); |
| 904 | if (d.len == 0) break :m; | 910 | if (d.len == 0) break :m; |
| 905 | if (std.fs.path.isAbsolute(d)) break :blk d; | 911 | 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); | ||
| 907 | } | 914 | } |
| 908 | break :blk try std.process.getCwdAlloc(arena); | 915 | const cwd = try std.process.getCwdAlloc(arena); |
| 916 | break :blk try arena.dupeZ(u8, cwd); | ||
| 909 | }; | 917 | }; |
| 910 | 918 | ||
| 911 | builder.llvm.di_compile_unit = builder.llvm.di_builder.?.createCompileUnit( | 919 | builder.llvm.di_compile_unit = builder.llvm.di_builder.?.createCompileUnit( |