From b6e97e5fb5ea2db25156f634eb7b02920f54b9c5 Mon Sep 17 00:00:00 2001 From: Mitsuo Heijo Date: Wed, 30 Jun 2021 22:35:25 +0900 Subject: [PATCH] Fix DSO detection for installed with PREFIX Signed-off-by: Mitsuo Heijo --- subprocess.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/subprocess.cc b/subprocess.cc index b4941671..9e349cf4 100644 --- a/subprocess.cc +++ b/subprocess.cc @@ -263,14 +263,11 @@ void process_run_subcommand(Context &ctx, int argc, char **argv) { // Get the mold-wrapper.so path std::string self = get_self_path(ctx); std::string dso_path; - if (self == "/usr/bin/mold") - dso_path = "/usr/lib/mold/mold-wrapper.so"; - else if (self == "/usr/local/bin/mold") - dso_path = "/usr/local/lib/mold/mold-wrapper.so"; - else - dso_path = std::string(path_dirname(self)) + "/mold-wrapper.so"; + dso_path = path_clean(self+"/../../lib/mold/mold-wrapper.so"); struct stat st; + if (stat(dso_path.c_str(), &st) || (st.st_mode & S_IFMT) != S_IFREG) + dso_path = std::string(path_dirname(self)) + "/mold-wrapper.so"; if (stat(dso_path.c_str(), &st) || (st.st_mode & S_IFMT) != S_IFREG) Fatal(ctx) << dso_path << " is missing";