X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=cli%2Fcli_resources.cpp;h=d6d0a55d6d5038fe773c41a163934f93f88bf3bf;hb=d6b7eb6b7c8280762fb635a6e63aa3a426694ed7;hp=a4797e11d414e0b41a35ec2d43c65e74d5714550;hpb=f73c1f8becb425336f6bf1b42cb7ea3fc121949d;p=apitrace diff --git a/cli/cli_resources.cpp b/cli/cli_resources.cpp index a4797e1..d6d0a55 100644 --- a/cli/cli_resources.cpp +++ b/cli/cli_resources.cpp @@ -32,6 +32,27 @@ #include "cli_resources.hpp" +#ifdef __GLIBC__ + +#include + +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)