nixpkgs/pkgs/development/libraries/rocm-runtime/rocr-ext-dir.diff
Daniël de Kok 68fecda43a rocm-runtime-ext: init at 3.5.1
This package provides the closed-source extension for rocm-runtime
that is necessary for OpenCL image processing.
2020-07-16 14:56:33 +02:00

25 lines
1.0 KiB
Diff

diff --git a/src/core/util/lnx/os_linux.cpp b/src/core/util/lnx/os_linux.cpp
index fdbe19a..42d4ef8 100644
--- a/src/core/util/lnx/os_linux.cpp
+++ b/src/core/util/lnx/os_linux.cpp
@@ -161,8 +161,17 @@ static_assert(sizeof(Mutex) == sizeof(pthread_mutex_t*), "OS abstraction size mi
static_assert(sizeof(Thread) == sizeof(os_thread*), "OS abstraction size mismatch");
LibHandle LoadLib(std::string filename) {
- void* ret = dlopen(filename.c_str(), RTLD_LAZY);
- if (ret == nullptr) debug_print("LoadLib(%s) failed: %s\n", filename.c_str(), dlerror());
+ std::string extDirFilename = GetEnvVar("ROCR_EXT_DIR") + "/" + filename;
+ void* ret = dlopen(extDirFilename.c_str(), RTLD_LAZY);
+
+ // Attempt to load from the directory hardcoded by rocrExtDir.
+ if (ret == nullptr) {
+ std::string runpathFilename = std::string("@rocrExtDir@") + "/" + filename;
+ ret = dlopen(runpathFilename.c_str(), RTLD_LAZY);
+
+ if (ret == nullptr) debug_print("LoadLib(%s) failed: %s\n", filename.c_str(), dlerror());
+ }
+
return *(LibHandle*)&ret;
}