natefoo / slurm-drmaa

DRMAA for Slurm: Implementation of the DRMAA C bindings for Slurm
GNU General Public License v3.0
48 stars 22 forks source link

RPM installs libdrmaa.so in /usr/lib64, but sets DRMAA_LIBRARY_PATH to /usr/lib/ #53

Open kcgthb opened 3 years ago

kcgthb commented 3 years ago

Hi!

Using the provided SPEC file (CentOS 7.x, x86_64), it looks like the generated RPM installs libdrmaa.so in /usr/lib64:

$ rpm -ql slurm-drmaa
/usr/bin/drmaa-run
/usr/bin/drmaa-run-bulk
/usr/bin/hpc-bash
/usr/include/drmaa.h
/usr/lib64/libdrmaa.a
/usr/lib64/libdrmaa.la
/usr/lib64/libdrmaa.so
/usr/lib64/libdrmaa.so.1
/usr/lib64/libdrmaa.so.1.0.8
/usr/share/doc/slurm-drmaa-1.1.2
/usr/share/doc/slurm-drmaa-1.1.2/COPYING
/usr/share/doc/slurm-drmaa-1.1.2/NEWS
/usr/share/doc/slurm-drmaa-1.1.2/README.md
/usr/share/doc/slurm-drmaa-1.1.2/slurm_drmaa.conf.example

But DRMAA_LIBRARY_PATH defaults to /usr/lib/libdrmaa.so:

$ drmaa-run
F #1d7bd [     0.00]  * Could not load DRMAA library (DRMAA_LIBRARY_PATH=/usr/lib/libdrmaa.so)
F #1d7bd [     0.00]  * Error

and:

$ strace -e open drmaa-run
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/libdrmaa.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/etc/localtime", O_RDONLY|O_CLOEXEC) = 3
F #1d7c5 [     0.00]  * Could not load DRMAA library (DRMAA_LIBRARY_PATH=/usr/lib/libdrmaa.so)
F #1d7c5 [     0.00]  * Error
+++ exited with 255 +++

Would there be a way to make the default DRMAA_LIBRARY_PATH consistent with the RPM installation?

richc-admin-gcai commented 2 years ago

I think this just needs another #if #else branch to check if the machine is 64 or 32 bit.

Internally I've applied the following patches which fixes this at compile time on CentOS, but it might make more sense to check at runtime for number of bits and is file exists, as Ubuntu uses /usr/lib and CentOS uses /usr/lib64.

Alternatively the spec file could patch in the the pre stage as then you know its CentOS.

--- slurm-drmaa-1.1.3/drmaa_utils/drmaa_utils/drmaa_run_bulk.c  2021-10-07 19:29:41.000000000 +0100
+++ drmaa_run_bulk.c    2022-01-05 11:17:45.109079264 +0000
@@ -149,9 +149,18 @@

    if (!path_to_drmaa) {
 #ifdef __APPLE__
-       path_to_drmaa = DRMAA_DIR_PREFIX"/lib/libdrmaa.dylib";
+                path_to_drmaa = DRMAA_DIR_PREFIX"/lib/libdrmaa.dylib";
 #else
-       path_to_drmaa = DRMAA_DIR_PREFIX"/lib/libdrmaa.so";
+
+#if __GNUC__
+#if __x86_64__ || __ppc64__
+                path_to_drmaa = DRMAA_DIR_PREFIX"/lib64/libdrmaa.so";
+#else
+                path_to_drmaa = DRMAA_DIR_PREFIX"/lib/libdrmaa.so";
+#endif
+#else
+                path_to_drmaa = DRMAA_DIR_PREFIX"/lib/libdrmaa.so";
+#endif
 #endif
    }
--- slurm-drmaa-1.1.3/drmaa_utils/drmaa_utils/drmaa_run.c   2021-10-07 19:29:41.000000000 +0100
+++ drmaa_run.c 2022-01-05 11:17:52.967210135 +0000
@@ -149,8 +149,17 @@
 #ifdef __APPLE__
        path_to_drmaa = DRMAA_DIR_PREFIX"/lib/libdrmaa.dylib";
 #else
+
+#if __GNUC__
+#if __x86_64__ || __ppc64__
+                path_to_drmaa = DRMAA_DIR_PREFIX"/lib64/libdrmaa.so";
+#else
+                path_to_drmaa = DRMAA_DIR_PREFIX"/lib/libdrmaa.so";
+#endif
+#else
        path_to_drmaa = DRMAA_DIR_PREFIX"/lib/libdrmaa.so";
 #endif
+#endif
    }

    api.handle = dlopen(path_to_drmaa, RTLD_LAZY | RTLD_GLOBAL);
--- slurm-drmaa-1.1.3/drmaa_utils/drmaa_utils/drmaa_job_ps.c    2021-10-07 19:29:41.000000000 +0100
+++ drmaa_job_ps.c  2022-01-05 11:17:59.938326234 +0000
@@ -139,9 +139,18 @@

    if (!path_to_drmaa) {
 #ifdef __APPLE__
-       path_to_drmaa = DRMAA_DIR_PREFIX"/lib/libdrmaa.dylib";
+                path_to_drmaa = DRMAA_DIR_PREFIX"/lib/libdrmaa.dylib";
 #else
-       path_to_drmaa = DRMAA_DIR_PREFIX"/lib/libdrmaa.so";
+
+#if __GNUC__
+#if __x86_64__ || __ppc64__
+                path_to_drmaa = DRMAA_DIR_PREFIX"/lib64/libdrmaa.so";
+#else
+                path_to_drmaa = DRMAA_DIR_PREFIX"/lib/libdrmaa.so";
+#endif
+#else
+                path_to_drmaa = DRMAA_DIR_PREFIX"/lib/libdrmaa.so";
+#endif
 #endif
    }