diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-09-22 23:31:32 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-09-22 23:31:32 -0700 |
| commit | fc88d36daea40b69690186730ae7f2a5296585a9 (patch) | |
| tree | 042e2a08172641866413b07b040660c55387a217 /src/Compilation.zig | |
| parent | 0638a020cf783486724d1999a4847140c6cc1442 (diff) | |
| download | zig-fc88d36daea40b69690186730ae7f2a5296585a9.tar.gz zig-fc88d36daea40b69690186730ae7f2a5296585a9.zip | |
stage2: link_libc=true on OS's that require it for syscalls
Diffstat (limited to 'src/Compilation.zig')
| -rw-r--r-- | src/Compilation.zig | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index d0f2e36080..f7ffc762aa 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -417,12 +417,14 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { return error.MachineCodeModelNotSupported; } + 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 options.link_libc and options.target.isGnuLibC()) + if (is_exe_or_dyn_lib and link_libc and options.target.isGnuLibC()) break :dl true; if (options.system_libs.len != 0) break :dl true; @@ -444,12 +446,12 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { options.zig_lib_directory.path.?, options.target, options.is_native_os, - options.link_libc, + link_libc, options.libc_installation, ); const must_pic: bool = b: { - if (target_util.requiresPIC(options.target, options.link_libc)) + if (target_util.requiresPIC(options.target, link_libc)) break :b true; break :b link_mode == .Dynamic; }; @@ -545,7 +547,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { cache.hash.add(link_mode); cache.hash.add(function_sections); cache.hash.add(options.strip); - cache.hash.add(options.link_libc); + cache.hash.add(link_libc); cache.hash.add(options.link_libcpp); cache.hash.add(options.output_mode); cache.hash.add(options.machine_code_model); @@ -676,7 +678,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { .optimize_mode = options.optimize_mode, .use_lld = use_lld, .use_llvm = use_llvm, - .link_libc = options.link_libc, + .link_libc = link_libc, .link_libcpp = options.link_libcpp, .objects = options.link_objects, .frameworks = options.frameworks, |
