authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-11-02 11:58:23+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-11-03 09:29:33+01:00
log3a2647b7d3b68fe32bab488f1fa8eaa1ec57f31a
treefd4b38ab1feb288b58ec6588246d2e9c91b942dc
parent4c70aea460d0cf4a5c1f77ec662837680e272220
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

glibc: Don't build CRT objects that won't be used.


2 files changed, 9 insertions(+), 2 deletions(-)

src/Compilation.zig+2-2
...@@ -1795,8 +1795,8 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil...@@ -1795,8 +1795,8 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
1795 .{ .glibc_crt_file = .crtn_o },1795 .{ .glibc_crt_file = .crtn_o },
1796 });1796 });
1797 }1797 }
1798 if (!is_dyn_lib) {1798 if (glibc.needsCrt0(comp.config.output_mode)) |f| {
1799 try comp.queueJob(.{ .glibc_crt_file = .scrt1_o });1799 try comp.queueJobs(&.{.{ .glibc_crt_file = f }});
1800 }1800 }
1801 try comp.queueJobs(&[_]Job{1801 try comp.queueJobs(&[_]Job{
1802 .{ .glibc_shared_objects = {} },1802 .{ .glibc_shared_objects = {} },
src/glibc.zig+7
...@@ -1357,3 +1357,10 @@ pub fn needsCrtiCrtn(target: std.Target) bool {...@@ -1357,3 +1357,10 @@ pub fn needsCrtiCrtn(target: std.Target) bool {
1357 else => true,1357 else => true,
1358 };1358 };
1359}1359}
1360
1361pub fn needsCrt0(output_mode: std.builtin.OutputMode) ?CrtFile {
1362 return switch (output_mode) {
1363 .Obj, .Lib => null,
1364 .Exe => .scrt1_o,
1365 };
1366}