authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2023-01-02 19:18:32-05:00
committergravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2023-01-02 19:18:32-05:00
logd78a2619bad84e47f288cecd35d35a0233c17beb
tree7ab96508d4a23660710af49d5ce96e70dbe4cb8c
parentc1f404ad537ded5a584525f7f89dcf5705a2c405
signature Commit is signed but in an unrecognized format.

link.Elf: resolve CsuObjects TODO


1 files changed, 6 insertions(+), 12 deletions(-)

src/link/Elf.zig+6-12
...@@ -3058,27 +3058,22 @@ const CsuObjects = struct {...@@ -3058,27 +3058,22 @@ const CsuObjects = struct {
30583058
3059 var result: CsuObjects = .{};3059 var result: CsuObjects = .{};
30603060
3061 // TODO: https://github.com/ziglang/zig/issues/46293061 // Flatten crt cases.
3062 // - use inline enum type3062 const mode: enum {
3063 // - reduce to enum-literals for values
3064 const Mode = enum {
3065 dynamic_lib,3063 dynamic_lib,
3066 dynamic_exe,3064 dynamic_exe,
3067 dynamic_pie,3065 dynamic_pie,
3068 static_exe,3066 static_exe,
3069 static_pie,3067 static_pie,
3070 };3068 } = switch (link_options.output_mode) {
3071
3072 // Flatten crt case types.
3073 const mode: Mode = switch (link_options.output_mode) {
3074 .Obj => return CsuObjects{},3069 .Obj => return CsuObjects{},
3075 .Lib => switch (link_options.link_mode) {3070 .Lib => switch (link_options.link_mode) {
3076 .Dynamic => Mode.dynamic_lib,3071 .Dynamic => .dynamic_lib,
3077 .Static => return CsuObjects{},3072 .Static => return CsuObjects{},
3078 },3073 },
3079 .Exe => switch (link_options.link_mode) {3074 .Exe => switch (link_options.link_mode) {
3080 .Dynamic => if (link_options.pie) Mode.dynamic_pie else Mode.dynamic_exe,3075 .Dynamic => if (link_options.pie) .dynamic_pie else .dynamic_exe,
3081 .Static => if (link_options.pie) Mode.static_pie else Mode.static_exe,3076 .Static => if (link_options.pie) .static_pie else .static_exe,
3082 },3077 },
3083 };3078 };
30843079
...@@ -3108,7 +3103,6 @@ const CsuObjects = struct {...@@ -3108,7 +3103,6 @@ const CsuObjects = struct {
3108 // hosted-glibc provides crtbegin/end objects in platform/compiler-specific dirs3103 // hosted-glibc provides crtbegin/end objects in platform/compiler-specific dirs
3109 // and they are not known at comptime. For now null-out crtbegin/end objects;3104 // and they are not known at comptime. For now null-out crtbegin/end objects;
3110 // there is no feature loss, zig has never linked those objects in before.3105 // there is no feature loss, zig has never linked those objects in before.
3111 // TODO: probe for paths, ie. `cc -print-file-name`
3112 result.crtbegin = null;3106 result.crtbegin = null;
3113 result.crtend = null;3107 result.crtend = null;
3114 } else {3108 } else {