authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-05-03 06:31:51+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-05-03 10:54:33+02:00
logf6476e9caeadea0c0c6b18841dffcf72bffdd582
treea98db6fe820e499f4489b92c90f8ebe82a90372d
parentae38575b42e7ff6f7254c0ae1f1f0519416d83f9
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

compiler: Allow linking native glibc statically.

This is generally ill-advised, but can be useful in some niche situations where the caveats don't apply. It might also be useful when providing a libc.txt that points to Eyra.

1 files changed, 4 insertions(+), 4 deletions(-)

src/Compilation/Config.zig+4-4
......@@ -352,7 +352,7 @@ pub fn resolve(options: Options) ResolveError!Config {
352352 break :b .static;
353353 }
354354 if (explicitly_exe_or_dyn_lib and link_libc and
355 (target.isGnuLibC() or target_util.osRequiresLibC(target)))
355 (target_util.osRequiresLibC(target) or (target.isGnuLibC() and !options.resolved_target.is_native_abi)))
356356 {
357357 if (options.link_mode == .static) return error.LibCRequiresDynamicLinking;
358358 break :b .dynamic;
......@@ -367,11 +367,11 @@ pub fn resolve(options: Options) ResolveError!Config {
367367
368368 if (options.link_mode) |link_mode| break :b link_mode;
369369
370 if (explicitly_exe_or_dyn_lib and link_libc and
371 options.resolved_target.is_native_abi and target.abi.isMusl())
370 if (explicitly_exe_or_dyn_lib and link_libc and options.resolved_target.is_native_abi and
371 (target.isGnuLibC() or target.isMuslLibC()))
372372 {
373373 // If targeting the system's native ABI and the system's libc is
374 // musl, link dynamically by default.
374 // glibc or musl, link dynamically by default.
375375 break :b .dynamic;
376376 }
377377