aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation
diff options
context:
space:
mode:
authorAlex Rønne Petersen <alex@alexrp.com>2025-05-03 06:31:51 +0200
committerAlex Rønne Petersen <alex@alexrp.com>2025-05-03 10:54:33 +0200
commitf6476e9caeadea0c0c6b18841dffcf72bffdd582 (patch)
treea98db6fe820e499f4489b92c90f8ebe82a90372d /src/Compilation
parentae38575b42e7ff6f7254c0ae1f1f0519416d83f9 (diff)
downloadzig-f6476e9caeadea0c0c6b18841dffcf72bffdd582.tar.gz
zig-f6476e9caeadea0c0c6b18841dffcf72bffdd582.zip
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.
Diffstat (limited to 'src/Compilation')
-rw-r--r--src/Compilation/Config.zig8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Compilation/Config.zig b/src/Compilation/Config.zig
index 5019f47ebf..1de0d83aa7 100644
--- a/src/Compilation/Config.zig
+++ b/src/Compilation/Config.zig
@@ -352,7 +352,7 @@ pub fn resolve(options: Options) ResolveError!Config {
break :b .static;
}
if (explicitly_exe_or_dyn_lib and link_libc and
- (target.isGnuLibC() or target_util.osRequiresLibC(target)))
+ (target_util.osRequiresLibC(target) or (target.isGnuLibC() and !options.resolved_target.is_native_abi)))
{
if (options.link_mode == .static) return error.LibCRequiresDynamicLinking;
break :b .dynamic;
@@ -367,11 +367,11 @@ pub fn resolve(options: Options) ResolveError!Config {
if (options.link_mode) |link_mode| break :b link_mode;
- if (explicitly_exe_or_dyn_lib and link_libc and
- options.resolved_target.is_native_abi and target.abi.isMusl())
+ if (explicitly_exe_or_dyn_lib and link_libc and options.resolved_target.is_native_abi and
+ (target.isGnuLibC() or target.isMuslLibC()))
{
// If targeting the system's native ABI and the system's libc is
- // musl, link dynamically by default.
+ // glibc or musl, link dynamically by default.
break :b .dynamic;
}