Skip to content

Commit b9a124a

Browse files
committed
requested changes
- use `link_options.libc_installation == null` - null-out any objects `comp.crt_files` doesn't know about
1 parent 36113cf commit b9a124a

File tree

1 file changed

+11
-23
lines changed

1 file changed

+11
-23
lines changed

src/link/Elf.zig

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3290,11 +3290,6 @@ const CsuObjects = struct {
32903290
}
32913291
// Bundled glibc only has Scrt1.o .
32923292
if (result.crt0 != null and link_options.target.isGnuLibC()) result.crt0 = "Scrt1.o";
3293-
// Target linux does not currently support host system toolchain/libc which
3294-
// supplies crt begin/end objects so we must disable linking them.
3295-
// We leave the above switch data fully populated for future purposes.
3296-
result.crtbegin = null;
3297-
result.crtend = null;
32983293
},
32993294
.dragonfly => switch (mode) {
33003295
// zig fmt: off
@@ -3334,28 +3329,17 @@ const CsuObjects = struct {
33343329
},
33353330
else => {},
33363331
}
3337-
3338-
// Bundled { glibc, musl } do not supply begin/end objects.
3339-
if (comp.wantBuildLibCFromSource()) {
3340-
result.crtbegin = null;
3341-
result.crtend = null;
3342-
}
3343-
3344-
// Musl does not supply crti/crtn for all architectures.
3345-
if (link_options.target.isMusl() and !musl.libc_needs_crti_crtn(link_options.target)) {
3346-
result.crti = null;
3347-
result.crtn = null;
3348-
}
33493332
}
33503333

33513334
// Convert each object to a full pathname.
3352-
if (comp.wantBuildGLibCFromSource() or
3353-
comp.wantBuildMuslFromSource() or
3354-
comp.wantBuildMinGWFromSource())
3355-
{
3335+
if (link_options.libc_installation == null) {
33563336
inline for (std.meta.fields(@TypeOf(result))) |f,i| {
33573337
if (@field(result, f.name)) |*obj| {
3358-
obj.* = comp.crt_files.get(obj.*).?.full_object_path;
3338+
if (comp.crt_files.get(obj.*)) |crtf| {
3339+
obj.* = crtf.full_object_path;
3340+
} else {
3341+
@field(result, f.name) = null;
3342+
}
33593343
}
33603344
}
33613345
} else {
@@ -3380,7 +3364,11 @@ const CsuObjects = struct {
33803364
else => {
33813365
inline for (std.meta.fields(@TypeOf(result))) |f,i| {
33823366
if (@field(result, f.name)) |*obj| {
3383-
obj.* = try fs.path.join(arena, &[_][]const u8{ crt_dir_path, obj.* });
3367+
if (comp.crt_files.get(obj.*)) |crtf| {
3368+
obj.* = crtf.full_object_path;
3369+
} else {
3370+
@field(result, f.name) = null;
3371+
}
33843372
}
33853373
}
33863374
}

0 commit comments

Comments
 (0)