Skip to content

Commit f6476e9

Browse files
committed
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 parent ae38575 commit f6476e9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Compilation/Config.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)