diff options
author | Alexander Monakov <amonakov@ispras.ru> | 2013-10-16 20:51:47 +0400 |
---|---|---|
committer | Alexander Monakov <amonakov@ispras.ru> | 2013-10-16 20:51:47 +0400 |
commit | 3f9c2ecf18d8fa37fad5a7062f80952692eaa8e7 (patch) | |
tree | 95f2d9c3e7c37d5655f811b8082afcb1f012320f /cli | |
parent | 1e20dc18f72de1002d4e5243f98137810d11eec8 (diff) |
cli: use $LIB to handle multilib automagically on glibc
Diffstat (limited to 'cli')
-rw-r--r-- | cli/cli_resources.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cli/cli_resources.cpp b/cli/cli_resources.cpp index a4797e11..d6d0a55d 100644 --- a/cli/cli_resources.cpp +++ b/cli/cli_resources.cpp @@ -32,6 +32,27 @@ #include "cli_resources.hpp" +#ifdef __GLIBC__ + +#include <dlfcn.h> + +static bool +tryLib(const os::String &path, bool verbose) +{ + void *handle = dlopen(path.str(), RTLD_LAZY); + bool exists = (handle != NULL); + if (verbose) { + if (exists) { + std::cerr << "info: found " << path.str() << "\n"; + } else { + std::cerr << "info: did not find " << dlerror() << "\n"; + } + } + if (exists) + dlclose(handle); + return exists; +} +#endif static bool tryPath(const os::String &path, bool verbose) @@ -93,6 +114,17 @@ findWrapper(const char *wrapperFilename, bool verbose) return wrapperPath; } +#ifdef __GLIBC__ + // We want to take advantage of $LIB dynamic string token expansion in + // glibc dynamic linker to handle multilib layout for us + wrapperPath = processDir; + wrapperPath.join("../$LIB/apitrace/wrappers"); + wrapperPath.join(wrapperFilename); + if (tryLib(wrapperPath, verbose)) { + return wrapperPath; + } +#endif + // Try relative install directory wrapperPath = processDir; #if defined(_WIN32) |