1
1

Fixes trac:376: bu default the wrappr compilers will enable rpath support

in generated executables on systems that support it.  Use
--disable-wrapper-rpath to disable this behavior.  See text in
README about --disable-wrapper-rpath for more details.

This commit was SVN r28479.

The following Trac tickets were found above:
  Ticket 376 --> https://svn.open-mpi.org/trac/ompi/ticket/376
Этот коммит содержится в:
Jeff Squyres 2013-05-11 00:49:17 +00:00
родитель 9d569f1487
Коммит 4d9da92e60
5 изменённых файлов: 141 добавлений и 7 удалений

39
README
Просмотреть файл

@ -679,6 +679,45 @@ INSTALLATION OPTIONS
Be sure to read the description of --without-memory-manager, below;
it may have some effect on --enable-static.
--disable-wrapper-rpath
By default, the wrapper compilers (e.g., mpicc) will enable "rpath"
support in generated executables on systems that support it. That
is, they will include a file reference to the location of Open MPI's
libraries in the MPI application executable itself. This mean that
the user does not have to set LD_LIBRARY_PATH to find Open MPI's
libraries (e.g., if they are installed in a location that the
run-time linker does not search by default).
On systems that utilize the GNU ld linker, recent enough versions
will actually utilize "runpath" functionality, not "rpath". There
is an important difference between the two:
"rpath": the location of the Open MPI libraries is hard-coded into
the MPI application and cannot be overridden at run-time.
"runpath": the location of the Open MPI libraries is hard-coded into
the MPI application, but can be overridden at run-time by
setting the LD_LIBRARY_PATH environment variable.
For example, consider that you install Open MPI vA.B.0 and
compile/link your MPI application against it. Later, you install
Open MPI vA.B.1 to a different installation prefix (e.g.,
/opt/openmpi/A.B.1 vs. /opt/openmpi/A.B.0), and you leave the old
installation intact.
In the rpath case, your MPI application will always use the
libraries from your A.B.0 installation. In the runpath case, you
can set the LD_LIBRARY_PATH environment variable to point to the
A.B.1 installation, and then your MPI application will use those
libraries.
Note that in both cases, however, if you remove the original A.B.0
installation and set LD_LIBRARY_PATH to point to the A.B.1
installation, your application will use the A.B.1 libraries.
This rpath/runpath behavior can be disabled via
--disable-wrapper-rpath.
--enable-dlopen
Build all of Open MPI's components as standalone Dynamic Shared
Objects (DSO's) that are loaded at run-time. The opposite of this

Просмотреть файл

@ -10,6 +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) 2010-2012 Cisco Systems, Inc. All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
@ -79,10 +80,9 @@ ompi_check_linker_flags_work yes
# eat any extra whitespace in CC, as libtool will do the same
tmpCC=`echo $CC | sed -e 's/\//\\\\\//g'`
output=`echo $output | sed -e "s/^$tmpCC//"`
eval "set $output"
extra_ldflags=
while test -n "[$]1"; do
case "[$]1" in
for arg in $output ; do
case "$arg" in
*.libs/bar*) ;;
bar*) ;;
-I*) ;;
@ -94,7 +94,7 @@ while test -n "[$]1"; do
*.so) ;;
*.a) ;;
*)
extra_ldflags="$extra_ldflags [$]1"
extra_ldflags="$extra_ldflags $arg"
;;
esac
shift
@ -106,5 +106,75 @@ else
AC_MSG_RESULT([no extra flags])
fi
#
# Now do something similar in order to capture the rpath flags: re-run
# the link, but give the libtool --rpath argument. Then capture the
# difference between this output and the previous output. Do this
# separately from the above tests to ensure that we don't accidentally
# remove -R if it's needed for rpath.
#
WRAPPER_RPATH_SUPPORT=disabled
AS_IF([test "x$enable_wrapper_rpath" = "xyes"],
[AC_MSG_CHECKING([for libtool-supplied rpath arguments])
no_rpath_output=$output
cmd="$libtool --dry-run --mode=link --tag=CC $CC -rpath /ompi-bogus-test-dir bar.lo libfoo.la -o bar $extra_flags"
ompi_check_linker_flags_work yes
# eat any extra whitespace in CC, as libtool will do the same
tmpCC=`echo $CC | sed -e 's/\//\\\\\//g'`
output=`echo $output | sed -e "s/^$tmpCC//"`
rpath_args=
for rp in $output ; do
found=0
for nrp in $no_rpath_output ; do
AS_IF([test "$rp" = "$nrp"], [found=1])
done
# If we didn't find it, then it must be an rpath argument.
# Ensure to replace /ompi-bogus-test-dir with ${libdir} so
# that the wrapper can do proper replacement, later.
AS_IF([test "$found" = "0"],
[rpath_args="$rpath_args `echo $rp | sed -e 's@/ompi-bogus-test-dir@\@{libdir}@'`"])
done
# If there were no flags necessary, then we really aren't doing
# anything to enable rpath, so let's not claim that we are.
AS_IF([test "`echo $rpath_args`" = ""],
[rpath_args=
enable_wrapper_rpath=no
WRAPPER_RPATH_SUPPORT=unnecessary
msg="no extra flags"],
[wrapper_extra_ldflags="$wrapper_extra_ldflags $rpath_args"
WRAPPER_RPATH_SUPPORT=rpath
msg=$rpath_args])
AC_MSG_RESULT([$msg])
])
# We don't need to be in the subdir any more
cd ..
rm -rf conftest.$$])dnl
rm -rf conftest.$$
AS_IF([test "x$enable_wrapper_rpath" = "xyes"],
[
# Now that we have the rpath flags, check to see if the linker
# supports the DT_RUNPATH flags via --enable-new-dtags (a GNU
# ld-specific option). These flags are more social than
# DT_RPATH -- they can be overridden by LD_LIBRARY_PATH (where
# a regular DT_RPATH cannot).
AC_MSG_CHECKING([if linker supports RUNPATH (vs. RPATH)])
LDFLAGS_save=$LDFLAGS
LDFLAGS="$LDFLAGS $rpath_args -Wl,--enable-new-dtags"
AC_LANG_PUSH([C])
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 7;])],
[msg=yes
WRAPPER_RPATH_SUPPORT=runpath
wrapper_extra_ldflags="$wrapper_extra_ldflags -Wl,--enable-new-dtags"],
[msg=no])
AC_LANG_POP([C])
LDFLAGS=$LDFLAGS_save
AC_MSG_RESULT([$msg])
])
])dnl

Просмотреть файл

@ -11,7 +11,7 @@ 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 Oracle and/or its affiliates. All rights reserved.
dnl Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
dnl Copyright (c) 2009-2010 Cisco Systems, Inc. All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
@ -120,6 +120,13 @@ AC_DEFUN([OPAL_SETUP_WRAPPER_INIT],[
[Extra flags to add to LIBS when using wrapper compilers])])
AS_IF([test "$with_wrapper_libs" = "yes" -o "$with_wrapper_libs" = "no"],
[AC_MSG_ERROR([--with-wrapper-libs must have an argument.])])
AC_MSG_CHECKING([if want wrapper compiler rpath support])
AC_ARG_ENABLE([wrapper-rpath],
[AS_HELP_STRING([--enable-wrapper-rpath],
[enable rpath support in the wrapper compilers (default=no)])])
AS_IF([test "$enable_wrapper_rpath" != "no"], [enable_wrapper_rpath=yes])
AC_MSG_RESULT([$enable_wrapper_rpath])
])
@ -342,4 +349,7 @@ AC_DEFUN([OPAL_SETUP_WRAPPER_FINAL],[
AC_DEFINE_UNQUOTED(WRAPPER_EXTRA_LIBS, "$OMPI_WRAPPER_EXTRA_LIBS",
[Additional LIBS to pass through the wrapper compilers])
])
AC_DEFINE_UNQUOTED(WRAPPER_RPATH_SUPPORT, "$WRAPPER_RPATH_SUPPORT",
[Whether the wrapper compilers add rpath flags by default])
])

Просмотреть файл

@ -315,6 +315,8 @@ void ompi_info_do_config(bool want_all)
fortran_build_f08_subarrays);
opal_info_out("Java bindings", "bindings:java", java);
opal_info_out("Wrapper compiler rpath", "compiler:all:rpath",
WRAPPER_RPATH_SUPPORT);
opal_info_out("C compiler", "compiler:c:command", OPAL_CC);
opal_info_out("C compiler absolute", "compiler:c:absolute",
OPAL_CC_ABSOLUTE);

Просмотреть файл

@ -20,6 +20,10 @@
#include "opal/mca/installdirs/base/base.h"
#include "opal/mca/installdirs/installdirs.h"
/* Support both ${name} and @{name} forms. The latter allows us to
pass values through AC_SUBST without being munged by m4 (e.g., if
we want to pass "@{libdir}" and not have it replaced by m4 to be
whatever the actual value of the shell variable is. */
#define EXPAND_STRING(field) \
do { \
if (NULL != (start_pos = strstr(retval, "${" #field "}"))) { \
@ -31,6 +35,15 @@
end_pos); \
free(tmp); \
changed = true; \
} else if (NULL != (start_pos = strstr(retval, "@{" #field "}"))) { \
tmp = retval; \
*start_pos = '\0'; \
end_pos = start_pos + strlen("@{" #field "}"); \
asprintf(&retval, "%s%s%s", tmp, \
opal_install_dirs.field + destdir_offset, \
end_pos); \
free(tmp); \
changed = true; \
} \
} while (0)
@ -97,7 +110,7 @@ opal_install_dirs_expand_internal(const char* input, bool is_setup)
len = strlen(input);
for (i = 0 ; i < len ; ++i) {
if (input[i] == '$') {
if ('$' == input[i] || '@' == input[i]) {
needs_expand = true;
break;
}