1
1
openmpi/config/opal_config_subdir.m4
Jeff Squyres 9ac9be15c4 opal_config_subdir.m4: do not export vars before invoking subdir configure
== Short version

Do not export special variables into the environment (e.g., LIBS,
LDFLAGS, etc.) when invoking subdir configure scripts.  This prevents
problems described in open-mpi/ompi#471.

== More detail

Exporing special env variables before invoking a subdir configure
script causes problems in some cases.  E.g., in open-mpi/ompi#471,
when the user configures with `--with-hwloc=/path/to/hwloc`, and that
directory is *not* in a default linker search location will cause the
libevent subdir configuration to fail.

This happens because:

1. We'll pass LIBS="-L/path/to/hwloc/lib -lhwloc" to the libevent
   configure script
1. Meaning: configure-generated executables will link successfully
1. But unless LD_LIBRARY_PATH (or some other
   tell-the-linker-where-to-find-things mechanism) includes
   /path/to/hwloc/lib, the executable can't run.

Specifically, the libevent "hey, does the compiler generate proper
executables?" check will fail, and configure will abort (because OMPI
needs libevent).

I checked the history: exporting these vars dates all the way back to
LAM/MPI.  I can't think of a reason why we need to export these
variables -- AC_CONFIG_SUBDIRs doesn't do it; subdir configure scripts
should be orthogonal from the upper-layer configure script (and its
variables).  So let's remove these export statements and see if
anything breaks.
2015-04-14 07:04:01 -07:00

148 строки
3.7 KiB
Bash

dnl -*- shell-script -*-
dnl
dnl Copyright (c) 2004-2005 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-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) 2012-2015 Cisco Systems, Inc. All rights reserved.
dnl Copyright (c) 2014 Intel, Inc. All rights reserved.
dnl Copyright (c) 2015 Research Organization for Information Science
dnl and Technology (RIST). All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
dnl
dnl $HEADER$
dnl
AC_DEFUN([OPAL_CONFIG_SUBDIR],[
OPAL_VAR_SCOPE_PUSH([subdir_parent sub_configure subdir_dir subdir_srcdir subdir_cache_file subdir_args subdir_dots total_dir dir_part temp])
#
# Invoke configure in a specific subdirectory.
#
# $1 is the directory to invoke in
# $2 is the list of arguments to pass
# $3 is actions to execute upon success
# $4 is actions to execute upon failure
#
subdir_dir="$1"
subdir_args="$2"
subdir_success="$3"
subdir_failure="$4"
#
# Sanity checks
#
if test "$subdir_dir" != ":" && test -d $srcdir/$subdir_dir; then
AC_MSG_NOTICE([OPAL configuring in $subdir_dir])
#
# Gotta check where srcdir is for VPATH builds. If srcdir is not
# ., then we need to mkdir the subdir. Otherwise, we can just cd
# into it.
#
case $srcdir in
.)
;;
*)
{ case $subdir_dir in
[[\\/]]* | ?:[[\\/]]* ) total_dir=;;
*) total_dir=.;;
esac
temp=$subdir_dir
for dir_part in `IFS='/\\'; set X $temp; shift; echo "$[@]"`; do
case $dir_part in
# Skip DOS drivespec
?:) total_dir=$dir_part ;;
*) total_dir=$total_dir/$dir_part
test -d "$total_dir" ||
mkdir "$total_dir" ||
AC_MSG_ERROR([cannot create $subdir_dir])
;;
esac
done; }
if test -d ./$subdir_dir; then :;
else
AC_MSG_ERROR([cannot create `pwd`/$subdir_dir])
fi
;;
esac
#
# Move into the target directory
#
subdir_parent=`pwd`
cd $subdir_dir
#
# Make a "../" for each directory in $subdir_dir.
#
subdir_dots=`[echo $subdir_dir | sed 's,^\./,,;s,[^/]$,&/,;s,[^/]*/,../,g]'`
#
# Construct the --srcdir argument
#
case $srcdir in
.)
# In place
subdir_srcdir="$srcdir"
;;
[[\\/]* | ?:[\\/]*] )
# Absolute path
subdir_srcdir="$srcdir/$subdir_dir"
;;
*)
# Relative path
subdir_srcdir="$subdir_dots$srcdir/$subdir_dir"
;;
esac
#
# Construct the --cache-file argument
#
# BWB - subdir caching is a pain since we change CFLAGS and all that.
# Just disable it for now
subdir_cache_file="/dev/null"
#
# Invoke the configure script in the subdirectory
#
sub_configure="$SHELL '$subdir_srcdir/configure'"
AC_MSG_NOTICE([running $sub_configure $subdir_args --cache-file=$subdir_cache_file --srcdir=$subdir_srcdir --disable-option-checking])
eval "$sub_configure $subdir_args \
--cache-file=\"\$subdir_cache_file\" --srcdir=\"$subdir_srcdir\" --disable-option-checking"
if test "$?" = "0"; then
eval $subdir_success
AC_MSG_NOTICE([$sub_configure succeeded for $subdir_dir])
else
eval $subdir_failure
AC_MSG_NOTICE([$sub_configure *failed* for $subdir_dir])
fi
#
# Go back to the topdir
#
cd $subdir_parent
fi
#
# Clean up
#
OPAL_VAR_SCOPE_POP])dnl