| ... | ... | @@ -455,6 +455,7 @@ static int main0(int argc, char **argv) { |
| 455 | 455 | CodeModel code_model = CodeModelDefault; |
| 456 | 456 | const char *override_soname = nullptr; |
| 457 | 457 | bool only_preprocess = false; |
| 458 | bool ensure_libc_on_non_freestanding = false; |
| 458 | 459 | |
| 459 | 460 | ZigList<const char *> llvm_argv = {0}; |
| 460 | 461 | llvm_argv.append("zig (LLVM option parsing)"); |
| ... | ... | @@ -582,11 +583,11 @@ static int main0(int argc, char **argv) { |
| 582 | 583 | } else if (argc >= 2 && strcmp(argv[1], "cc") == 0) { |
| 583 | 584 | emit_h = false; |
| 584 | 585 | strip = true; |
| 586 | ensure_libc_on_non_freestanding = true; |
| 585 | 587 | |
| 586 | 588 | bool c_arg = false; |
| 587 | 589 | Stage2ClangArgIterator it; |
| 588 | 590 | stage2_clang_arg_iterator(&it, argc, argv); |
| 589 | | bool nostdlib = false; |
| 590 | 591 | bool is_shared_lib = false; |
| 591 | 592 | ZigList<Buf *> linker_args = {}; |
| 592 | 593 | while (it.has_next) { |
| ... | ... | @@ -645,7 +646,7 @@ static int main0(int argc, char **argv) { |
| 645 | 646 | want_pic = WantPICDisabled; |
| 646 | 647 | break; |
| 647 | 648 | case Stage2ClangArgNoStdLib: |
| 648 | | nostdlib = true; |
| 649 | ensure_libc_on_non_freestanding = false; |
| 649 | 650 | break; |
| 650 | 651 | case Stage2ClangArgShared: |
| 651 | 652 | is_dynamic = true; |
| ... | ... | @@ -772,10 +773,6 @@ static int main0(int argc, char **argv) { |
| 772 | 773 | build_mode = BuildModeSafeRelease; |
| 773 | 774 | } |
| 774 | 775 | |
| 775 | | if (!nostdlib && !have_libc) { |
| 776 | | have_libc = true; |
| 777 | | link_libs.append("c"); |
| 778 | | } |
| 779 | 776 | if (only_preprocess) { |
| 780 | 777 | cmd = CmdBuild; |
| 781 | 778 | out_type = OutTypeObj; |
| ... | ... | @@ -1216,6 +1213,11 @@ static int main0(int argc, char **argv) { |
| 1216 | 1213 | return print_error_usage(arg0); |
| 1217 | 1214 | } |
| 1218 | 1215 | |
| 1216 | if (!have_libc && ensure_libc_on_non_freestanding && target.os != OsFreestanding) { |
| 1217 | have_libc = true; |
| 1218 | link_libs.append("c"); |
| 1219 | } |
| 1220 | |
| 1219 | 1221 | Buf zig_triple_buf = BUF_INIT; |
| 1220 | 1222 | target_triple_zig(&zig_triple_buf, &target); |
| 1221 | 1223 | |