From e597c4f9cd65cc2c0facc80b959ed555daeb30e7 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Thu, 20 May 2010 22:42:02 +0000 Subject: [PATCH] Add --with-libltdl option to allow building Open MPI with an external installation of libltdl. Fixes trac:2407 This commit was SVN r23189. The following Trac tickets were found above: Ticket 2407 --> https://svn.open-mpi.org/trac/ompi/ticket/2407 --- NEWS | 2 + README | 22 +++ opal/config/opal_configure_options.m4 | 6 +- opal/config/opal_setup_libltdl.m4 | 180 ++++++++++++++++++ opal/mca/base/mca_base_component_find.c | 6 +- opal/mca/base/mca_base_component_repository.c | 8 +- 6 files changed, 220 insertions(+), 4 deletions(-) create mode 100644 opal/config/opal_setup_libltdl.m4 diff --git a/NEWS b/NEWS index c068979629..d27d851bfe 100644 --- a/NEWS +++ b/NEWS @@ -29,6 +29,8 @@ version 1.0. Trunk (not on release branches yet) ----------------------------------- +- Added --with-libltdl[=VALUE] option to allow using a libltdl + installation from outside of the Open MPI source tree. - ErrMgr framework redesigned to better support fault tolerance development activities. See the following RFC for details: http://www.open-mpi.org/community/lists/devel/2010/03/7589.php diff --git a/README b/README index 8d3e67d82d..b666d4da6d 100644 --- a/README +++ b/README @@ -868,6 +868,28 @@ for a full list); a summary of the more commonly used ones follows: are build as static or dynamic via --enable|disable-static and --enable|disable-shared. +--with-libltdl[=VALUE] + This option specifies where to find the GNU Libtool libltdl support + library. The following VALUEs are permitted: + + internal: Use Open MPI's internal copy of libltdl. + external: Use an external libltdl installation (rely on default + compiler and linker paths to find it) + : Same as "internal". + : Specify the localtion of a specific libltdl + installation to use + + By default (or if --with-libltdl is specified with no VALUE), Open + MPI will build and use the copy of libltdl that it has in its source + tree. However, if the VALUE is "external", Open MPI will look for + the relevant libltdl header file and library in default compiler / + linker locations. Or, VALUE can be a directory tree where the + libltdl header file can library can be found. This option allows + operating systems to include Open MPI and use their default libltdl + installation instead of Open MPI's bundled libltdl. + + Note that this option is ignored if --disable-dlopen is specified. + --enable-heterogeneous Enable support for running on heterogeneous clusters (e.g., machines with different endian representations). Heterogeneous support is diff --git a/opal/config/opal_configure_options.m4 b/opal/config/opal_configure_options.m4 index a3b24d8618..f8feaf5c16 100644 --- a/opal/config/opal_configure_options.m4 +++ b/opal/config/opal_configure_options.m4 @@ -10,7 +10,7 @@ dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, dnl University of Stuttgart. All rights reserved. dnl Copyright (c) 2004-2005 The Regents of the University of California. dnl All rights reserved. -dnl Copyright (c) 2006-2009 Cisco Systems, Inc. All rights reserved. +dnl Copyright (c) 2006-2010 Cisco Systems, Inc. All rights reserved. dnl Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. dnl Copyright (c) 2009 IBM Corporation. All rights reserved. dnl Copyright (c) 2009 Los Alamos National Security, LLC. All rights @@ -537,4 +537,8 @@ OPAL_WITH_OPTION_MIN_MAX_VALUE(port_name, 1024, 255, 2048) # Min length accroding to MPI-2.1, p. 418 OPAL_WITH_OPTION_MIN_MAX_VALUE(datarep_string, 128, 64, 256) +# How to build libltdl +AC_ARG_WITH([libltdl], + [AC_HELP_STRING([--with-libltdl(=DIR)], + [Where to find libltdl (this option is ignored if --disable-dlopen is used). DIR can take one of three values: "internal", "external", or a valid directory name. "internal" (or no DIR value) forces Open MPI to use its internal copy of libltdl. "external" forces Open MPI to use an external installation of libltdl. Supplying a valid directory name also forces Open MPI to use an external installation of libltdl, and adds DIR/include, DIR/lib, and DIR/lib64 to the search path for headers and libraries.])]) ])dnl diff --git a/opal/config/opal_setup_libltdl.m4 b/opal/config/opal_setup_libltdl.m4 new file mode 100644 index 0000000000..818b08ef2b --- /dev/null +++ b/opal/config/opal_setup_libltdl.m4 @@ -0,0 +1,180 @@ +dnl +dnl Copyright (c) 2004-2009 The Trustees of Indiana University and Indiana +dnl University Research and Technology +dnl Corporation. All rights reserved. +dnl Copyright (c) 2004-2005 The University of Tennessee and The University +dnl of Tennessee Research Foundation. All rights +dnl reserved. +dnl Copyright (c) 2004-2007 High Performance Computing Center Stuttgart, +dnl University of Stuttgart. All rights reserved. +dnl Copyright (c) 2004-2005 The Regents of the University of California. +dnl All rights reserved. +dnl Copyright (c) 2006-2010 Cisco Systems, Inc. All rights reserved. +dnl Copyright (c) 2006-2008 Sun Microsystems, Inc. All rights reserved. +dnl Copyright (c) 2006-2007 Los Alamos National Security, LLC. All rights +dnl reserved. +dnl Copyright (c) 2009 Oak Ridge National Labs. All rights reserved. +dnl $COPYRIGHT$ +dnl +dnl Additional copyrights may follow +dnl +dnl $HEADER$ +dnl + +AC_DEFUN([OPAL_SETUP_LIBLTDL],[ + OMPI_VAR_SCOPE_PUSH([HAPPY]) + + ompi_show_subtitle "GNU libltdl setup" + + # AC_CONFIG_SUBDIRS appears to be broken for non-gcc compilers (i.e., + # passing precious variables down to the sub-configure). + # + # Finally, make ltdl follow the same shared/static convention that was + # user for the main OMPI libraries. So manually examine + # $enable_shared and $enable_static and pass down the corresponding + # flags. + + LTDLINCL= + LIBLTDL= + LIBLTDL_SUBDIR= + OPAL_HAVE_LTDL_ADVISE=0 + OPAL_LIBLTDL_INTERNAL=0 + + AS_IF([test "$OPAL_ENABLE_DLOPEN_SUPPORT" = "0"], + [AC_MSG_WARN([libltdl support disabled (by --disable-dlopen)]) + WRAPPER_EXTRA_LIBS="$WRAPPER_EXTRA_LIBS $LIBS"], + [ + # Default to building the internal copy. After this, + # paffinity_hwloc_location is guaranteed to be set to one of: + # "internal", a directory name (i.e., whatever the user + # supplied), or "no". + libltdl_location=$with_libltdl + AS_IF([test -z "$libltdl_location" -o "$libltdl_location" = "yes"], + [libltdl_location=internal]) + + AC_MSG_CHECKING([location of libltdl]) + case $libltdl_location in + no) + AC_MSG_WARN([--without-libltdl specified in conjunction with]) + AC_MSG_WARN([--enable-dlopen (or --disable-dlopen was not specified)]) + AC_MSG_WARN([Cannot have dlopen without libltdl]) + AC_MSG_ERROR([Cannot continue]) + ;; + internal) + AC_MSG_RESULT([internal copy]) + _OPAL_SETUP_LIBLTDL_INTERNAL + ;; + external) + AC_MSG_RESULT([external copy (unspecified)]) + libltdl_location= + libltdl_need_external=1 + ;; + *) + AC_MSG_RESULT([external copy ($libltdl_location)]) + OMPI_CHECK_WITHDIR([libltdl], [$libltdl_location], + [include/ltdl.h]) + libltdl_need_external=1 + ;; + esac + + AS_IF([test "$libltdl_need_external" = "1"], + [OMPI_CHECK_PACKAGE([libltdl], + [ltdl.h], + [ltdl], + [lt_dlopen], + [], + [$libltdl_location], + [], + [], + [AC_MSG_WARN([External libltdl installation not found]) + AC_MSG_WARN([or not usable.]) + AC_MSG_ERROR([Cannot continue.])]) + CPPFLAGS="$CPPFLAGS $libltdl_CPPFLAGS" + LDFLAGS="$LDFLAGS $libltdl_LDFLAGS" + LIBS="$LIBS $libltdl_LIBS" + + # Check for lt_dladvise_init; warn if we don't have + # it + AC_CHECK_FUNC([lt_dladvise_init], [], + [AC_MSG_WARN([*********************************************]) + AC_MSG_WARN([Could not find lt_dladvise_init in the]) + AC_MSG_WARN([external libltdl installation.]) + AC_MSG_WARN([This could mean that your libltdl version]) + AC_MSG_WARN([is old. We recommend that you re-configure]) + AC_MSG_WARN([Open MPI with --with-libltdl=internal to]) + AC_MSG_WARN([use the internal libltdl copy in Open MPI.]) + AC_MSG_WARN([]) + AC_MSG_WARN([Sleeping 10 seconds to give you a]) + AC_MSG_WARN([chance to read this message.]) + AC_MSG_WARN([*********************************************]) + sleep 10 + ]) + ]) + ]) + + AC_SUBST(LTDLINCL) + AC_SUBST(LIBLTDL) + AC_SUBST(LIBLTDL_SUBDIR) + + AC_DEFINE_UNQUOTED(OPAL_HAVE_LTDL_ADVISE, $OPAL_HAVE_LTDL_ADVISE, + [Whether libltdl appears to have the lt_dladvise interface]) + + AC_DEFINE_UNQUOTED(OPAL_WANT_LIBLTDL, $OPAL_ENABLE_DLOPEN_SUPPORT, + [Whether to include support for libltdl or not]) + AC_DEFINE_UNQUOTED(OPAL_LIBLTDL_INTERNAL, $OPAL_LIBLTDL_INTERNAL, + [Whether we are using the internal libltdl or not]) + + AM_CONDITIONAL(OPAL_HAVE_DLOPEN, + [test "$OPAL_ENABLE_DLOPEN_SUPPORT" = "1"]) + OMPI_VAR_SCOPE_POP([HAPPY]) +])dnl + + +# +# Setup to build the internal copy of libltdl +# +AC_DEFUN([_OPAL_SETUP_LIBLTDL_INTERNAL],[ + ompi_subdir_args="$ompi_subdir_args --enable-ltdl-convenience --disable-ltdl-install" + if test "$enable_shared" = "yes"; then + ompi_subdir_args="$ompi_subdir_args --enable-shared" + else + ompi_subdir_args="$ompi_subdir_args --disable-shared" + fi + if test "$enable_static" = "yes"; then + ompi_subdir_args="$ompi_subdir_args --enable-static" + else + ompi_subdir_args="$ompi_subdir_args --disable-static" + fi + + CFLAGS_save="$CFLAGS" + CFLAGS="$OMPI_CFLAGS_BEFORE_PICKY $OPAL_VISIBILITY_CFLAGS" + + OMPI_CONFIG_SUBDIR(opal/libltdl, [$ompi_subdir_args], + [HAPPY=1], [HAPPY=0]) + if test "$HAPPY" = "1"; then + LIBLTDL_SUBDIR=libltdl + OPAL_LIBLTDL_INTERNAL=1 + + CPPFLAGS_save="$CPPFLAGS" + CPPFLAGS="-I." + AC_EGREP_HEADER([lt_dladvise_init], [opal/libltdl/ltdl.h], + [OPAL_HAVE_LTDL_ADVISE=1]) + CPPFLAGS="$CPPFLAGS_save" + + # Arrgh. This is gross. But I can't think of any other + # way to do it. :-( + flags=`$EGREP ^LIBADD_DL opal/libltdl/Makefile | cut -d= -f2-` + OMPI_CHECK_LINKER_FLAGS([opal/libltdl/libtool], + [-export-dynamic $flags]) + + WRAPPER_EXTRA_LIBS="$WRAPPER_EXTRA_LIBS $extra_ldflags" + LDFLAGS="-export-dynamic $LDFLAGS" + else + AC_MSG_WARN([Failed to build GNU libltdl. This usually means that something]) + AC_MSG_WARN([is incorrectly setup with your environment. There may be useful information in]) + AC_MSG_WARN([opal/libltdl/config.log. You can also disable GNU libltdl, which will disable]) + AC_MSG_WARN([dynamic shared object loading, by configuring with --disable-dlopen.]) + AC_MSG_ERROR([Cannot continue]) + fi + CFLAGS="$CFLAGS_save" +])dnl diff --git a/opal/mca/base/mca_base_component_find.c b/opal/mca/base/mca_base_component_find.c index c6038bf8a9..cafd748725 100644 --- a/opal/mca/base/mca_base_component_find.c +++ b/opal/mca/base/mca_base_component_find.c @@ -42,7 +42,11 @@ #if OPAL_WANT_LIBLTDL #ifndef __WINDOWS__ - #include "opal/libltdl/ltdl.h" + #if OPAL_LIBLTDL_INTERNAL + #include "opal/libltdl/ltdl.h" + #else + #include "ltdl.h" + #endif #else #include "ltdl.h" #endif diff --git a/opal/mca/base/mca_base_component_repository.c b/opal/mca/base/mca_base_component_repository.c index fa9cb116e1..0aa029916a 100644 --- a/opal/mca/base/mca_base_component_repository.c +++ b/opal/mca/base/mca_base_component_repository.c @@ -9,7 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2008 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2008-2010 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -28,7 +28,11 @@ #if OPAL_WANT_LIBLTDL #ifndef __WINDOWS__ - #include "opal/libltdl/ltdl.h" + #if OPAL_LIBLTDL_INTERNAL + #include "opal/libltdl/ltdl.h" + #else + #include "ltdl.h" + #endif #else #include "ltdl.h" #endif