diff --git a/configure.ac b/configure.ac index 1c0297899f..cbfcbbe0f0 100644 --- a/configure.ac +++ b/configure.ac @@ -995,10 +995,15 @@ CFLAGS="$CFLAGS_save" ompi_show_subtitle "Libtool configuration" +m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), 2.0), -1, [ AC_LIBLTDL_CONVENIENCE(opal/libltdl) AC_LIBTOOL_DLOPEN AC_PROG_LIBTOOL - +], [ +LT_CONFIG_LTDL_DIR([opal/libltdl], [subproject]) +LTDL_CONVENIENCE +LT_INIT([dlopen win32-dll]) +]) ompi_show_subtitle "GNU libltdl setup" # AC_CONFIG_SUBDIRS appears to be broken for non-gcc compilers (i.e., @@ -1038,6 +1043,13 @@ if test "$OMPI_ENABLE_DLOPEN_SUPPORT" = "1" ; then if test "$HAPPY" = "1"; then LIBLTDL_SUBDIR=libltdl + CPPFLAGS_save="$CPPFLAGS" + CPPFLAGS="-I." + AC_EGREP_HEADER([lt_dladvise_init], [opal/libltdl/ltdl.h], + [OPAL_HAVE_LTDL_ADVISE=1], + [OPAL_HAVE_LTDL_ADVISE=0]) + CPPFLAGS="$CPPFLAGS" + # Arrgh. This is gross. But I can't think of any other way to do # it. :-( @@ -1057,7 +1069,7 @@ else AC_MSG_WARN([libltdl support disabled (by --disable-dlopen)]) LIBLTDL_SUBDIR= - LIBLTDL= + OPAL_HAVE_LTDL_ADVISE=0 # append instead of prepend, since LIBS are going to be system # type things needed by everyone. Normally, libltdl will push @@ -1073,6 +1085,8 @@ AC_SUBST(LIBLTDL_SUBDIR) AC_DEFINE_UNQUOTED(OMPI_WANT_LIBLTDL, $OMPI_ENABLE_DLOPEN_SUPPORT, [Whether to include support for libltdl or not]) +AC_DEFINE_UNQUOTED(OPAL_HAVE_LTDL_ADVISE, $OPAL_HAVE_LTDL_ADVISE, + [Whether libltdl appears to have the lt_dladvise interface]) ################################## # visibility diff --git a/opal/mca/base/mca_base_component_find.c b/opal/mca/base/mca_base_component_find.c index d6f54913b5..c58f638873 100644 --- a/opal/mca/base/mca_base_component_find.c +++ b/opal/mca/base/mca_base_component_find.c @@ -75,6 +75,10 @@ struct ltfn_data_holder_t { char name[MCA_BASE_MAX_COMPONENT_NAME_LEN]; }; typedef struct ltfn_data_holder_t ltfn_data_holder_t; + +#if OPAL_HAVE_LTDL_ADVISE +extern lt_dladvise opal_mca_dladvise; +#endif #endif /* OMPI_WANT_LIBLTDL */ @@ -387,7 +391,11 @@ static int open_component(component_file_item_t *target_file, /* Now try to load the component */ +#if OPAL_HAVE_LTDL_ADVISE + component_handle = lt_dlopenadvise(target_file->filename, opal_mca_dladvise); +#else component_handle = lt_dlopenext(target_file->filename); +#endif if (NULL == component_handle) { err = strdup(lt_dlerror()); if (0 != show_errors) { diff --git a/opal/mca/base/mca_base_component_repository.c b/opal/mca/base/mca_base_component_repository.c index befd6b8325..571f3d431b 100644 --- a/opal/mca/base/mca_base_component_repository.c +++ b/opal/mca/base/mca_base_component_repository.c @@ -85,6 +85,10 @@ static opal_list_t repository; static repository_item_t *find_component(const char *type, const char *name); static int link_items(repository_item_t *src, repository_item_t *depend); +#if OPAL_HAVE_LTDL_ADVISE +lt_dladvise opal_mca_dladvise; +#endif + #endif /* OMPI_WANT_LIBLTDL */ @@ -103,6 +107,20 @@ int mca_base_component_repository_init(void) return OPAL_ERR_OUT_OF_RESOURCE; } +#if OPAL_HAVE_LTDL_ADVISE + if (lt_dladvise_init(&opal_mca_dladvise)) { + return OPAL_ERR_OUT_OF_RESOURCE; + } + + if (lt_dladvise_ext(&opal_mca_dladvise)) { + return OPAL_ERROR; + } + + if (lt_dladvise_global(&opal_mca_dladvise)) { + return OPAL_ERROR; + } +#endif + OBJ_CONSTRUCT(&repository, opal_list_t); #endif initialized = true; @@ -255,6 +273,12 @@ void mca_base_component_repository_finalize(void) } } while (opal_list_get_size(&repository) > 0); +#if OPAL_HAVE_LTDL_ADVISE + if (lt_dladvise_destroy(&opal_mca_dladvise)) { + return OPAL_ERR_OUT_OF_RESOURCE; + } +#endif + /* Close down libltdl */ lt_dlexit();