Blame slurm_pmix_soname.patch

Philip Kovacs bff578
diff --git a/src/plugins/mpi/pmix/mpi_pmix.c b/src/plugins/mpi/pmix/mpi_pmix.c
Philip Kovacs 8a8ef7
index bbb947616c..b284af63f2 100644
Philip Kovacs bff578
--- a/src/plugins/mpi/pmix/mpi_pmix.c
Philip Kovacs bff578
+++ b/src/plugins/mpi/pmix/mpi_pmix.c
Philip Kovacs 8a8ef7
@@ -89,6 +89,8 @@ const uint32_t plugin_version = SLURM_VERSION_NUMBER;
Philip Kovacs 8a8ef7
 
Philip Kovacs 8a8ef7
 void *libpmix_plug = NULL;
Philip Kovacs 8a8ef7
 
Philip Kovacs 8a8ef7
+static const char *pmix_libraries[] = { "libpmix.so", "libpmix.so.2", "libpmix.so.1" };
Philip Kovacs 8a8ef7
+
Philip Kovacs 8a8ef7
 static void _libpmix_close(void *lib_plug)
Philip Kovacs 8a8ef7
 {
Philip Kovacs 8a8ef7
 	xassert(lib_plug);
Philip Kovacs 8a8ef7
@@ -99,15 +101,20 @@ static void *_libpmix_open(void)
Philip Kovacs 8a8ef7
 {
Philip Kovacs 8a8ef7
 	void *lib_plug = NULL;
Philip Kovacs 8a8ef7
 	char *full_path = NULL;
Philip Kovacs 8a8ef7
+	size_t sz = 0;
Philip Kovacs 8a8ef7
 
Philip Kovacs 8a8ef7
 #ifdef PMIXP_V1_LIBPATH
Philip Kovacs 8a8ef7
 	xstrfmtcat(full_path, "%s/", PMIXP_V1_LIBPATH);
Philip Kovacs bff578
 #elif defined PMIXP_V2_LIBPATH
Philip Kovacs bff578
 	xstrfmtcat(full_path, "%s/", PMIXP_V2_LIBPATH);
Philip Kovacs bff578
 #endif
Philip Kovacs bff578
-	xstrfmtcat(full_path, "libpmix.so");
Philip Kovacs 8a8ef7
-	lib_plug = dlopen(full_path, RTLD_LAZY | RTLD_GLOBAL);
Philip Kovacs 8a8ef7
-	xfree(full_path);
Philip Kovacs 8a8ef7
+
Philip Kovacs 8a8ef7
+	while (!lib_plug && (sz < sizeof(pmix_libraries)/sizeof(pmix_libraries[0]))) {
Philip Kovacs 8a8ef7
+		xstrfmtcat(full_path, "%s", pmix_libraries[sz]);
Philip Kovacs 24291c
+		lib_plug = dlopen(full_path, RTLD_LAZY | RTLD_GLOBAL);
Philip Kovacs 24291c
+		xfree(full_path);
Philip Kovacs 8a8ef7
+		++sz;
Philip Kovacs 24291c
+	}
Philip Kovacs 8a8ef7
 
Philip Kovacs 24291c
 	if (lib_plug && (HAVE_PMIX_VER != pmixp_lib_get_version())) {
Philip Kovacs 24291c
 		PMIXP_ERROR("pmi/pmix: incorrect PMIx library version loaded %d was loaded, required %d version",
Philip Kovacs 8a8ef7
diff --git a/src/plugins/mpi/pmix/pmixp_dconn_ucx.c b/src/plugins/mpi/pmix/pmixp_dconn_ucx.c
Philip Kovacs 8a8ef7
index f6c91adc93..650fb7d5ff 100644
Philip Kovacs 8a8ef7
--- a/src/plugins/mpi/pmix/pmixp_dconn_ucx.c
Philip Kovacs 8a8ef7
+++ b/src/plugins/mpi/pmix/pmixp_dconn_ucx.c
Philip Kovacs 8a8ef7
@@ -140,6 +140,8 @@ static struct io_operations _progress_ops = {
Philip Kovacs 8a8ef7
 	.handle_read = _progress_read
Philip Kovacs 8a8ef7
 };
Philip Kovacs 8a8ef7
 
Philip Kovacs 8a8ef7
+static const char *ucx_libraries[] = { "libucp.so", "libucp.so.0" };
Philip Kovacs 8a8ef7
+
Philip Kovacs 8a8ef7
 static void *_ucx_init(int nodeid, pmixp_p2p_data_t direct_hdr);
Philip Kovacs 8a8ef7
 static void _ucx_fini(void *_priv);
Philip Kovacs 8a8ef7
 static int _ucx_connect(void *_priv, void *ep_data, size_t ep_len,
Philip Kovacs 8a8ef7
@@ -161,15 +163,20 @@ static int _load_ucx_lib()
Philip Kovacs 8a8ef7
 	setenv("UCX_MEM_MALLOC_RELOC", "no", 1);
Philip Kovacs 8a8ef7
 	setenv("UCX_MEM_EVENTS", "no", 1);
Philip Kovacs 8a8ef7
 
Philip Kovacs 8a8ef7
+	size_t sz = 0;
Philip Kovacs 8a8ef7
+
Philip Kovacs 8a8ef7
 #ifdef PMIXP_UCX_LIBPATH
Philip Kovacs 8a8ef7
 	/* If this Slurm build doesn't allow RPATH's
Philip Kovacs 8a8ef7
 	 * try to open library by it's full path that
Philip Kovacs 8a8ef7
 	 * we have from autoconf
Philip Kovacs 8a8ef7
 	 */
Philip Kovacs 8a8ef7
 	char *full_path = NULL;
Philip Kovacs 8a8ef7
-	xstrfmtcat(full_path, "%s/libucp.so", PMIXP_UCX_LIBPATH);
Philip Kovacs 8a8ef7
-	_ucx_lib_handler = dlopen(full_path, RTLD_LAZY | RTLD_GLOBAL);
Philip Kovacs 8a8ef7
-	xfree(full_path);
Philip Kovacs 8a8ef7
+	while (!_ucx_lib_handler && (sz < sizeof(ucx_libraries)/sizeof(ucx_libraries[0]))) {
Philip Kovacs 8a8ef7
+		xstrfmtcat(full_path, "%s/%s", PMIXP_UCX_LIBPATH, ucx_libraries[sz]);
Philip Kovacs 8a8ef7
+		_ucx_lib_handler = dlopen(full_path, RTLD_LAZY | RTLD_GLOBAL);
Philip Kovacs 8a8ef7
+		xfree(full_path);
Philip Kovacs 8a8ef7
+		++sz;
Philip Kovacs 8a8ef7
+	}
Philip Kovacs 8a8ef7
 	if (_ucx_lib_handler) {
Philip Kovacs 8a8ef7
 		/* successful, exit now */
Philip Kovacs 8a8ef7
 		return SLURM_SUCCESS;
Philip Kovacs 8a8ef7
@@ -178,7 +185,13 @@ static int _load_ucx_lib()
Philip Kovacs 8a8ef7
 	 * known by dynamic linker.
Philip Kovacs 8a8ef7
 	 */
Philip Kovacs 8a8ef7
 #endif
Philip Kovacs 8a8ef7
-	_ucx_lib_handler = dlopen("libucp.so", RTLD_LAZY | RTLD_GLOBAL);
Philip Kovacs 8a8ef7
+	sz = 0;
Philip Kovacs 8a8ef7
+	while (!_ucx_lib_handler && (sz < sizeof(ucx_libraries)/sizeof(ucx_libraries[0]))) {
Philip Kovacs 8a8ef7
+		xstrfmtcat(full_path, "%s", ucx_libraries[sz]);
Philip Kovacs 8a8ef7
+		_ucx_lib_handler = dlopen(full_path, RTLD_LAZY | RTLD_GLOBAL);
Philip Kovacs 8a8ef7
+		xfree(full_path);
Philip Kovacs 8a8ef7
+		++sz;
Philip Kovacs 8a8ef7
+	}
Philip Kovacs 8a8ef7
 	if (!_ucx_lib_handler) {
Philip Kovacs 8a8ef7
 		char *err = dlerror();
Philip Kovacs 8a8ef7
 		PMIXP_ERROR("Cannot open UCX lib: %s", (err) ? err : "unknown");