aboutsummaryrefslogtreecommitdiff
path: root/src/compiler.cpp
diff options
context:
space:
mode:
authorVexu <15308111+Vexu@users.noreply.github.com>2019-07-17 01:20:59 +0300
committerGitHub <noreply@github.com>2019-07-17 01:20:59 +0300
commitf8e753e19c013cc605a951e5038b4a26099aa135 (patch)
tree3cbb2ce1b8815bc565344e23a39e3d39505cfd31 /src/compiler.cpp
parent0063953d1634ce770ce88519c66e3956832ceb7e (diff)
parent158e2312ea5f680b7c8598ef578aefb6cbdd3372 (diff)
downloadzig-f8e753e19c013cc605a951e5038b4a26099aa135.tar.gz
zig-f8e753e19c013cc605a951e5038b4a26099aa135.zip
Merge branch 'master' into comment-in-array
Diffstat (limited to 'src/compiler.cpp')
-rw-r--r--src/compiler.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/compiler.cpp b/src/compiler.cpp
index 8bfe87bfcd..5d401f1851 100644
--- a/src/compiler.cpp
+++ b/src/compiler.cpp
@@ -9,9 +9,13 @@ static Buf saved_stage1_path = BUF_INIT;
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;
+static Buf saved_libc_path = BUF_INIT;
+static bool searched_for_libc = false;
+
Buf *get_stage1_cache_path(void) {
if (saved_stage1_path.list.length != 0) {
return &saved_stage1_path;
@@ -36,6 +40,28 @@ static void detect_dynamic_linker(Buf *lib_path) {
#endif
}
+const Buf *get_self_libc_path(void) {
+ 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;
+ }
+}
+
Buf *get_self_dynamic_linker_path(void) {
for (;;) {
if (saved_dynamic_linker_path.list.length != 0) {