Skip to content

Commit 69dc1a6

Browse files
committed
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
1 parent 2769215 commit 69dc1a6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/codegen/llvm.zig

+5-3
Original file line numberDiff line numberDiff line change
@@ -898,10 +898,11 @@ 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-
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
902901
const compile_unit_dir_z = blk: {
903-
if (options.module) |mod| {
902+
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
903+
if (options.module) |mod| m: {
904904
const d = try mod.root_mod.root.joinStringZ(builder.gpa, "");
905+
if (d.len == 0) break :m;
905906
if (std.fs.path.isAbsolute(d)) break :blk d;
906907
const abs = std.fs.realpath(d, &buf) catch break :blk d;
907908
builder.gpa.free(d);
@@ -1840,7 +1841,8 @@ pub const Object = struct {
18401841
const dir_path = try file.mod.root.joinStringZ(gpa, sub_path);
18411842
if (std.fs.path.isAbsolute(dir_path)) break :d dir_path;
18421843
const abs = std.fs.realpath(dir_path, &buffer) catch break :d dir_path;
1843-
break :d try std.fs.path.joinZ(gpa, &.{ abs, sub_path });
1844+
gpa.free(dir_path);
1845+
break :d try gpa.dupeZ(u8, abs);
18441846
};
18451847
defer gpa.free(dir_path_z);
18461848
const sub_file_path_z = try gpa.dupeZ(u8, std.fs.path.basename(file.sub_file_path));

0 commit comments

Comments
 (0)