Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prov/cxi: Add FI_CXI_CURL_LIB_PATH #define from autoconf #10711

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion prov/cxi/configure.m4
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ AC_DEFUN([FI_CXI_CONFIGURE],[
[CPPFLAGS="-I$with_cxi_uapi_headers/include $CPPFLAGS"])

# Support non-standard install path for curl. This is needed by CXI provider.
# Add #define of the path to the curl library for use in the code
AC_ARG_WITH([curl],
[AS_HELP_STRING([--with-curl=DIR], [Install directory for curl])])
[AS_HELP_STRING([--with-curl=DIR], [Install directory for curl])],
[AC_DEFINE_UNQUOTED([FI_CXI_CURL_LIB_PATH], ["$with_curl"], [Path to the curl install root])])

# Support non-standard install path for json-c. This is needed by CXI provider.
AC_ARG_WITH([json-c],
Expand Down
59 changes: 42 additions & 17 deletions prov/cxi/src/cxip_curl.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ struct curlfunc curlary[] = {
int cxip_curl_load_symbols(void)
{
struct curlfunc *funcptr;
char libfile[256], *libpath;
char *libfile = NULL, *libpath;
int version;
int errcnt;
void *h;
Expand All @@ -189,28 +189,53 @@ int cxip_curl_load_symbols(void)
if (cxip_curlhandle)
return 0;

char *curl_libpath = NULL;
#ifdef FI_CXI_CURL_LIB_PATH
curl_libpath = strdup(FI_CXI_CURL_LIB_PATH "/%s/libcurl.so.%d");
TRACE_CURL("FI_CXI_CURL_LIB_PATH set to '%s'\n", curl_libpath);
#else
curl_libpath = strdup("/usr/%s/libcurl.so.%d");
#endif

/* Try to find latest usable version */
// TODO test earlier versions
for (version = 4; version >= 4; version--) {
sprintf(libfile, "/usr/lib64/libcurl.so.%d", version);
libpath = realpath(libfile, NULL);
if (!libpath) {
TRACE_CURL("could not expand '%s'\n", libfile);
CXIP_INFO("could not expand '%s'\n", libfile);
continue;
}
TRACE_CURL("dlopen '%s'\n", libpath);
h = dlopen(libpath, RTLD_NOW);
if (!h) {
TRACE_CURL("%s not found\n", libpath);
CXIP_INFO("%s not found\n", libpath);
const char *lib_dirs[] = {"lib", "lib64"};
for (int i = 0; i < 2; i++) {
int len = snprintf(NULL, 0, curl_libpath, lib_dirs[i], version) + 1;
libfile = malloc(len);
if (!libfile) {
free(curl_libpath);
return -FI_ENOMEM;
}
snprintf(libfile, len, curl_libpath, lib_dirs[i], version);
TRACE_CURL("Checking libcurl at '%s'\n", libfile);
libpath = realpath(libfile, NULL);
if (!libpath) {
TRACE_CURL("could not expand '%s'\n", libfile);
CXIP_INFO("could not expand '%s'\n", libfile);
free(libfile);
continue;
}
TRACE_CURL("dlopen '%s'\n", libpath);
h = dlopen(libpath, RTLD_NOW);
if (!h) {
TRACE_CURL("%s not found\n", libpath);
CXIP_INFO("%s not found\n", libpath);
free(libpath);
free(libfile);
continue;
}
TRACE_CURL("%s found\n", libpath);
free(libpath);
continue;
free(libfile);
break;
}
if (h) {
break;
}
TRACE_CURL("%s found\n", libpath);
free(libpath);
break;
}
free(curl_libpath);
if (!h) {
TRACE_CURL("libcurl not supported\n");
CXIP_WARN("libcurl not supported\n");
Expand Down
Loading