link.Elf: resolve CsuObjects TODO

This commit is contained in:
Michael Dusan
2023-01-02 19:18:32 -05:00
parent c1f404ad53
commit d78a2619ba

View File

@@ -3058,27 +3058,22 @@ const CsuObjects = struct {
var result: CsuObjects = .{};
// TODO: https://github.com/ziglang/zig/issues/4629
// - use inline enum type
// - reduce to enum-literals for values
const Mode = enum {
// Flatten crt cases.
const mode: enum {
dynamic_lib,
dynamic_exe,
dynamic_pie,
static_exe,
static_pie,
};
// Flatten crt case types.
const mode: Mode = switch (link_options.output_mode) {
} = switch (link_options.output_mode) {
.Obj => return CsuObjects{},
.Lib => switch (link_options.link_mode) {
.Dynamic => Mode.dynamic_lib,
.Dynamic => .dynamic_lib,
.Static => return CsuObjects{},
},
.Exe => switch (link_options.link_mode) {
.Dynamic => if (link_options.pie) Mode.dynamic_pie else Mode.dynamic_exe,
.Static => if (link_options.pie) Mode.static_pie else Mode.static_exe,
.Dynamic => if (link_options.pie) .dynamic_pie else .dynamic_exe,
.Static => if (link_options.pie) .static_pie else .static_exe,
},
};
@@ -3108,7 +3103,6 @@ const CsuObjects = struct {
// hosted-glibc provides crtbegin/end objects in platform/compiler-specific dirs
// and they are not known at comptime. For now null-out crtbegin/end objects;
// there is no feature loss, zig has never linked those objects in before.
// TODO: probe for paths, ie. `cc -print-file-name`
result.crtbegin = null;
result.crtend = null;
} else {