From 199d0b90294af4fbec6890b2675c3272da0be1cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Sun, 16 Aug 2026 09:38:02 +0200 Subject: [PATCH] glibc: build Scrt1.o and libc_nonshared.a as PIC These have to be PIC; don't rely on the compiler's defaults for the target. --- src/libs/glibc.zig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libs/glibc.zig b/src/libs/glibc.zig index 86c5360cc17cce248afeac8ddcfb5bb4b2f9ceca..024588644a8c69c12fc323c4c812468abff565d1 100644 --- a/src/libs/glibc.zig +++ b/src/libs/glibc.zig @@ -243,7 +243,9 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre }; var files = [_]Compilation.CSourceFile{ start_o, abi_note_o, init_o }; const basename = if (comp.config.output_mode == .Exe and !comp.config.pie) "crt1" else "Scrt1"; - return comp.build_crt_file(basename, .Obj, .@"glibc Scrt1.o", prog_node, &files, .{}); + return comp.build_crt_file(basename, .Obj, .@"glibc Scrt1.o", prog_node, &files, .{ + .pic = true, + }); }, .libc_nonshared_a => { const s = path.sep_str; @@ -356,7 +358,9 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre files_index += 1; } const files = files_buf[0..files_index]; - return comp.build_crt_file("c_nonshared", .Lib, .@"glibc libc_nonshared.a", prog_node, files, .{}); + return comp.build_crt_file("c_nonshared", .Lib, .@"glibc libc_nonshared.a", prog_node, files, .{ + .pic = true, + }); }, } } -- 2.54.0