commit 69dc1a6bb28dc47a57902d421c538f2f82edea8a (tree)
parent 2769215b9037bb1f407e07887d4d21957ce1a9e0
Author: Andrew Kelley <andrew@ziglang.org>
Date: Thu, 12 Oct 2023 17:41:33 -0700
llvm: fix incorrect file paths in debug info
The previous code incorrectly added `sub_path` twice.
Also for the compilation unit, it was passing empty string to realpath,
resulting in the error handling codepath being used.
closes #17482
Diffstat:
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
@@ -898,10 +898,11 @@ 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?
- var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
const compile_unit_dir_z = blk: {
- if (options.module) |mod| {
+ var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
+ if (options.module) |mod| m: {
const d = try mod.root_mod.root.joinStringZ(builder.gpa, "");
+ if (d.len == 0) break :m;
if (std.fs.path.isAbsolute(d)) break :blk d;
const abs = std.fs.realpath(d, &buf) catch break :blk d;
builder.gpa.free(d);
@@ -1840,7 +1841,8 @@ pub const Object = struct {
const dir_path = try file.mod.root.joinStringZ(gpa, sub_path);
if (std.fs.path.isAbsolute(dir_path)) break :d dir_path;
const abs = std.fs.realpath(dir_path, &buffer) catch break :d dir_path;
- break :d try std.fs.path.joinZ(gpa, &.{ abs, sub_path });
+ gpa.free(dir_path);
+ break :d try gpa.dupeZ(u8, abs);
};
defer gpa.free(dir_path_z);
const sub_file_path_z = try gpa.dupeZ(u8, std.fs.path.basename(file.sub_file_path));