build libunwind.a from source and link it
This commit is contained in:
@@ -10,6 +10,7 @@ static Buf saved_lib_dir = BUF_INIT;
|
||||
static Buf saved_special_dir = BUF_INIT;
|
||||
static Buf saved_std_dir = BUF_INIT;
|
||||
static Buf saved_dynamic_linker_path = BUF_INIT;
|
||||
static bool searched_for_dyn_linker = false;
|
||||
|
||||
Buf *get_stage1_cache_path(void) {
|
||||
if (saved_stage1_path.list.length != 0) {
|
||||
@@ -24,6 +25,35 @@ Buf *get_stage1_cache_path(void) {
|
||||
return &saved_stage1_path;
|
||||
}
|
||||
|
||||
static void detect_dynamic_linker(Buf *lib_path) {
|
||||
#if defined(ZIG_OS_LINUX) && defined(ZIG_ARCH_X86_64)
|
||||
if (buf_ends_with_str(lib_path, "ld-linux-x86-64.so.2")) {
|
||||
buf_init_from_buf(&saved_dynamic_linker_path, lib_path);
|
||||
} else if (buf_ends_with_str(lib_path, "ld-musl-x86-64.so.1")) {
|
||||
buf_init_from_buf(&saved_dynamic_linker_path, lib_path);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Buf *get_self_dynamic_linker_path(void) {
|
||||
for (;;) {
|
||||
if (saved_dynamic_linker_path.list.length != 0) {
|
||||
return &saved_dynamic_linker_path;
|
||||
}
|
||||
if (searched_for_dyn_linker)
|
||||
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);
|
||||
detect_dynamic_linker(lib_path);
|
||||
}
|
||||
searched_for_dyn_linker = true;
|
||||
}
|
||||
}
|
||||
|
||||
Error get_compiler_id(Buf **result) {
|
||||
if (saved_compiler_id.list.length != 0) {
|
||||
*result = &saved_compiler_id;
|
||||
@@ -57,15 +87,9 @@ Error get_compiler_id(Buf **result) {
|
||||
return err;
|
||||
for (size_t i = 0; i < lib_paths.length; i += 1) {
|
||||
Buf *lib_path = lib_paths.at(i);
|
||||
detect_dynamic_linker(lib_path);
|
||||
if ((err = cache_add_file(ch, lib_path)))
|
||||
return err;
|
||||
#if defined(ZIG_OS_LINUX) && defined(ZIG_ARCH_X86_64)
|
||||
if (buf_ends_with_str(lib_path, "ld-linux-x86-64.so.2")) {
|
||||
buf_init_from_buf(&saved_dynamic_linker_path, lib_path);
|
||||
} else if (buf_ends_with_str(lib_path, "ld-musl-x86-64.so.1")) {
|
||||
buf_init_from_buf(&saved_dynamic_linker_path, lib_path);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if ((err = cache_final(ch, &saved_compiler_id)))
|
||||
return err;
|
||||
@@ -76,12 +100,6 @@ Error get_compiler_id(Buf **result) {
|
||||
return ErrorNone;
|
||||
}
|
||||
|
||||
Buf *get_self_dynamic_linker_path(void) {
|
||||
Buf *dontcare;
|
||||
(void)get_compiler_id(&dontcare); // for the side-effects of caching the dynamic linker path
|
||||
return (saved_dynamic_linker_path.list.length == 0) ? nullptr : &saved_dynamic_linker_path;
|
||||
}
|
||||
|
||||
static bool test_zig_install_prefix(Buf *test_path, Buf *out_zig_lib_dir) {
|
||||
Buf lib_buf = BUF_INIT;
|
||||
buf_init_from_str(&lib_buf, "lib");
|
||||
|
||||
Reference in New Issue
Block a user