Commit d4f375c46b
Changed files (4)
src/compiler.cpp
@@ -4,31 +4,6 @@
#include <stdio.h>
-Buf *get_self_libc_path(void) {
- static Buf saved_libc_path = BUF_INIT;
- static bool searched_for_libc = false;
-
- for (;;) {
- if (saved_libc_path.list.length != 0) {
- return &saved_libc_path;
- }
- if (searched_for_libc)
- return nullptr;
- ZigList<Buf *> lib_paths = {};
- Error err;
- if ((err = os_self_exe_shared_libs(lib_paths)))
- return nullptr;
- for (size_t i = 0; i < lib_paths.length; i += 1) {
- Buf *lib_path = lib_paths.at(i);
- if (buf_ends_with_str(lib_path, "libc.so.6")) {
- buf_init_from_buf(&saved_libc_path, lib_path);
- return &saved_libc_path;
- }
- }
- searched_for_libc = true;
- }
-}
-
Error get_compiler_id(Buf **result) {
static Buf saved_compiler_id = BUF_INIT;
src/compiler.hpp
@@ -12,7 +12,6 @@
#include "error.hpp"
Error get_compiler_id(Buf **result);
-Buf *get_self_libc_path(void);
Buf *get_zig_lib_dir(void);
Buf *get_zig_special_dir(Buf *zig_lib_dir);
src/glibc.cpp
@@ -362,43 +362,6 @@ bool eql_glibc_target(const ZigTarget *a, const ZigTarget *b) {
a->abi == b->abi;
}
-#ifdef ZIG_OS_LINUX
-#include <unistd.h>
-Error glibc_detect_native_version(ZigGLibCVersion *glibc_ver) {
- Buf *self_libc_path = get_self_libc_path();
- if (self_libc_path == nullptr) {
- // TODO There is still more we could do to detect the native glibc version. For example,
- // we could look at the ELF file of `/usr/bin/env`, find `libc.so.6`, and then `readlink`
- // to find out the glibc version. This is relevant for the static zig builds distributed
- // on the download page, since the above detection based on zig's own dynamic linking
- // will not work.
-
- return ErrorUnknownABI;
- }
- Buf *link_name = buf_alloc();
- buf_resize(link_name, 4096);
- ssize_t amt = readlink(buf_ptr(self_libc_path), buf_ptr(link_name), buf_len(link_name));
- if (amt == -1) {
- return ErrorUnknownABI;
- }
- buf_resize(link_name, amt);
- if (!buf_starts_with_str(link_name, "libc-") || !buf_ends_with_str(link_name, ".so")) {
- return ErrorUnknownABI;
- }
- // example: "libc-2.3.4.so"
- // example: "libc-2.27.so"
- buf_resize(link_name, buf_len(link_name) - 3); // chop off ".so"
- glibc_ver->major = 2;
- glibc_ver->minor = 0;
- glibc_ver->patch = 0;
- return target_parse_glibc_version(glibc_ver, buf_ptr(link_name) + 5);
-}
-#else
-Error glibc_detect_native_version(ZigGLibCVersion *glibc_ver) {
- return ErrorUnknownABI;
-}
-#endif
-
size_t glibc_lib_count(void) {
return array_length(glibc_libs);
}
src/glibc.hpp
@@ -43,9 +43,6 @@ Error glibc_load_metadata(ZigGLibCAbi **out_result, Buf *zig_lib_dir, bool verbo
Error glibc_build_dummies_and_maps(CodeGen *codegen, const ZigGLibCAbi *glibc_abi, const ZigTarget *target,
Buf **out_dir, bool verbose, Stage2ProgressNode *progress_node);
-// returns ErrorUnknownABI when glibc is not the native libc
-Error glibc_detect_native_version(ZigGLibCVersion *glibc_ver);
-
size_t glibc_lib_count(void);
const ZigGLibCLib *glibc_lib_enum(size_t index);
const ZigGLibCLib *glibc_lib_find(const char *name);