[arrayfire] 50/84: Add extra paths to check for unified on Linux/OSX
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Mon Jan 4 23:22:23 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch master
in repository arrayfire.
commit 1c584de84106936a1776ead3bb3ec96093fedf68
Author: Shehzan Mohammed <shehzan at arrayfire.com>
Date: Mon Dec 28 13:36:42 2015 -0500
Add extra paths to check for unified on Linux/OSX
---
src/api/unified/symbol_manager.cpp | 46 +++++++++++++++++++++++++++++++++-----
1 file changed, 41 insertions(+), 5 deletions(-)
diff --git a/src/api/unified/symbol_manager.cpp b/src/api/unified/symbol_manager.cpp
index 1139f99..0746eb9 100644
--- a/src/api/unified/symbol_manager.cpp
+++ b/src/api/unified/symbol_manager.cpp
@@ -71,18 +71,18 @@ LibHandle openDynLibrary(const int bknd_idx, int flag=RTLD_LAZY)
* * DYLD_LIBRARY_PATH (Apple)
* * PATH (Windows)
*/
- string bkndName = getBkndLibName(bknd_idx);
+ string bkndLibName = getBkndLibName(bknd_idx);
string show_flag = getEnvVar("AF_SHOW_LOAD_PATH");
bool show_load_path = show_flag=="1";
#if defined(OS_WIN)
- HMODULE retVal = LoadLibrary(bkndName.c_str());
+ HMODULE retVal = LoadLibrary(bkndLibName.c_str());
#else
- LibHandle retVal = dlopen(bkndName.c_str(), flag);
+ LibHandle retVal = dlopen(bkndLibName.c_str(), flag);
#endif
if(retVal != NULL) { // Success
if (show_load_path)
- printf("Using %s from system path\n", bkndName.c_str());
+ printf("Using %s from system path\n", bkndLibName.c_str());
} else {
/*
* In the event that dlopen returns NULL, search for the lib
@@ -94,11 +94,12 @@ LibHandle openDynLibrary(const int bknd_idx, int flag=RTLD_LAZY)
* Note: This does not guarantee successful loading as the dependent
* libraries may still not load
*/
+
for (int i=0; i<NUM_ENV_VARS; ++i) {
string abs_path = getEnvVar(LIB_AF_ENVARS[i])
+ LIB_AF_RPATHS[i]
+ (LIB_AF_RPATH_SUFFIX[i] ? LIB_AF_BKND_NAME[bknd_idx]+"/" : "")
- + bkndName;
+ + bkndLibName;
#if defined(OS_WIN)
replace(abs_path.begin(), abs_path.end(), '/', '\\');
retVal = LoadLibrary(abs_path.c_str());
@@ -114,7 +115,42 @@ LibHandle openDynLibrary(const int bknd_idx, int flag=RTLD_LAZY)
break;
}
}
+
+#if !defined(OS_WIN)
+ /*
+ * If Linux/OSX, then the following are also checked
+ * (only if lib is not found)
+ * /opt/arrayfire/lib
+ * /opt/arrayfire-3/lib
+ * /usr/local/lib
+ * /usr/local/arrayfire/lib
+ * /usr/local/arrayfire-3/lib
+ */
+ if (retVal == NULL) {
+ static const char* extraLibPaths[] = {"/opt/arrayfire-3/lib/",
+ "/opt/arrayfire/lib/",
+ "/usr/local/lib/",
+ "/usr/local/arrayfire-3/lib/",
+ "/usr/local/arrayfire/lib/",
+ };
+ const int nPaths = sizeof(extraLibPaths) / sizeof(extraLibPaths[0]);
+
+ for (int i = 0; i < nPaths; ++i) {
+ string abs_path = extraLibPaths[i] + bkndLibName;
+ retVal = dlopen(abs_path.c_str(), flag);
+ if (retVal != NULL) {
+ if (show_load_path)
+ printf("Using %s\n", abs_path.c_str());
+ // if the current absolute path based dlopen
+ // search is a success, then abandon search
+ // and proceed for compute
+ break;
+ }
+ }
+ }
+#endif
}
+
return retVal;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git
More information about the debian-science-commits
mailing list