aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-09-26 01:58:16 -0700
committerAndrew Kelley <andrew@ziglang.org>2020-09-26 01:58:16 -0700
commit819625d2740838ad10440f4af04200a38b5c65e2 (patch)
treeb2fbe9a4c38d7debe0af61d6c6709a8998b8eabe /src/Compilation.zig
parent6af2990549709ec5e2bc1efeb5090a944f1a8bdf (diff)
downloadzig-819625d2740838ad10440f4af04200a38b5c65e2.tar.gz
zig-819625d2740838ad10440f4af04200a38b5c65e2.zip
fix logic for choosing when dynamic linking is required
When building object files or static libraries, link_mode can still be static even if the OS needs libc for syscalls.
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index d831403497..f51ea74d56 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -454,16 +454,16 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
break :blk false;
};
- const link_libc = options.link_libc or
- (is_exe_or_dyn_lib and target_util.osRequiresLibC(options.target));
+ const link_libc = options.link_libc or target_util.osRequiresLibC(options.target);
const must_dynamic_link = dl: {
if (target_util.cannotDynamicLink(options.target))
break :dl false;
- if (target_util.osRequiresLibC(options.target))
- break :dl true;
- if (is_exe_or_dyn_lib and link_libc and options.target.isGnuLibC())
+ if (is_exe_or_dyn_lib and link_libc and
+ (options.target.isGnuLibC() or target_util.osRequiresLibC(options.target)))
+ {
break :dl true;
+ }
if (options.system_libs.len != 0)
break :dl true;