File tree Expand file tree Collapse file tree 2 files changed +25
-8
lines changed Expand file tree Collapse file tree 2 files changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -296,6 +296,15 @@ Specific environment variables can be set to control the behavior of unified run
296
296
297
297
This environment variable is ignored when :envvar: `UR_ADAPTERS_FORCE_LOAD ` environment variable is used.
298
298
299
+ .. envvar :: UR_ADAPTERS_DEEP_BIND
300
+
301
+ If set, the loader will use `RTLD_DEEPBIND ` when opening adapter libraries. This might be useful if an adapter
302
+ requires a different version of a shared library compared to the rest of the applcation.
303
+
304
+ .. note ::
305
+
306
+ This environment variable is Linux-only.
307
+
299
308
.. envvar :: UR_ENABLE_LAYERS
300
309
301
310
Holds a comma-separated list of layers to enable in addition to any specified via ``urInit ``.
Original file line number Diff line number Diff line change 12
12
#include " logger/ur_logger.hpp"
13
13
#include " ur_lib_loader.hpp"
14
14
15
- #if defined(SANITIZER_ANY) || defined(__APPLE__)
16
- #define LOAD_DRIVER_LIBRARY (NAME ) dlopen(NAME, RTLD_LAZY | RTLD_LOCAL)
17
- #else
18
- #define LOAD_DRIVER_LIBRARY (NAME ) \
19
- dlopen (NAME, RTLD_LAZY | RTLD_LOCAL | RTLD_DEEPBIND)
20
- #endif
15
+ #define DEEP_BIND_ENV " UR_ADAPTERS_DEEP_BIND"
21
16
22
17
namespace ur_loader {
23
18
@@ -34,8 +29,21 @@ void LibLoader::freeAdapterLibrary(HMODULE handle) {
34
29
35
30
std::unique_ptr<HMODULE, LibLoader::lib_dtor>
36
31
LibLoader::loadAdapterLibrary (const char *name) {
37
- return std::unique_ptr<HMODULE, LibLoader::lib_dtor>(
38
- LOAD_DRIVER_LIBRARY (name));
32
+ int mode = RTLD_LAZY | RTLD_LOCAL;
33
+ #if !defined(__APPLE__)
34
+ bool deepbind = getenv_tobool (DEEP_BIND_ENV);
35
+ if (deepbind) {
36
+ #if defined(SANITIZER_ANY)
37
+ logger::warning (
38
+ " Enabling RTLD_DEEPBIND while running under a sanitizer is likely "
39
+ " to cause issues. Consider disabling {} environment variable." ,
40
+ DEEP_BIND_ENV);
41
+ #endif
42
+ mode |= RTLD_DEEPBIND;
43
+ }
44
+ #endif
45
+
46
+ return std::unique_ptr<HMODULE, LibLoader::lib_dtor>(dlopen (name, mode));
39
47
}
40
48
41
49
void *LibLoader::getFunctionPtr (HMODULE handle, const char *func_name) {
You can’t perform that action at this time.
0 commit comments