mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
Compilation.Config: Default to dynamic linking with FreeBSD libc.
This commit is contained in:
parent
2116f2e3b2
commit
e8992af7f0
@ -353,7 +353,9 @@ pub fn resolve(options: Options) ResolveError!Config {
|
||||
break :b .static;
|
||||
}
|
||||
if (explicitly_exe_or_dyn_lib and link_libc and
|
||||
(target_util.osRequiresLibC(target) or (target.isGnuLibC() and !options.resolved_target.is_native_abi)))
|
||||
(target_util.osRequiresLibC(target) or
|
||||
// For these libcs, Zig can only provide dynamic libc when cross-compiling.
|
||||
((target.isGnuLibC() or target.isFreeBSDLibC()) and !options.resolved_target.is_native_abi)))
|
||||
{
|
||||
if (options.link_mode == .static) return error.LibCRequiresDynamicLinking;
|
||||
break :b .dynamic;
|
||||
@ -368,14 +370,20 @@ 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.isGnuLibC() or target.isMuslLibC()))
|
||||
{
|
||||
// If targeting the system's native ABI and the system's libc is
|
||||
// glibc or musl, link dynamically by default.
|
||||
if (explicitly_exe_or_dyn_lib and link_libc) {
|
||||
// When using the native glibc/musl ABI, dynamic linking is usually what people want.
|
||||
if (options.resolved_target.is_native_abi and (target.isGnuLibC() or target.isMuslLibC())) {
|
||||
break :b .dynamic;
|
||||
}
|
||||
|
||||
// When targeting systems where the kernel and libc are developed alongside each other,
|
||||
// dynamic linking is the better default; static libc may contain code that requires
|
||||
// the very latest kernel version.
|
||||
if (target.isFreeBSDLibC()) {
|
||||
break :b .dynamic;
|
||||
}
|
||||
}
|
||||
|
||||
// Static is generally a better default. Fight me.
|
||||
break :b .static;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user