diff options
Diffstat (limited to 'src/libc_installation.cpp')
| -rw-r--r-- | src/libc_installation.cpp | 106 |
1 files changed, 6 insertions, 100 deletions
diff --git a/src/libc_installation.cpp b/src/libc_installation.cpp index 8be704887a..8a293af82a 100644 --- a/src/libc_installation.cpp +++ b/src/libc_installation.cpp @@ -14,11 +14,8 @@ static const char *zig_libc_keys[] = { "include_dir", "sys_include_dir", "crt_dir", - "lib_dir", - "static_lib_dir", "msvc_lib_dir", "kernel32_lib_dir", - "dynamic_linker_path", }; static const size_t zig_libc_keys_len = array_length(zig_libc_keys); @@ -37,11 +34,8 @@ static void zig_libc_init_empty(ZigLibCInstallation *libc) { buf_init_from_str(&libc->include_dir, ""); buf_init_from_str(&libc->sys_include_dir, ""); buf_init_from_str(&libc->crt_dir, ""); - buf_init_from_str(&libc->lib_dir, ""); - buf_init_from_str(&libc->static_lib_dir, ""); buf_init_from_str(&libc->msvc_lib_dir, ""); buf_init_from_str(&libc->kernel32_lib_dir, ""); - buf_init_from_str(&libc->dynamic_linker_path, ""); } Error zig_libc_parse(ZigLibCInstallation *libc, Buf *libc_file, const ZigTarget *target, bool verbose) { @@ -80,11 +74,8 @@ Error zig_libc_parse(ZigLibCInstallation *libc, Buf *libc_file, const ZigTarget match = match || zig_libc_match_key(name, value, found_keys, 0, &libc->include_dir); match = match || zig_libc_match_key(name, value, found_keys, 1, &libc->sys_include_dir); match = match || zig_libc_match_key(name, value, found_keys, 2, &libc->crt_dir); - match = match || zig_libc_match_key(name, value, found_keys, 3, &libc->lib_dir); - match = match || zig_libc_match_key(name, value, found_keys, 4, &libc->static_lib_dir); - match = match || zig_libc_match_key(name, value, found_keys, 5, &libc->msvc_lib_dir); - match = match || zig_libc_match_key(name, value, found_keys, 6, &libc->kernel32_lib_dir); - match = match || zig_libc_match_key(name, value, found_keys, 7, &libc->dynamic_linker_path); + match = match || zig_libc_match_key(name, value, found_keys, 3, &libc->msvc_lib_dir); + match = match || zig_libc_match_key(name, value, found_keys, 4, &libc->kernel32_lib_dir); } for (size_t i = 0; i < zig_libc_keys_len; i += 1) { @@ -119,24 +110,6 @@ Error zig_libc_parse(ZigLibCInstallation *libc, Buf *libc_file, const ZigTarget } } - if (buf_len(&libc->lib_dir) == 0) { - if (!target_is_darwin(target) && target->os != OsWindows) { - if (verbose) { - fprintf(stderr, "lib_dir may not be empty for %s\n", target_os_name(target->os)); - } - return ErrorSemanticAnalyzeFail; - } - } - - if (buf_len(&libc->static_lib_dir) == 0) { - if (!target_is_darwin(target) && target->os != OsWindows) { - if (verbose) { - fprintf(stderr, "static_lib_dir may not be empty for %s\n", target_os_name(target->os)); - } - return ErrorSemanticAnalyzeFail; - } - } - if (buf_len(&libc->msvc_lib_dir) == 0) { if (target->os == OsWindows) { if (verbose) { @@ -155,15 +128,6 @@ Error zig_libc_parse(ZigLibCInstallation *libc, Buf *libc_file, const ZigTarget } } - if (buf_len(&libc->dynamic_linker_path) == 0) { - if (!target_is_darwin(target) && target->os != OsWindows) { - if (verbose) { - fprintf(stderr, "dynamic_linker_path may not be empty for %s\n", target_os_name(target->os)); - } - return ErrorSemanticAnalyzeFail; - } - } - return ErrorNone; } @@ -325,8 +289,8 @@ static Error zig_libc_find_native_include_dir_posix(ZigLibCInstallation *self, b } return ErrorFileNotFound; } -#if !defined(ZIG_OS_DARWIN) && !defined(ZIG_OS_FREEBSD) && !defined(ZIG_OS_NETBSD) -static Error zig_libc_cc_print_file_name(const char *o_file, Buf *out, bool want_dirname, bool verbose) { +#if defined(ZIG_OS_LINUX) +Error zig_libc_cc_print_file_name(const char *o_file, Buf *out, bool want_dirname, bool verbose) { const char *cc_exe = getenv("CC"); cc_exe = (cc_exe == nullptr) ? "cc" : cc_exe; ZigList<const char *> args = {}; @@ -363,40 +327,7 @@ static Error zig_libc_cc_print_file_name(const char *o_file, Buf *out, bool want static Error zig_libc_find_native_crt_dir_posix(ZigLibCInstallation *self, bool verbose) { return zig_libc_cc_print_file_name("crt1.o", &self->crt_dir, true, verbose); } -static Error zig_libc_find_native_lib_dir_posix(ZigLibCInstallation *self, bool verbose) { - return zig_libc_cc_print_file_name("libgcc_s.so", &self->lib_dir, true, verbose); -} - -static Error zig_libc_find_native_static_lib_dir_posix(ZigLibCInstallation *self, bool verbose) { - return zig_libc_cc_print_file_name("crtbegin.o", &self->static_lib_dir, true, verbose); -} #endif - -static Error zig_libc_find_native_dynamic_linker_posix(ZigLibCInstallation *self, bool verbose) { -#if defined(ZIG_OS_LINUX) - Error err; - static const char *dyn_tests[] = { - "ld-linux-x86-64.so.2", - "ld-musl-x86_64.so.1", - }; - for (size_t i = 0; i < array_length(dyn_tests); i += 1) { - const char *lib_name = dyn_tests[i]; - if ((err = zig_libc_cc_print_file_name(lib_name, &self->dynamic_linker_path, false, true))) { - if (err != ErrorCCompilerCannotFindFile) - return err; - continue; - } - return ErrorNone; - } -#endif - ZigTarget native_target; - get_native_target(&native_target); - const char *dynamic_linker_path = target_dynamic_linker(&native_target); - if (dynamic_linker_path != nullptr) { - buf_init_from_str(&self->dynamic_linker_path, dynamic_linker_path); - } - return ErrorNone; -} #endif void zig_libc_render(ZigLibCInstallation *self, FILE *file) { @@ -414,16 +345,6 @@ void zig_libc_render(ZigLibCInstallation *self, FILE *file) { "# Not needed when targeting MacOS.\n" "crt_dir=%s\n" "\n" - "# The directory that contains `libgcc_s.so`.\n" - "# On POSIX, can be found with `cc -print-file-name=libgcc_s.so`.\n" - "# Not needed when targeting MacOS or Windows.\n" - "lib_dir=%s\n" - "\n" - "# The directory that contains `crtbegin.o`.\n" - "# On POSIX, can be found with `cc -print-file-name=crtbegin.o`.\n" - "# Not needed when targeting MacOS or Windows.\n" - "static_lib_dir=%s\n" - "\n" "# The directory that contains `vcruntime.lib`.\n" "# Only needed when targeting Windows.\n" "msvc_lib_dir=%s\n" @@ -432,19 +353,12 @@ void zig_libc_render(ZigLibCInstallation *self, FILE *file) { "# Only needed when targeting Windows.\n" "kernel32_lib_dir=%s\n" "\n" - "# The full path to the dynamic linker, on the target system.\n" - "# Not needed when targeting MacOS or Windows.\n" - "dynamic_linker_path=%s\n" - "\n" , buf_ptr(&self->include_dir), buf_ptr(&self->sys_include_dir), buf_ptr(&self->crt_dir), - buf_ptr(&self->lib_dir), - buf_ptr(&self->static_lib_dir), buf_ptr(&self->msvc_lib_dir), - buf_ptr(&self->kernel32_lib_dir), - buf_ptr(&self->dynamic_linker_path) + buf_ptr(&self->kernel32_lib_dir) ); } @@ -481,18 +395,10 @@ Error zig_libc_find_native(ZigLibCInstallation *self, bool verbose) { return err; #if defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) buf_init_from_str(&self->crt_dir, "/usr/lib"); - buf_init_from_str(&self->lib_dir, "/usr/lib"); - buf_init_from_str(&self->static_lib_dir, "/usr/lib"); -#elif !defined(ZIG_OS_DARWIN) +#elif defined(ZIG_OS_LINUX) if ((err = zig_libc_find_native_crt_dir_posix(self, verbose))) return err; - if ((err = zig_libc_find_native_lib_dir_posix(self, verbose))) - return err; - if ((err = zig_libc_find_native_static_lib_dir_posix(self, verbose))) - return err; #endif - if ((err = zig_libc_find_native_dynamic_linker_posix(self, verbose))) - return err; return ErrorNone; #endif } |
