| ... | @@ -359,6 +359,10 @@ static void construct_linker_job_coff(LinkJob *lj) { | ... | @@ -359,6 +359,10 @@ static void construct_linker_job_coff(LinkJob *lj) { |
| 359 | } else if (g->windows_subsystem_console) { | 359 | } else if (g->windows_subsystem_console) { |
| 360 | lj->args.append("/SUBSYSTEM:console"); | 360 | lj->args.append("/SUBSYSTEM:console"); |
| 361 | } | 361 | } |
| | 362 | // The commented out stuff is from when we linked with MinGW |
| | 363 | // Now that we're linking with LLD it remains to be determined |
| | 364 | // how to handle --target-environ gnu |
| | 365 | // These comments are a clue |
| 362 | | 366 | |
| 363 | //bool dll = g->out_type == OutTypeLib; | 367 | //bool dll = g->out_type == OutTypeLib; |
| 364 | //bool shared = !g->is_static && dll; | 368 | //bool shared = !g->is_static && dll; |
| ... | @@ -385,7 +389,19 @@ static void construct_linker_job_coff(LinkJob *lj) { | ... | @@ -385,7 +389,19 @@ static void construct_linker_job_coff(LinkJob *lj) { |
| 385 | lj->args.append(buf_ptr(buf_sprintf("-OUT:%s", buf_ptr(&lj->out_file)))); | 389 | lj->args.append(buf_ptr(buf_sprintf("-OUT:%s", buf_ptr(&lj->out_file)))); |
| 386 | | 390 | |
| 387 | if (lj->link_in_crt) { | 391 | if (lj->link_in_crt) { |
| 388 | zig_panic("TODO link in c runtime"); | 392 | const char *lib_str = g->is_static ? "lib" : ""; |
| | 393 | const char *d_str = (g->build_mode == BuildModeDebug) ? "d" : ""; |
| | 394 | |
| | 395 | Buf *cmt_lib_name = buf_sprintf("libcmt%s.lib", d_str); |
| | 396 | lj->args.append(buf_ptr(cmt_lib_name)); |
| | 397 | |
| | 398 | Buf *vcruntime_lib_name = buf_sprintf("%svcruntime%s.lib", lib_str, d_str); |
| | 399 | lj->args.append(buf_ptr(vcruntime_lib_name)); |
| | 400 | |
| | 401 | Buf *crt_lib_name = buf_sprintf("%sucrt%s.lib", lib_str, d_str); |
| | 402 | lj->args.append(buf_ptr(crt_lib_name)); |
| | 403 | |
| | 404 | |
| 389 | //if (shared || dll) { | 405 | //if (shared || dll) { |
| 390 | // lj->args.append(get_libc_file(g, "dllcrt2.o")); | 406 | // lj->args.append(get_libc_file(g, "dllcrt2.o")); |
| 391 | //} else { | 407 | //} else { |
| ... | @@ -468,54 +484,54 @@ static void construct_linker_job_coff(LinkJob *lj) { | ... | @@ -468,54 +484,54 @@ static void construct_linker_job_coff(LinkJob *lj) { |
| 468 | } | 484 | } |
| 469 | } | 485 | } |
| 470 | | 486 | |
| 471 | if (g->libc_link_lib != nullptr) { | 487 | //if (g->libc_link_lib != nullptr) { |
| 472 | if (g->is_static) { | 488 | //if (g->is_static) { |
| 473 | lj->args.append("--start-group"); | 489 | // lj->args.append("--start-group"); |
| 474 | } | 490 | //} |
| 475 | | 491 | |
| 476 | lj->args.append("-lmingw32"); | 492 | //lj->args.append("-lmingw32"); |
| 477 | | 493 | |
| 478 | lj->args.append("-lgcc"); | 494 | //lj->args.append("-lgcc"); |
| 479 | bool is_android = (g->zig_target.env_type == ZigLLVM_Android); | 495 | //bool is_android = (g->zig_target.env_type == ZigLLVM_Android); |
| 480 | bool is_cyg_ming = is_target_cyg_mingw(&g->zig_target); | 496 | //bool is_cyg_ming = is_target_cyg_mingw(&g->zig_target); |
| 481 | if (!g->is_static && !is_android) { | 497 | //if (!g->is_static && !is_android) { |
| 482 | if (!is_cyg_ming) { | 498 | // if (!is_cyg_ming) { |
| 483 | lj->args.append("--as-needed"); | 499 | // lj->args.append("--as-needed"); |
| 484 | } | 500 | // } |
| 485 | //lj->args.append("-lgcc_s"); | 501 | // //lj->args.append("-lgcc_s"); |
| 486 | if (!is_cyg_ming) { | 502 | // if (!is_cyg_ming) { |
| 487 | lj->args.append("--no-as-needed"); | 503 | // lj->args.append("--no-as-needed"); |
| 488 | } | 504 | // } |
| 489 | } | 505 | //} |
| 490 | if (g->is_static && !is_android) { | 506 | //if (g->is_static && !is_android) { |
| 491 | //lj->args.append("-lgcc_eh"); | 507 | // //lj->args.append("-lgcc_eh"); |
| 492 | } | 508 | //} |
| 493 | if (is_android && !g->is_static) { | 509 | //if (is_android && !g->is_static) { |
| 494 | lj->args.append("-ldl"); | 510 | // lj->args.append("-ldl"); |
| 495 | } | 511 | //} |
| 496 | | 512 | |
| 497 | lj->args.append("-lmoldname"); | 513 | //lj->args.append("-lmoldname"); |
| 498 | lj->args.append("-lmingwex"); | 514 | //lj->args.append("-lmingwex"); |
| 499 | lj->args.append("-lmsvcrt"); | 515 | //lj->args.append("-lmsvcrt"); |
| 500 | | 516 | |
| 501 | | 517 | |
| 502 | if (g->windows_subsystem_windows) { | 518 | //if (g->windows_subsystem_windows) { |
| 503 | lj->args.append("-lgdi32"); | 519 | // lj->args.append("-lgdi32"); |
| 504 | lj->args.append("-lcomdlg32"); | 520 | // lj->args.append("-lcomdlg32"); |
| 505 | } | 521 | //} |
| 506 | lj->args.append("-ladvapi32"); | 522 | //lj->args.append("-ladvapi32"); |
| 507 | lj->args.append("-lshell32"); | 523 | //lj->args.append("-lshell32"); |
| 508 | lj->args.append("-luser32"); | 524 | //lj->args.append("-luser32"); |
| 509 | lj->args.append("-lkernel32"); | 525 | //lj->args.append("-lkernel32"); |
| 510 | | 526 | |
| 511 | if (g->is_static) { | 527 | //if (g->is_static) { |
| 512 | lj->args.append("--end-group"); | 528 | // lj->args.append("--end-group"); |
| 513 | } | 529 | //} |
| 514 | | 530 | |
| 515 | if (lj->link_in_crt) { | 531 | //if (lj->link_in_crt) { |
| 516 | lj->args.append(get_libc_static_file(g, "crtend.o")); | 532 | // lj->args.append(get_libc_static_file(g, "crtend.o")); |
| 517 | } | 533 | //} |
| 518 | } | 534 | //} |
| 519 | } | 535 | } |
| 520 | | 536 | |
| 521 | | 537 | |