Commit 0be97b5ae3
Changed files (5)
src
src/codegen/llvm.zig
@@ -898,14 +898,22 @@ pub const Object = struct {
// very location dependent.
// TODO: the only concern I have with this is WASI as either host or target, should
// we leave the paths as relative then?
+ // TODO: This is totally wrong. In dwarf, paths are encoded as relative to
+ // a particular directory, and then the directory path is specified elsewhere.
+ // In the compiler frontend we have it stored correctly in this
+ // way already, but here we throw all that sweet information
+ // into the garbage can by converting into absolute paths. What
+ // a terrible tragedy.
const compile_unit_dir_z = blk: {
if (comp.module) |zcu| m: {
const d = try zcu.root_mod.root.joinStringZ(arena, "");
if (d.len == 0) break :m;
if (std.fs.path.isAbsolute(d)) break :blk d;
- break :blk std.fs.realpathAlloc(arena, d) catch d;
+ const realpath = std.fs.realpathAlloc(arena, d) catch break :blk d;
+ break :blk try arena.dupeZ(u8, realpath);
}
- break :blk try std.process.getCwdAlloc(arena);
+ const cwd = try std.process.getCwdAlloc(arena);
+ break :blk try arena.dupeZ(u8, cwd);
};
builder.llvm.di_compile_unit = builder.llvm.di_builder.?.createCompileUnit(
src/Package/Module.zig
@@ -40,7 +40,7 @@ builtin_file: ?*File,
pub const Deps = std.StringArrayHashMapUnmanaged(*Module);
pub fn isBuiltin(m: Module) bool {
- return m.file != null;
+ return m.builtin_file != null;
}
pub const Tree = struct {
src/Builtin.zig
@@ -276,7 +276,7 @@ pub fn populateFile(comp: *Compilation, mod: *Module, file: *File) !void {
}
fn writeFile(file: *File, mod: *Module) !void {
- var af = try mod.root.atomicFile(mod.root_src_path, .{});
+ var af = try mod.root.atomicFile(mod.root_src_path, .{ .make_path = true });
defer af.deinit();
try af.file.writeAll(file.source);
try af.finish();
src/Compilation.zig
@@ -1119,6 +1119,11 @@ fn addModuleTableToCacheHash(
var i: usize = 0;
while (i < seen_table.count()) : (i += 1) {
const mod = seen_table.keys()[i];
+ if (mod.isBuiltin()) {
+ // Skip builtin.zig; it is useless as an input, and we don't want to
+ // have to write it before checking for a cache hit.
+ continue;
+ }
cache_helpers.addResolvedTarget(hash, mod.resolved_target);
hash.add(mod.optimize_mode);
@@ -1133,6 +1138,8 @@ fn addModuleTableToCacheHash(
hash.add(mod.red_zone);
hash.add(mod.sanitize_c);
hash.add(mod.sanitize_thread);
+ hash.add(mod.unwind_tables);
+ hash.add(mod.structured_cfg);
switch (hash_type) {
.path_bytes => {
@@ -2371,7 +2378,6 @@ pub const link_hash_implementation_version = 10;
fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifest) !void {
const gpa = comp.gpa;
- const target = comp.getTarget();
var arena_allocator = std.heap.ArenaAllocator.init(gpa);
defer arena_allocator.deinit();
@@ -2432,6 +2438,7 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes
man.hash.add(comp.include_compiler_rt);
if (comp.config.link_libc) {
man.hash.add(comp.libc_installation != null);
+ const target = comp.root_mod.resolved_target.result;
if (comp.libc_installation) |libc_installation| {
man.hash.addOptionalBytes(libc_installation.crt_dir);
if (target.abi == .msvc) {
src/Package.zig
@@ -108,6 +108,16 @@ pub const Path = struct {
return p.root_dir.handle.access(joined_path, flags);
}
+ pub fn makePath(p: Path, sub_path: []const u8) !void {
+ var buf: [fs.MAX_PATH_BYTES]u8 = undefined;
+ const joined_path = if (p.sub_path.len == 0) sub_path else p: {
+ break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{
+ p.sub_path, sub_path,
+ }) catch return error.NameTooLong;
+ };
+ return p.root_dir.handle.makePath(joined_path);
+ }
+
pub fn format(
self: Path,
comptime fmt_string: []const u8,