From fc88d36daea40b69690186730ae7f2a5296585a9 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 22 Sep 2020 23:31:32 -0700 Subject: [PATCH] stage2: link_libc=true on OS's that require it for syscalls --- BRANCH_TODO | 1 + src/Compilation.zig | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/BRANCH_TODO b/BRANCH_TODO index 58cf974cb..1e0efa9a1 100644 --- a/BRANCH_TODO +++ b/BRANCH_TODO @@ -1,3 +1,4 @@ + * windows CUSTOMBUILD : error : unable to build compiler_rt: FileNotFound [D:\a\1\s\build\zig_install_lib_files.vcxproj] * separate libzigcpp.a and libzigstage1.a so that we can do non-stage1 builds * repair @cImport * make sure zig cc works diff --git a/src/Compilation.zig b/src/Compilation.zig index d0f2e3608..f7ffc762a 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,