diff options
| author | Alex Rønne Petersen <alex@alexrp.com> | 2024-11-02 11:58:23 +0100 |
|---|---|---|
| committer | Alex Rønne Petersen <alex@alexrp.com> | 2024-11-03 09:29:33 +0100 |
| commit | 3a2647b7d3b68fe32bab488f1fa8eaa1ec57f31a (patch) | |
| tree | fd4b38ab1feb288b58ec6588246d2e9c91b942dc /src | |
| parent | 4c70aea460d0cf4a5c1f77ec662837680e272220 (diff) | |
| download | zig-3a2647b7d3b68fe32bab488f1fa8eaa1ec57f31a.tar.gz zig-3a2647b7d3b68fe32bab488f1fa8eaa1ec57f31a.zip | |
glibc: Don't build CRT objects that won't be used.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Compilation.zig | 4 | ||||
| -rw-r--r-- | src/glibc.zig | 7 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index 6d7097e5fa..51877d7973 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -1795,8 +1795,8 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil .{ .glibc_crt_file = .crtn_o }, }); } - if (!is_dyn_lib) { - try comp.queueJob(.{ .glibc_crt_file = .scrt1_o }); + if (glibc.needsCrt0(comp.config.output_mode)) |f| { + try comp.queueJobs(&.{.{ .glibc_crt_file = f }}); } try comp.queueJobs(&[_]Job{ .{ .glibc_shared_objects = {} }, diff --git a/src/glibc.zig b/src/glibc.zig index 588c3af004..df37deed64 100644 --- a/src/glibc.zig +++ b/src/glibc.zig @@ -1357,3 +1357,10 @@ pub fn needsCrtiCrtn(target: std.Target) bool { else => true, }; } + +pub fn needsCrt0(output_mode: std.builtin.OutputMode) ?CrtFile { + return switch (output_mode) { + .Obj, .Lib => null, + .Exe => .scrt1_o, + }; +} |
