From 4bdc2d38717b5655acd862a5762e069419b158c7 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 23 Oct 2024 16:26:17 -0700 Subject: [PATCH] avoid unnecessarily building Scrt1.o when cross-compiling glibc which, in this branch causes a miscompilation because it would get sent to the linker. --- src/Compilation.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Compilation.zig b/src/Compilation.zig index 3b236f80f0..fac1ad4baa 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -1795,10 +1795,12 @@ 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 }); + } try comp.queueJobs(&[_]Job{ - .{ .glibc_crt_file = .scrt1_o }, - .{ .glibc_crt_file = .libc_nonshared_a }, .{ .glibc_shared_objects = {} }, + .{ .glibc_crt_file = .libc_nonshared_a }, }); } else if (target.isWasm() and target.os.tag == .wasi) { if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable;