authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-22 23:31:32-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-22 23:31:32-07:00
logfc88d36daea40b69690186730ae7f2a5296585a9
tree042e2a08172641866413b07b040660c55387a217
parent0638a020cf783486724d1999a4847140c6cc1442

stage2: link_libc=true on OS's that require it for syscalls


2 files changed, 8 insertions(+), 5 deletions(-)

BRANCH_TODO+1
......@@ -1,3 +1,4 @@
1 * windows CUSTOMBUILD : error : unable to build compiler_rt: FileNotFound [D:\a\1\s\build\zig_install_lib_files.vcxproj]
12 * separate libzigcpp.a and libzigstage1.a so that we can do non-stage1 builds
23 * repair @cImport
34 * make sure zig cc works
src/Compilation.zig+7-5
......@@ -417,12 +417,14 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
417417 return error.MachineCodeModelNotSupported;
418418 }
419419
420 const link_libc = options.link_libc or target_util.osRequiresLibC(options.target);
421
420422 const must_dynamic_link = dl: {
421423 if (target_util.cannotDynamicLink(options.target))
422424 break :dl false;
423425 if (target_util.osRequiresLibC(options.target))
424426 break :dl true;
425 if (is_exe_or_dyn_lib and options.link_libc and options.target.isGnuLibC())
427 if (is_exe_or_dyn_lib and link_libc and options.target.isGnuLibC())
426428 break :dl true;
427429 if (options.system_libs.len != 0)
428430 break :dl true;
......@@ -444,12 +446,12 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
444446 options.zig_lib_directory.path.?,
445447 options.target,
446448 options.is_native_os,
447 options.link_libc,
449 link_libc,
448450 options.libc_installation,
449451 );
450452
451453 const must_pic: bool = b: {
452 if (target_util.requiresPIC(options.target, options.link_libc))
454 if (target_util.requiresPIC(options.target, link_libc))
453455 break :b true;
454456 break :b link_mode == .Dynamic;
455457 };
......@@ -545,7 +547,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
545547 cache.hash.add(link_mode);
546548 cache.hash.add(function_sections);
547549 cache.hash.add(options.strip);
548 cache.hash.add(options.link_libc);
550 cache.hash.add(link_libc);
549551 cache.hash.add(options.link_libcpp);
550552 cache.hash.add(options.output_mode);
551553 cache.hash.add(options.machine_code_model);
......@@ -676,7 +678,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
676678 .optimize_mode = options.optimize_mode,
677679 .use_lld = use_lld,
678680 .use_llvm = use_llvm,
679 .link_libc = options.link_libc,
681 .link_libc = link_libc,
680682 .link_libcpp = options.link_libcpp,
681683 .objects = options.link_objects,
682684 .frameworks = options.frameworks,