Skip to content

Commit 4eedf01

Browse files
committed
hosted-libc: fixes for glibc
1 parent 2f828aa commit 4eedf01

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/link/Elf.zig

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3294,8 +3294,17 @@ const CsuObjects = struct {
32943294
.static_pie => result.set( "rcrt1.o", "crti.o", "crtbeginS.o", "crtendS.o", "crtn.o" ),
32953295
// zig fmt: on
32963296
}
3297-
// Bundled glibc only has Scrt1.o .
3298-
if (result.crt0 != null and link_options.target.isGnuLibC()) result.crt0 = "Scrt1.o";
3297+
if (link_options.libc_installation) |_| {
3298+
// hosted-glibc provides crtbegin/end objects in platform/compiler-specific dirs
3299+
// and they are not known at comptime. For now null-out crtbegin/end objects;
3300+
// there is no feature loss, zig has never linked those objects in before.
3301+
// TODO: probe for paths, ie. `cc -print-file-name`
3302+
result.crtbegin = null;
3303+
result.crtend = null;
3304+
} else {
3305+
// Bundled glibc only has Scrt1.o .
3306+
if (result.crt0 != null and link_options.target.isGnuLibC()) result.crt0 = "Scrt1.o";
3307+
}
32993308
},
33003309
.dragonfly => switch (mode) {
33013310
// zig fmt: off
@@ -3359,11 +3368,7 @@ const CsuObjects = struct {
33593368
else => {
33603369
inline for (std.meta.fields(@TypeOf(result))) |f,i| {
33613370
if (@field(result, f.name)) |*obj| {
3362-
if (comp.crt_files.get(obj.*)) |crtf| {
3363-
obj.* = crtf.full_object_path;
3364-
} else {
3365-
@field(result, f.name) = null;
3366-
}
3371+
obj.* = try fs.path.join(arena, &[_][]const u8{ crt_dir_path, obj.* });
33673372
}
33683373
}
33693374
}

0 commit comments

Comments
 (0)