| ... | ... | @@ -359,6 +359,10 @@ static void construct_linker_job_coff(LinkJob *lj) { |
| 359 | 359 | } else if (g->windows_subsystem_console) { |
| 360 | 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 | 367 | //bool dll = g->out_type == OutTypeLib; |
| 364 | 368 | //bool shared = !g->is_static && dll; |
| ... | ... | @@ -385,7 +389,19 @@ static void construct_linker_job_coff(LinkJob *lj) { |
| 385 | 389 | lj->args.append(buf_ptr(buf_sprintf("-OUT:%s", buf_ptr(&lj->out_file)))); |
| 386 | 390 | |
| 387 | 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 | 405 | //if (shared || dll) { |
| 390 | 406 | // lj->args.append(get_libc_file(g, "dllcrt2.o")); |
| 391 | 407 | //} else { |
| ... | ... | @@ -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) { |
| 472 | | if (g->is_static) { |
| 473 | | lj->args.append("--start-group"); |
| 474 | | } |
| 487 | //if (g->libc_link_lib != nullptr) { |
| 488 | //if (g->is_static) { |
| 489 | // lj->args.append("--start-group"); |
| 490 | //} |
| 475 | 491 | |
| 476 | | lj->args.append("-lmingw32"); |
| 492 | //lj->args.append("-lmingw32"); |
| 477 | 493 | |
| 478 | | lj->args.append("-lgcc"); |
| 479 | | bool is_android = (g->zig_target.env_type == ZigLLVM_Android); |
| 480 | | bool is_cyg_ming = is_target_cyg_mingw(&g->zig_target); |
| 481 | | if (!g->is_static && !is_android) { |
| 482 | | if (!is_cyg_ming) { |
| 483 | | lj->args.append("--as-needed"); |
| 484 | | } |
| 485 | | //lj->args.append("-lgcc_s"); |
| 486 | | if (!is_cyg_ming) { |
| 487 | | lj->args.append("--no-as-needed"); |
| 488 | | } |
| 489 | | } |
| 490 | | if (g->is_static && !is_android) { |
| 491 | | //lj->args.append("-lgcc_eh"); |
| 492 | | } |
| 493 | | if (is_android && !g->is_static) { |
| 494 | | lj->args.append("-ldl"); |
| 495 | | } |
| 494 | //lj->args.append("-lgcc"); |
| 495 | //bool is_android = (g->zig_target.env_type == ZigLLVM_Android); |
| 496 | //bool is_cyg_ming = is_target_cyg_mingw(&g->zig_target); |
| 497 | //if (!g->is_static && !is_android) { |
| 498 | // if (!is_cyg_ming) { |
| 499 | // lj->args.append("--as-needed"); |
| 500 | // } |
| 501 | // //lj->args.append("-lgcc_s"); |
| 502 | // if (!is_cyg_ming) { |
| 503 | // lj->args.append("--no-as-needed"); |
| 504 | // } |
| 505 | //} |
| 506 | //if (g->is_static && !is_android) { |
| 507 | // //lj->args.append("-lgcc_eh"); |
| 508 | //} |
| 509 | //if (is_android && !g->is_static) { |
| 510 | // lj->args.append("-ldl"); |
| 511 | //} |
| 496 | 512 | |
| 497 | | lj->args.append("-lmoldname"); |
| 498 | | lj->args.append("-lmingwex"); |
| 499 | | lj->args.append("-lmsvcrt"); |
| 513 | //lj->args.append("-lmoldname"); |
| 514 | //lj->args.append("-lmingwex"); |
| 515 | //lj->args.append("-lmsvcrt"); |
| 500 | 516 | |
| 501 | 517 | |
| 502 | | if (g->windows_subsystem_windows) { |
| 503 | | lj->args.append("-lgdi32"); |
| 504 | | lj->args.append("-lcomdlg32"); |
| 505 | | } |
| 506 | | lj->args.append("-ladvapi32"); |
| 507 | | lj->args.append("-lshell32"); |
| 508 | | lj->args.append("-luser32"); |
| 509 | | lj->args.append("-lkernel32"); |
| 518 | //if (g->windows_subsystem_windows) { |
| 519 | // lj->args.append("-lgdi32"); |
| 520 | // lj->args.append("-lcomdlg32"); |
| 521 | //} |
| 522 | //lj->args.append("-ladvapi32"); |
| 523 | //lj->args.append("-lshell32"); |
| 524 | //lj->args.append("-luser32"); |
| 525 | //lj->args.append("-lkernel32"); |
| 510 | 526 | |
| 511 | | if (g->is_static) { |
| 512 | | lj->args.append("--end-group"); |
| 513 | | } |
| 527 | //if (g->is_static) { |
| 528 | // lj->args.append("--end-group"); |
| 529 | //} |
| 514 | 530 | |
| 515 | | if (lj->link_in_crt) { |
| 516 | | lj->args.append(get_libc_static_file(g, "crtend.o")); |
| 517 | | } |
| 518 | | } |
| 531 | //if (lj->link_in_crt) { |
| 532 | // lj->args.append(get_libc_static_file(g, "crtend.o")); |
| 533 | //} |
| 534 | //} |
| 519 | 535 | } |
| 520 | 536 | |
| 521 | 537 | |