| author | |
| committer | |
| log | 0d10ab0680c8cd0c75bf6f6cc7d4a153ac742db8 |
| tree | 80ece3404adc10e93c68eb97913b5529ac80dcec |
| parent | dd263eccb716ba167fdad5bb3a4544dace6bf6a1 |
| signature | Commit is signed but in an unrecognized format. |
4 files changed, 3 insertions(+), 175 deletions(-)
src/codegen.cpp-2| ... | ... | @@ -9027,8 +9027,6 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) { |
| 9027 | 9027 | cache_buf(ch, &g->libc->include_dir); |
| 9028 | 9028 | cache_buf(ch, &g->libc->sys_include_dir); |
| 9029 | 9029 | cache_buf(ch, &g->libc->crt_dir); |
| 9030 | cache_buf(ch, &g->libc->lib_dir); | |
| 9031 | cache_buf(ch, &g->libc->static_lib_dir); | |
| 9032 | 9030 | cache_buf(ch, &g->libc->msvc_lib_dir); |
| 9033 | 9031 | cache_buf(ch, &g->libc->kernel32_lib_dir); |
| 9034 | 9032 | cache_buf(ch, &g->libc->dynamic_linker_path); |
src/libc_installation.cpp+3-52| ... | ... | @@ -14,8 +14,6 @@ static const char *zig_libc_keys[] = { |
| 14 | 14 | "include_dir", |
| 15 | 15 | "sys_include_dir", |
| 16 | 16 | "crt_dir", |
| 17 | "lib_dir", | |
| 18 | "static_lib_dir", | |
| 19 | 17 | "msvc_lib_dir", |
| 20 | 18 | "kernel32_lib_dir", |
| 21 | 19 | "dynamic_linker_path", |
| ... | ... | @@ -37,8 +35,6 @@ static void zig_libc_init_empty(ZigLibCInstallation *libc) { |
| 37 | 35 | buf_init_from_str(&libc->include_dir, ""); |
| 38 | 36 | buf_init_from_str(&libc->sys_include_dir, ""); |
| 39 | 37 | buf_init_from_str(&libc->crt_dir, ""); |
| 40 | buf_init_from_str(&libc->lib_dir, ""); | |
| 41 | buf_init_from_str(&libc->static_lib_dir, ""); | |
| 42 | 38 | buf_init_from_str(&libc->msvc_lib_dir, ""); |
| 43 | 39 | buf_init_from_str(&libc->kernel32_lib_dir, ""); |
| 44 | 40 | buf_init_from_str(&libc->dynamic_linker_path, ""); |
| ... | ... | @@ -80,11 +76,9 @@ Error zig_libc_parse(ZigLibCInstallation *libc, Buf *libc_file, const ZigTarget |
| 80 | 76 | match = match || zig_libc_match_key(name, value, found_keys, 0, &libc->include_dir); |
| 81 | 77 | match = match || zig_libc_match_key(name, value, found_keys, 1, &libc->sys_include_dir); |
| 82 | 78 | match = match || zig_libc_match_key(name, value, found_keys, 2, &libc->crt_dir); |
| 83 | match = match || zig_libc_match_key(name, value, found_keys, 3, &libc->lib_dir); | |
| 84 | match = match || zig_libc_match_key(name, value, found_keys, 4, &libc->static_lib_dir); | |
| 85 | match = match || zig_libc_match_key(name, value, found_keys, 5, &libc->msvc_lib_dir); | |
| 86 | match = match || zig_libc_match_key(name, value, found_keys, 6, &libc->kernel32_lib_dir); | |
| 87 | match = match || zig_libc_match_key(name, value, found_keys, 7, &libc->dynamic_linker_path); | |
| 79 | match = match || zig_libc_match_key(name, value, found_keys, 3, &libc->msvc_lib_dir); | |
| 80 | match = match || zig_libc_match_key(name, value, found_keys, 4, &libc->kernel32_lib_dir); | |
| 81 | match = match || zig_libc_match_key(name, value, found_keys, 5, &libc->dynamic_linker_path); | |
| 88 | 82 | } |
| 89 | 83 | |
| 90 | 84 | for (size_t i = 0; i < zig_libc_keys_len; i += 1) { |
| ... | ... | @@ -119,24 +113,6 @@ Error zig_libc_parse(ZigLibCInstallation *libc, Buf *libc_file, const ZigTarget |
| 119 | 113 | } |
| 120 | 114 | } |
| 121 | 115 | |
| 122 | if (buf_len(&libc->lib_dir) == 0) { | |
| 123 | if (!target_is_darwin(target) && target->os != OsWindows) { | |
| 124 | if (verbose) { | |
| 125 | fprintf(stderr, "lib_dir may not be empty for %s\n", target_os_name(target->os)); | |
| 126 | } | |
| 127 | return ErrorSemanticAnalyzeFail; | |
| 128 | } | |
| 129 | } | |
| 130 | ||
| 131 | if (buf_len(&libc->static_lib_dir) == 0) { | |
| 132 | if (!target_is_darwin(target) && target->os != OsWindows) { | |
| 133 | if (verbose) { | |
| 134 | fprintf(stderr, "static_lib_dir may not be empty for %s\n", target_os_name(target->os)); | |
| 135 | } | |
| 136 | return ErrorSemanticAnalyzeFail; | |
| 137 | } | |
| 138 | } | |
| 139 | ||
| 140 | 116 | if (buf_len(&libc->msvc_lib_dir) == 0) { |
| 141 | 117 | if (target->os == OsWindows) { |
| 142 | 118 | if (verbose) { |
| ... | ... | @@ -363,13 +339,6 @@ static Error zig_libc_cc_print_file_name(const char *o_file, Buf *out, bool want |
| 363 | 339 | static Error zig_libc_find_native_crt_dir_posix(ZigLibCInstallation *self, bool verbose) { |
| 364 | 340 | return zig_libc_cc_print_file_name("crt1.o", &self->crt_dir, true, verbose); |
| 365 | 341 | } |
| 366 | static Error zig_libc_find_native_lib_dir_posix(ZigLibCInstallation *self, bool verbose) { | |
| 367 | return zig_libc_cc_print_file_name("libgcc_s.so", &self->lib_dir, true, verbose); | |
| 368 | } | |
| 369 | ||
| 370 | static Error zig_libc_find_native_static_lib_dir_posix(ZigLibCInstallation *self, bool verbose) { | |
| 371 | return zig_libc_cc_print_file_name("crtbegin.o", &self->static_lib_dir, true, verbose); | |
| 372 | } | |
| 373 | 342 | #endif |
| 374 | 343 | |
| 375 | 344 | static Error zig_libc_find_native_dynamic_linker_posix(ZigLibCInstallation *self, bool verbose) { |
| ... | ... | @@ -414,16 +383,6 @@ void zig_libc_render(ZigLibCInstallation *self, FILE *file) { |
| 414 | 383 | "# Not needed when targeting MacOS.\n" |
| 415 | 384 | "crt_dir=%s\n" |
| 416 | 385 | "\n" |
| 417 | "# The directory that contains `libgcc_s.so`.\n" | |
| 418 | "# On POSIX, can be found with `cc -print-file-name=libgcc_s.so`.\n" | |
| 419 | "# Not needed when targeting MacOS or Windows.\n" | |
| 420 | "lib_dir=%s\n" | |
| 421 | "\n" | |
| 422 | "# The directory that contains `crtbegin.o`.\n" | |
| 423 | "# On POSIX, can be found with `cc -print-file-name=crtbegin.o`.\n" | |
| 424 | "# Not needed when targeting MacOS or Windows.\n" | |
| 425 | "static_lib_dir=%s\n" | |
| 426 | "\n" | |
| 427 | 386 | "# The directory that contains `vcruntime.lib`.\n" |
| 428 | 387 | "# Only needed when targeting Windows.\n" |
| 429 | 388 | "msvc_lib_dir=%s\n" |
| ... | ... | @@ -440,8 +399,6 @@ void zig_libc_render(ZigLibCInstallation *self, FILE *file) { |
| 440 | 399 | buf_ptr(&self->include_dir), |
| 441 | 400 | buf_ptr(&self->sys_include_dir), |
| 442 | 401 | buf_ptr(&self->crt_dir), |
| 443 | buf_ptr(&self->lib_dir), | |
| 444 | buf_ptr(&self->static_lib_dir), | |
| 445 | 402 | buf_ptr(&self->msvc_lib_dir), |
| 446 | 403 | buf_ptr(&self->kernel32_lib_dir), |
| 447 | 404 | buf_ptr(&self->dynamic_linker_path) |
| ... | ... | @@ -481,15 +438,9 @@ Error zig_libc_find_native(ZigLibCInstallation *self, bool verbose) { |
| 481 | 438 | return err; |
| 482 | 439 | #if defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) |
| 483 | 440 | buf_init_from_str(&self->crt_dir, "/usr/lib"); |
| 484 | buf_init_from_str(&self->lib_dir, "/usr/lib"); | |
| 485 | buf_init_from_str(&self->static_lib_dir, "/usr/lib"); | |
| 486 | 441 | #elif !defined(ZIG_OS_DARWIN) |
| 487 | 442 | if ((err = zig_libc_find_native_crt_dir_posix(self, verbose))) |
| 488 | 443 | return err; |
| 489 | if ((err = zig_libc_find_native_lib_dir_posix(self, verbose))) | |
| 490 | return err; | |
| 491 | if ((err = zig_libc_find_native_static_lib_dir_posix(self, verbose))) | |
| 492 | return err; | |
| 493 | 444 | #endif |
| 494 | 445 | if ((err = zig_libc_find_native_dynamic_linker_posix(self, verbose))) |
| 495 | 446 | return err; |
src/libc_installation.hpp-2| ... | ... | @@ -19,8 +19,6 @@ struct ZigLibCInstallation { |
| 19 | 19 | Buf include_dir; |
| 20 | 20 | Buf sys_include_dir; |
| 21 | 21 | Buf crt_dir; |
| 22 | Buf lib_dir; | |
| 23 | Buf static_lib_dir; | |
| 24 | 22 | Buf msvc_lib_dir; |
| 25 | 23 | Buf kernel32_lib_dir; |
| 26 | 24 | Buf dynamic_linker_path; |
src/link.cpp-119| ... | ... | @@ -305,13 +305,6 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file) { |
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | static const char *get_libc_static_file(CodeGen *g, const char *file) { | |
| 309 | assert(g->libc != nullptr); | |
| 310 | Buf *out_buf = buf_alloc(); | |
| 311 | os_path_join(&g->libc->static_lib_dir, buf_create_from_str(file), out_buf); | |
| 312 | return buf_ptr(out_buf); | |
| 313 | } | |
| 314 | ||
| 315 | 308 | static Buf *build_a_raw(CodeGen *parent_gen, const char *aname, Buf *full_path) { |
| 316 | 309 | // The Mach-O LLD code is not well maintained, and trips an assertion |
| 317 | 310 | // when we link compiler_rt and builtin as libraries rather than objects. |
| ... | ... | @@ -432,11 +425,6 @@ static void add_rpath(LinkJob *lj, Buf *rpath) { |
| 432 | 425 | lj->rpath_table.put(rpath, true); |
| 433 | 426 | } |
| 434 | 427 | |
| 435 | // TODO: try to get away with completely removing this functionality | |
| 436 | static bool want_gcc_objects(CodeGen *g) { | |
| 437 | return g->libc != nullptr && buf_len(&g->libc->static_lib_dir) != 0; | |
| 438 | } | |
| 439 | ||
| 440 | 428 | static void construct_linker_job_elf(LinkJob *lj) { |
| 441 | 429 | CodeGen *g = lj->codegen; |
| 442 | 430 | |
| ... | ... | @@ -480,22 +468,15 @@ static void construct_linker_job_elf(LinkJob *lj) { |
| 480 | 468 | |
| 481 | 469 | if (lj->link_in_crt) { |
| 482 | 470 | const char *crt1o; |
| 483 | const char *crtbegino; | |
| 484 | 471 | if (g->zig_target->os == OsNetBSD) { |
| 485 | 472 | crt1o = "crt0.o"; |
| 486 | crtbegino = "crtbegin.o"; | |
| 487 | 473 | } else if (g->is_static) { |
| 488 | 474 | crt1o = "crt1.o"; |
| 489 | crtbegino = "crtbeginT.o"; | |
| 490 | 475 | } else { |
| 491 | 476 | crt1o = "Scrt1.o"; |
| 492 | crtbegino = "crtbegin.o"; | |
| 493 | 477 | } |
| 494 | 478 | lj->args.append(get_libc_crt_file(g, crt1o)); |
| 495 | 479 | lj->args.append(get_libc_crt_file(g, "crti.o")); |
| 496 | if (want_gcc_objects(g)) { | |
| 497 | lj->args.append(get_libc_static_file(g, crtbegino)); | |
| 498 | } | |
| 499 | 480 | } |
| 500 | 481 | |
| 501 | 482 | for (size_t i = 0; i < g->rpath_list.length; i += 1) { |
| ... | ... | @@ -533,14 +514,6 @@ static void construct_linker_job_elf(LinkJob *lj) { |
| 533 | 514 | if (g->libc != nullptr) { |
| 534 | 515 | lj->args.append("-L"); |
| 535 | 516 | lj->args.append(buf_ptr(&g->libc->crt_dir)); |
| 536 | ||
| 537 | if (!buf_eql_buf(&g->libc->crt_dir, &g->libc->lib_dir)) { | |
| 538 | lj->args.append("-L"); | |
| 539 | lj->args.append(buf_ptr(&g->libc->lib_dir)); | |
| 540 | } | |
| 541 | ||
| 542 | lj->args.append("-L"); | |
| 543 | lj->args.append(buf_ptr(&g->libc->static_lib_dir)); | |
| 544 | 517 | } |
| 545 | 518 | |
| 546 | 519 | if (!g->is_static) { |
| ... | ... | @@ -624,9 +597,6 @@ static void construct_linker_job_elf(LinkJob *lj) { |
| 624 | 597 | |
| 625 | 598 | // crt end |
| 626 | 599 | if (lj->link_in_crt) { |
| 627 | if (want_gcc_objects(g)) { | |
| 628 | lj->args.append(get_libc_static_file(g, "crtend.o")); | |
| 629 | } | |
| 630 | 600 | lj->args.append(get_libc_crt_file(g, "crtn.o")); |
| 631 | 601 | } |
| 632 | 602 | |
| ... | ... | @@ -731,95 +701,6 @@ static void add_nt_link_args(LinkJob *lj, bool is_library) { |
| 731 | 701 | } |
| 732 | 702 | } |
| 733 | 703 | |
| 734 | // These are n actual command lines from LINK.EXE UEFI builds (app & driver) to be used as guidance cleaning | |
| 735 | // up a bit for building the COFF linker args: | |
| 736 | // /OUT:"J:\coding\nebulae\k\x64\Release\k.efi" /LTCG:incremental /Driver /PDB:"J:\coding\nebulae\k\x64\Release\k.pdb" "UefiApplicationEntryPoint.lib" "UefiRuntimeLib.lib" "UefiHiiLib.lib" "UefiHiiServicesLib.lib" "UefiSortLib.lib" "UefiShellLib.lib" "GlueLib.lib" "BaseLib.lib" "BaseDebugPrintErrorLevelLib.lib" "BasePrintLib.lib" "UefiLib.lib" "UefiBootServicesTableLib.lib" "UefiRuntimeServicesTableLib.lib" "UefiDevicePathLibDevicePathProtocol.lib" "UefiDebugLibConOut.lib" "UefiMemoryLib.lib" "UefiMemoryAllocationLib.lib" "BaseSynchronizationLib.lib" "UefiFileHandleLib.lib" /IMPLIB:"J:\coding\nebulae\k\x64\Release\k.lib" /DEBUG:FASTLINK /BASE:"0" /MACHINE:X64 /ENTRY:"EfiMain" /OPT:REF /SAFESEH:NO /SUBSYSTEM:EFI_APPLICATION /MERGE:".rdata=.data" /NOLOGO /ALIGN:32 /NODEFAULTLIB /SECTION:".xdata,D" | |
| 737 | // /OUT:"J:\coding\VisualUefi\samples\x64\Release\UefiDriver.efi" /LTCG:incremental /Driver /PDB:"J:\coding\VisualUefi\samples\x64\Release\UefiDriver.pdb" "UefiDriverEntryPoint.lib" "UefiHiiLib.lib" "UefiHiiServicesLib.lib" "UefiSortLib.lib" "UefiShellLib.lib" "GlueLib.lib" "BaseLib.lib" "BaseDebugPrintErrorLevelLib.lib" "BasePrintLib.lib" "UefiLib.lib" "UefiBootServicesTableLib.lib" "UefiRuntimeServicesTableLib.lib" "UefiDevicePathLibDevicePathProtocol.lib" "UefiDebugLibConOut.lib" "UefiMemoryLib.lib" "UefiMemoryAllocationLib.lib" "BaseSynchronizationLib.lib" "UefiFileHandleLib.lib" /IMPLIB:"J:\coding\VisualUefi\samples\x64\Release\UefiDriver.lib" /DEBUG:FASTLINK /BASE:"0" /MACHINE:X64 /ENTRY:"EfiMain" /OPT:REF /SAFESEH:NO /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /MERGE:".rdata=.data" /NOLOGO /ALIGN:32 /NODEFAULTLIB /SECTION:".xdata,D" | |
| 738 | // This commented out stuff is from when we linked with MinGW | |
| 739 | // Now that we're linking with LLD it remains to be determined | |
| 740 | // how to handle --target-environ gnu | |
| 741 | // These comments are a clue | |
| 742 | //bool dll = g->out_type == OutTypeLib; | |
| 743 | //bool shared = !g->is_static && dll; | |
| 744 | //if (g->is_static) { | |
| 745 | // lj->args.append("-Bstatic"); | |
| 746 | //} else { | |
| 747 | // if (dll) { | |
| 748 | // lj->args.append("--dll"); | |
| 749 | // } else if (shared) { | |
| 750 | // lj->args.append("--shared"); | |
| 751 | // } | |
| 752 | // lj->args.append("-Bdynamic"); | |
| 753 | // if (dll || shared) { | |
| 754 | // lj->args.append("-e"); | |
| 755 | // if (g->zig_target.arch == ZigLLVM_x86) { | |
| 756 | // lj->args.append("_DllMainCRTStartup@12"); | |
| 757 | // } else { | |
| 758 | // lj->args.append("DllMainCRTStartup"); | |
| 759 | // } | |
| 760 | // lj->args.append("--enable-auto-image-base"); | |
| 761 | // } | |
| 762 | //} | |
| 763 | //if (shared || dll) { | |
| 764 | // lj->args.append(get_libc_file(g, "dllcrt2.o")); | |
| 765 | //} else { | |
| 766 | // if (g->windows_linker_unicode) { | |
| 767 | // lj->args.append(get_libc_file(g, "crt2u.o")); | |
| 768 | // } else { | |
| 769 | // lj->args.append(get_libc_file(g, "crt2.o")); | |
| 770 | // } | |
| 771 | //} | |
| 772 | //lj->args.append(get_libc_static_file(g, "crtbegin.o")); | |
| 773 | //if (g->libc_link_lib != nullptr) { | |
| 774 | //if (g->is_static) { | |
| 775 | // lj->args.append("--start-group"); | |
| 776 | //} | |
| 777 | ||
| 778 | //lj->args.append("-lmingw32"); | |
| 779 | ||
| 780 | //lj->args.append("-lgcc"); | |
| 781 | //bool is_android = (g->zig_target.abi == ZigLLVM_Android); | |
| 782 | //bool is_cyg_ming = is_target_cyg_mingw(&g->zig_target); | |
| 783 | //if (!g->is_static && !is_android) { | |
| 784 | // if (!is_cyg_ming) { | |
| 785 | // lj->args.append("--as-needed"); | |
| 786 | // } | |
| 787 | // //lj->args.append("-lgcc_s"); | |
| 788 | // if (!is_cyg_ming) { | |
| 789 | // lj->args.append("--no-as-needed"); | |
| 790 | // } | |
| 791 | //} | |
| 792 | //if (g->is_static && !is_android) { | |
| 793 | // //lj->args.append("-lgcc_eh"); | |
| 794 | //} | |
| 795 | //if (is_android && !g->is_static) { | |
| 796 | // lj->args.append("-ldl"); | |
| 797 | //} | |
| 798 | ||
| 799 | //lj->args.append("-lmoldname"); | |
| 800 | //lj->args.append("-lmingwex"); | |
| 801 | //lj->args.append("-lmsvcrt"); | |
| 802 | ||
| 803 | ||
| 804 | //if (g->windows_subsystem_windows) { | |
| 805 | // lj->args.append("-lgdi32"); | |
| 806 | // lj->args.append("-lcomdlg32"); | |
| 807 | //} | |
| 808 | //lj->args.append("-ladvapi32"); | |
| 809 | //lj->args.append("-lshell32"); | |
| 810 | //lj->args.append("-luser32"); | |
| 811 | //lj->args.append("-lkernel32"); | |
| 812 | ||
| 813 | //if (g->is_static) { | |
| 814 | // lj->args.append("--end-group"); | |
| 815 | //} | |
| 816 | ||
| 817 | //if (lj->link_in_crt) { | |
| 818 | // lj->args.append(get_libc_static_file(g, "crtend.o")); | |
| 819 | //} | |
| 820 | //} | |
| 821 | ||
| 822 | ||
| 823 | 704 | static void construct_linker_job_coff(LinkJob *lj) { |
| 824 | 705 | CodeGen *g = lj->codegen; |
| 825 | 706 |