libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

LD_LIBRARY_PATH_64 on Solaris (was: [OMPI devel] "make check" (libtool?)


From: Ralf Wildenhues
Subject: LD_LIBRARY_PATH_64 on Solaris (was: [OMPI devel] "make check" (libtool?) failure on Solaris/SPARC (1.5rc5 and 1.4.3rc1))
Date: Sat, 16 Oct 2010 16:52:20 +0200
User-agent: Mutt/1.5.20 (2010-08-04)

[ moving from open-mpi-devel to libtool-patches ]

Hello Paul, all,

this took quite a bit longer than I expected, and it also turned out
to be quite a bit longer than I initially expected.  ;-)

> * Paul H. Hargrove wrote on Thu, Aug 26, 2010 at 10:14:22PM CEST:
> >  I just had a thought on this one:  In my environment on this
> > platform I have LD_LIBRARY_PATH_32 and LD_LIBRARY_PATH_64 set.  It
> > seems possible to me that this is causing the loader to ignore the
> > LD_LIBRARY_PATH setting that libtool's wrapper script sets when
> > executing uninstalled programs in the build directory, as during
> > "make check".
> >  So, I tried removing these from my environment and editing
> > ~/.bashrc not to set them.  The result is a SUCCESSful "make check"!

Yep.  Quoting ld.so.1(1) from Solaris 10 (Sparc):

     Each environment variable can be specified with a _32 or _64
     suffix.   This  makes  the  environment  variable  specific,
     respectively, to 32-bit or 64-bit processes.  This  environ-
     ment  variable  overrides  any  non-suffixed  version of the
     environment variable that may  be  in  effect.   Environment
     variables  specified without a value, that have a _32 or _64
     suffix, effectively cancel any associated  generic  environ-
     ment variable setting.

Here's what I think are the semantics relevant to Libtool:

- programs executed by libtool might be 32 or 64 bits, so in the most
general case we need the settings from up to two of the three variables
LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64, in the following
named L, L32, and L64.

- we cannot assume L, L32, and L64 are set the same at configure time as
they are at, say, runtime of uninstalled executables.

- we cannot blindly append :$L to L32 if L32 is already set, because the
entries from L could actually contain old libraries not to be used (for
all programs not from us, we want to ensure an error is still an error).
Or they could contain unwanted 64bit libraries.  Same of course with 32
and 64 roles swapped.

- we cannot prepend $L32: to L and then unset L32, because those
directories could also contain bogus 64bit libraries then loaded by
64bit helper programs.  Likewise with roles swapped.

- a quick test shows that if you have a directory with 64bit liba.so.1
and one later with 32bit liba.so.1, then if both directories are in one
of the paths, the runtime linker will load the right one and not print
complaints about the wrong one found earlier.  Good.


Taken together, that means it should be possible to implement one of
these alternative strategies for a 32-bit build (analogous for 64bit of
course):

1) if L32 is already set, prepend to L32 in addition to prepending to L.

2) if L32 is already set, prepend to L32 instead of prepending to L.

(1) seems a bit safer for the case that we detect the bitness wrongly,
or the link editor behaves differently than the runtime linker;
(2) increases the environment less.

An actual implementation could thus be a new libtool variable
aux_shlibpath_var; if nonempty, we check whether the variable it names
is set, and if yes, we prepend to that instead of or additionally.


Now, how about other multi-ABI systems?

I checked IRIX, which has very similar runtime linker semantics
regarding the variables LD_LIBRARY64_PATH and LD_LIBRARYN32_PATH.

Hmm, IRIX also has _RLD_ROOT, _RLD64_ROOT and _RLDN32_ROOT, which in
hierarchy sit even before DT_RPATH, so could be (ab)used as alternate
shlibpath_var settings that override the runpath (unlike LD_LIBRARY_PATH
and sisters on this system) ...

HP-UX/hppa64, according to documentation, has in addition to SHLIB_PATH
also LD_LIBRARY_PATH.  The latter takes precedence over the former, but
does not turn the former off.  Of course either are only enabled when +s
has been used for linking (which we don't deal with quite correctly
yet).

OS X has DYLD_FALLBACK_LIBRARY_PATH, but it has lower precedence.

Note that this is not intended for systems which have environment
variables which differ in whether they override DT_RPATH (run path
entries encoded in the executable or library).


So, I've worked on a patch for this, and this is what I've come up with
so far.  I say so far, because the patch could probably do with a few
more testsuite additions and maybe some factoring, but I'm at a stage
where I'd like some preliminary review that what I'm doing is sensible
and will be welcome when finished.  It implements approach (2) above.

The two patches (well, slightly previous versions of them) have been
tested on IRIX, HP-UX/hppa64, Solaris/i386 with both the shlibpath_var
and the aux_shlibpath_var unset (no regression to previous test
results).  They have also been tested with LD_LIBRARY_PATH_32 set on
Solaris/i386, fixing all of several previous test failures.

I would test the final version again before pushing.

I'm a bit worried whether $host_cpu is a good indicator for bitness on
Solaris (it will be wrong if -m64 is put in CFLAGS rather than CC).
Better ideas welcome.

Thanks,
Ralf

    Handle auxiliary shared library path environment variables.
    
    This patch lets libtool handle systems with more than one shared
    library path variable, such as Solaris, HP-UX, IRIX.  If the
    libtool variable aux_shlibpath_var is set, then it names an
    environment variable that, if set, overrides the environment
    variable named by shlibpath_var.  libtool takes care to set
    $aux_shlibpath_var only if it is set already in the environment,
    to avoid losing settings from $shlibpath_var.
    
    * libltdl/config/ltmain.m4sh (func_mode_execute)
    (func_mode_finish, func_exec_program, func_emit_cwrapperexe_src)
    (func_mode_link): Handle $aux_shlibpath_var in addition to
    $shlibpath_var, by setting the former if aux_shlibpath_var is
    nonempty and the variable it names is set in the environment.
    * libltdl/ltdl.c (try_dlopen): Honor LT_MODULE_AUX_PATH_VAR if
    it is set and nonempty, and LT_MODULE_PATH_VAR only otherwise.
    * libltdl/m4/libtool.m4 (_LT_SYS_DYNAMIC_LINKER)
    <aux_shlibpath_var>: New _LT_DECL.
    [hpux/hppa64]: Set shlibpath_var to SHLIB_PATH, aux_shlibpath_var
    to LD_LIBRARY_PATH.
    [irix]: Set shlibpath to LD_LIBRARY_PATH, aux_shlibpath_var to
    LD_LIBRARY${shlibsuff}_PATH.
    [solaris i386/x86_64]: Set aux_shlibpath_var to
    LD_LIBRARY_PATH_{32,64} as appropriate.
    * libltdl/m4/ltdl.m4 (LT_SYS_MODULE_PATH): New define
    LT_MODULE_AUX_PATH_VAR, new cache variable
    lt_cv_module_aux_path_var, set from aux_shlibpath_var.
    * tests/shlibpath.at (aux_shlibpath_var): New test.
    * NEWS: Update.
    * doc/libtool.texi (libtool script contents): Document
    aux_shlibpath_var.  Adjust documentation for
    hardcode_direct_absolute and hardcode_shlibpath_var.
    Report by Paul H. Hargrove.

diff --git a/NEWS b/NEWS
index 90e33f7..ecb8a1d 100644
--- a/NEWS
+++ b/NEWS
@@ -27,6 +27,11 @@ New in 2.4 2010-09-22: git version 2.2.11a, Libtool team:
     now for more concurrency and better test logging.  For this, tests are
     run in verbose mode by default now.
 
+  - If the new libtool variable aux_shlibpath_var is nonempty, it names an
+    environment variable that, if set, overrides the shlibpath_var.  The
+    aux_shlibpath_var variable may be set on Solaris (LD_LIBRARY_PATH_{32,64})
+    IRIX (LD_LIBRARY{,N32,64}_PATH), and HP-UX/hppa64 (LD_LIBRARY_PATH).
+
 * Important incompatible changes:
 
   - Autoconf 2.62 and Automake 1.11.1 or newer are now required for
@@ -34,6 +39,9 @@ New in 2.4 2010-09-22: git version 2.2.11a, Libtool team:
     Autoconf 2.59 and Automake 1.9.6 should still work.
   - The fix_srcfile_path variable has been replaced by a more thorough
     mechanism triggered by the to_tool_file_cmd variable.
+  - With the introduction of aux_shlibpath_var (see above), shlibpath_var
+    has been changed to LD_LIBRARY_PATH on IRIX, and SHLIB_PATH on
+    HP-UX/hppa64.
 
 * Changes in supported systems or compilers:
 
diff --git a/doc/libtool.texi b/doc/libtool.texi
index 076b67b..288b7ff 100644
--- a/doc/libtool.texi
+++ b/doc/libtool.texi
@@ -6599,9 +6599,9 @@ line (such as @address@hidden/address@hidden) when
 
 @defvar hardcode_direct_absolute
 Some architectures hardcode "absolute" library directories that can not
-be overridden by @code{shlibpath_var} when @code{hardcode_direct} is
address@hidden  In that case set @code{hardcode_direct_absolute} to
address@hidden, or otherwise @samp{no}.
+be overridden by @code{shlibpath_var} or @code{aux_shlibpath_var} when
address@hidden is @samp{yes}.  In that case set
address@hidden to @samp{yes}, or otherwise @samp{no}.
 @end defvar
 
 @defvar hardcode_into_libs
@@ -6631,9 +6631,10 @@ executable when @code{hardcode_libdir_flag_spec} is 
specified.
 @defvar hardcode_shlibpath_var
 Set to @samp{yes} or @samp{no}, depending on whether the linker
 hardcodes directories by writing the contents of @samp{$shlibpath_var}
-into the resulting executable when @code{hardcode_libdir_flag_spec} is
-specified.  Set to @samp{unsupported} if directories specified by
address@hidden are searched at run time, but not at link time.
+or @samp{$aux_shlibpath_var} into the resulting executable when
address@hidden is specified.  Set to
address@hidden if directories specified by @samp{$shlibpath_var} or
address@hidden are searched at run time, but not at link time.
 @end defvar
 
 @defvar host
@@ -6791,8 +6792,12 @@ equivalent to @samp{no}.
 @end defvar
 
 @defvar shlibpath_var
address@hidden aux_shlibpath_var
 The environment variable that tells the dynamic linker where to find
-shared libraries.
+shared libraries.  If no such variable exists, @code{shlibpath_var} is
+empty.  If additionally @code{aux_shlibpath_var} is nonempty, then it
+name an environment variable that overrides @code{shlibpath_var} if and
+only if it is set.
 @end defvar
 
 @defvar soname_spec
@@ -6816,10 +6821,11 @@ that appear in this list are never hard-coded into 
executables.
 Expression to get the compile-time system library search path.  This
 variable is used by libtool when it has to test whether a certain
 library is shared or static.  The directories listed in
address@hidden are automatically appended to this list, every time
-libtool runs (i.e., not at configuration time), because some linkers use
-this variable to extend the library search path.  Linker switches such
-as @option{-L} also augment the search path.
address@hidden or @code{aux_shlibpath_var} are automatically
+appended to this list, every time libtool runs (i.e., not at
+configuration time), because some linkers use this variable to extend
+the library search path.  Linker switches such as @option{-L} also
+augment the search path.
 @end defvar
 
 @defvar thread_safe_flag_spec
diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index af46cb8..48154ad 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -1788,11 +1788,20 @@ func_mode_execute ()
       absdir=`cd "$dir" && pwd`
       test -n "$absdir" && dir="$absdir"
 
-      # Now add the directory to shlibpath_var.
-      if eval "test -z \"\$$shlibpath_var\""; then
-       eval "$shlibpath_var=\"\$dir\""
+      # Now add the directory to aux_shlibpath_var or shlibpath_var.
+      if test -n "$aux_shlibpath_var" \
+        && eval test \"\${$aux_shlibpath_var+set}\" = set; then
+       if eval "test -z \"\$$aux_shlibpath_var\""; then
+         eval "$aux_shlibpath_var=\"\$dir\""
+       else
+         eval "$aux_shlibpath_var=\"\$dir:\$$aux_shlibpath_var\""
+       fi
       else
-       eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
+       if eval "test -z \"\$$shlibpath_var\""; then
+         eval "$shlibpath_var=\"\$dir\""
+       else
+         eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
+       fi
       fi
     done
 
@@ -1825,9 +1834,13 @@ func_mode_execute ()
     done
 
     if test "X$opt_dry_run" = Xfalse; then
+      # Export aux_shlibpath_var if set, or shlibpath_var.
+      if test -n "$aux_shlibpath_var" \
+        && eval "test \"\${$aux_shlibpath_var+set}\" = set"; then
+        export $aux_shlibpath_var
+      fi
       if test -n "$shlibpath_var"; then
-       # Export the shlibpath_var.
-       eval "export $shlibpath_var"
+       export $shlibpath_var
       fi
 
       # Restore saved environment variables
@@ -1844,6 +1857,11 @@ func_mode_execute ()
       exec_cmd="\$cmd$args"
     else
       # Display what would be done.
+      if test -n "$aux_shlibpath_var" \
+        && eval "test \"\${$aux_shlibpath_var+set}\" = set"; then
+       eval "\$ECHO \"\$aux_shlibpath_var=\$$aux_shlibpath_var\""
+       echo "export $aux_shlibpath_var"
+      fi
       if test -n "$shlibpath_var"; then
        eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
        echo "export $shlibpath_var"
@@ -1936,7 +1954,11 @@ func_mode_finish ()
       echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
       echo "flag during linking and do at least one of the following:"
       if test -n "$shlibpath_var"; then
-       echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
+        if test -n "$aux_shlibpath_var"; then
+         echo "   - add LIBDIR to the \`$aux_shlibpath_var' or the 
\`$shlibpath_var' environment variable"
+       else
+         echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
+       fi
        echo "     during execution"
       fi
       if test -n "$runpath_var"; then
@@ -3307,8 +3329,27 @@ func_exec_program ()
 
        # Export our shlibpath_var if we have one.
        if test "$shlibpath_overrides_runpath" = yes && test -n 
"$shlibpath_var" && test -n "$temp_rpath"; then
-         $ECHO "\
-    # Add our own library path to $shlibpath_var
+
+         if test -n "$aux_shlibpath_var"; then
+           $ECHO "\
+    # Add our own library path to $aux_shlibpath_var or $shlibpath_var.
+    if test \"\${$aux_shlibpath_var+set}\" = set; then
+      $aux_shlibpath_var=\"$temp_rpath\$$aux_shlibpath_var\"
+      $aux_shlibpath_var=\`\$ECHO \"\$$aux_shlibpath_var\" | $SED 's/::*\$//'\`
+      export $aux_shlibpath_var
+    else
+      $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
+
+      # Some systems cannot cope with colon-terminated $shlibpath_var
+      # The second colon is a workaround for a bug in BeOS R4 sed
+      $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
+
+      export $shlibpath_var
+    fi
+"
+          else
+           $ECHO "\
+    # Add our own library path to $shlibpath_var.
     $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
 
     # Some systems cannot cope with colon-terminated $shlibpath_var
@@ -3317,6 +3358,7 @@ func_exec_program ()
 
     export $shlibpath_var
 "
+         fi
        fi
 
        $ECHO "\
@@ -3507,6 +3549,7 @@ EOF
            cat <<EOF
 volatile const char * MAGIC_EXE = "$magic_exe";
 const char * LIB_PATH_VARNAME = "$shlibpath_var";
+const char * AUX_LIB_PATH_VARNAME = "$aux_shlibpath_var";
 EOF
 
            if test "$shlibpath_overrides_runpath" = yes && test -n 
"$shlibpath_var" && test -n "$temp_rpath"; then
@@ -3562,6 +3605,7 @@ main (int argc, char *argv[])
   char *actual_cwrapper_name;
   char *target_name;
   char *lt_argv_zero;
+  char *aux_shlibpath;
   intptr_t rval = 127;
 
   int i;
@@ -3712,7 +3756,12 @@ EOF
      because on Windows, both *_VARNAMEs are PATH but uninstalled
      libraries must come first. */
   lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
-  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
+  if (*AUX_LIB_PATH_VARNAME != '\0'
+      && (aux_shlibpath_var = getenv (AUX_LIB_PATH_VARNAME)) != NULL
+      && *aux_shlibpath_var != '\0)
+    lt_update_lib_path (AUX_LIB_PATH_VARNAME, LIB_PATH_VALUE);
+  else
+    lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
 
   lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
                  nonnull (lt_argv_zero));
@@ -5216,7 +5265,11 @@ func_mode_link ()
     outputname="$func_basename_result"
     libobjs_save="$libobjs"
 
-    if test -n "$shlibpath_var"; then
+    if test -n "$aux_shlibpath_var" \
+       && eval test \"\$\{$aux_shlibpath_var+set\}\" = set; then
+      # get the directories listed in $aux_shlibpath_var
+      eval shlib_search_path=\`\$ECHO \"\${$aux_shlibpath_var}\" \| \$SED 
\'s/:/ /g\'\`
+    elif test -n "$shlibpath_var"; then
       # get the directories listed in $shlibpath_var
       eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ 
/g\'\`
     else
@@ -7295,7 +7348,12 @@ EOF
        shlibpath="$finalize_shlibpath"
        test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
        if test -n "$shlibpath"; then
-         eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export 
$shlibpath_var"
+         if test -n "$aux_shlibpath_var" \
+           && eval test \"\${$aux_shlibpath_var+set}\" = set; then
+           eval "$aux_shlibpath_var='$shlibpath\$$aux_shlibpath_var'; export 
$aux_shlibpath_var"
+         else
+           eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export 
$shlibpath_var"
+         fi
        fi
 
        # Get the real and link names of the library.
@@ -8116,10 +8174,20 @@ EOF
        exit $exit_status
       fi
 
+      # FIXME: for relink_command, $aux_shlibpath_var contents should be
+      # checked at relink time only.
       if test -n "$compile_shlibpath$finalize_shlibpath"; then
+       if test -n "$aux_shlibpath_var" \
+          && eval test \"\${$aux_shlibpath_var+set}\" = set; then
+         
compile_command="$aux_shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$aux_shlibpath_var\"
 $compile_command"
+       fi
        
compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\"
 $compile_command"
       fi
       if test -n "$finalize_shlibpath"; then
+       if test -n "$aux_shlibpath_var" \
+          && eval test \"\${$aux_shlibpath_var+set}\" = set; then
+         
finalize_command="$aux_shlibpath_var=\"$finalize_shlibpath\$$aux_shlibpath_var\"
 $finalize_command"
+       fi
        
finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" 
$finalize_command"
       fi
 
diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c
index be1e4c0..7b1f7d3 100644
--- a/libltdl/ltdl.c
+++ b/libltdl/ltdl.c
@@ -1154,6 +1154,7 @@ try_dlopen (lt_dlhandle *phandle, const char *filename, 
const char *ext,
   char *       dir             = 0;
   char *       name            = 0;
   char *        attempt                = 0;
+  char *        aux_path        = 0;
   int          errors          = 0;
   lt_dlhandle  newhandle;
 
@@ -1354,9 +1355,17 @@ try_dlopen (lt_dlhandle *phandle, const char *filename, 
const char *ext,
 #if defined(LT_MODULE_PATH_VAR)
          if (!file)
            {
-             search_path = getenv (LT_MODULE_PATH_VAR);
-             if (search_path)
+#if defined(LT_MODULE_AUX_PATH_VAR)
+             search_path = getenv (LT_MODULE_AUX_PATH_VAR);
+             if (search_path && *search_path != '\0')
                file = find_file (search_path, base_name, &dir);
+             else
+#endif
+               {
+                 search_path = getenv (LT_MODULE_PATH_VAR);
+                 if (search_path)
+                   file = find_file (search_path, base_name, &dir);
+               }
            }
 #endif
 #if defined(LT_DLSEARCH_PATH)
@@ -1457,6 +1466,11 @@ try_dlopen (lt_dlhandle *phandle, const char *filename, 
const char *ext,
                   && !find_handle (getenv (LTDL_SEARCHPATH_VAR), base_name,
                                    &newhandle, advise)
 #if defined(LT_MODULE_PATH_VAR)
+#if defined(LT_MODULE_AUX_PATH_VAR)
+                  && ((aux_path = getenv (LT_MODULE_AUX_PATH_VAR)) == NULL
+                      || !find_handle (aux_path, base_name, &newhandle,
+                                       advise))
+#endif
                   && !find_handle (getenv (LT_MODULE_PATH_VAR), base_name,
                                    &newhandle, advise)
 #endif
diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4
index 967dd38..5c4e29c 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -2172,6 +2172,7 @@ postuninstall_cmds=
 finish_cmds=
 finish_eval=
 shlibpath_var=
+aux_shlibpath_var=
 shlibpath_overrides_runpath=unknown
 version_type=none
 dynamic_linker="$host_os ld.so"
@@ -2503,7 +2504,8 @@ hpux9* | hpux10* | hpux11*)
     shrext_cmds='.sl'
     hardcode_into_libs=yes
     dynamic_linker="$host_os dld.sl"
-    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+    shlibpath_var=SHLIB_PATH
+    aux_shlibpath_var=LD_LIBRARY_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
     library_names_spec='${libname}${release}${shared_ext}$versuffix 
${libname}${release}${shared_ext}$major $libname${shared_ext}'
     soname_spec='${libname}${release}${shared_ext}$major'
@@ -2567,7 +2569,8 @@ irix5* | irix6* | nonstopux*)
     esac
     ;;
   esac
-  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_var=LD_LIBRARY_PATH
+  aux_shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
   shlibpath_overrides_runpath=no
   sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} 
/usr/local/lib${libsuff}"
   sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
@@ -2719,6 +2722,10 @@ solaris*)
   library_names_spec='${libname}${release}${shared_ext}$versuffix 
${libname}${release}${shared_ext}$major $libname${shared_ext}'
   soname_spec='${libname}${release}${shared_ext}$major'
   shlibpath_var=LD_LIBRARY_PATH
+  case $host_cpu in
+    x86_64) aux_shlibpath_var=LD_LIBRARY_PATH_64 ;;
+    i386)   aux_shlibpath_var=LD_LIBRARY_PATH_32 ;;
+  esac
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
   # ldd complains unless libraries are executable
@@ -2837,6 +2844,7 @@ _LT_DECL([], [need_version], [0], [Do we need a version 
for libraries?])
 _LT_DECL([], [version_type], [0], [Library versioning type])
 _LT_DECL([], [runpath_var], [0],  [Shared library runtime path variable])
 _LT_DECL([], [shlibpath_var], [0],[Shared library path variable])
+_LT_DECL([], [aux_shlibpath_var], [0], [Auxiliary shared library path 
variable])
 _LT_DECL([], [shlibpath_overrides_runpath], [0],
     [Is shlibpath searched before the hard-coded library search path?])
 _LT_DECL([], [libname_spec], [1], [Format of library name prefix])
diff --git a/libltdl/m4/ltdl.m4 b/libltdl/m4/ltdl.m4
index 42e07e9..4c63c3e 100644
--- a/libltdl/m4/ltdl.m4
+++ b/libltdl/m4/ltdl.m4
@@ -573,11 +573,19 @@ AC_DEFUN([LT_SYS_MODULE_PATH],
 [m4_require([_LT_SYS_DYNAMIC_LINKER])dnl
 AC_CACHE_CHECK([which variable specifies run-time module search path],
   [lt_cv_module_path_var], [lt_cv_module_path_var="$shlibpath_var"])
+AC_CACHE_CHECK([which auxiliary variable specifies run-time module search 
path],
+  [lt_cv_module_aux_path_var], 
[lt_cv_module_aux_path_var="$aux_shlibpath_var"])
 if test -n "$lt_cv_module_path_var"; then
   m4_pattern_allow([LT_MODULE_PATH_VAR])dnl
   AC_DEFINE_UNQUOTED([LT_MODULE_PATH_VAR], ["$lt_cv_module_path_var"],
     [Define to the name of the environment variable that determines the 
run-time module search path.])
 fi
+if test -n "$lt_cv_module_aux_path_var"; then
+  m4_pattern_allow([LT_MODULE_AUX_PATH_VAR])dnl
+  AC_DEFINE_UNQUOTED([LT_MODULE_AUX_PATH_VAR], ["$lt_cv_module_aux_path_var"],
+    [Define to the name of the environment variable that determines the
+     auxiliary run-time module search path.])
+fi
 ])# LT_SYS_MODULE_PATH
 
 # Old name:
diff --git a/tests/shlibpath.at b/tests/shlibpath.at
index eea059b..ba0c241 100644
--- a/tests/shlibpath.at
+++ b/tests/shlibpath.at
@@ -71,3 +71,88 @@ fi
 LT_AT_EXEC_CHECK([./m2], [0], [ignore], [ignore])
 
 AT_CLEANUP
+
+
+AT_SETUP([aux_shlibpath_var])
+
+# This test aims to verify that the semantics that we intend aux_shlibpath_var
+# to have match the system; i.e., it tries to verify libtool.m4 not ltmain.
+
+eval "`$LIBTOOL --config | $EGREP '^((aux)?shlibpath_var)='`"
+AT_CHECK([test -n "$aux_shlibpath_var" || exit 77])
+# Static linking is not interesting.
+AT_CHECK([$LIBTOOL --features | grep 'enable shared libraries' || exit 77],
+        [], [ignore])
+# This test is not fit for cross compilation.
+AT_CHECK([test "$host" = "$build" || exit 77])
+# This test does not handle a shlibpath_var of PATH correctly.
+AT_CHECK([test "$shlibpath_var" != PATH || exit 77])
+
+# Hypothesis: the variable names are different.
+AT_CHECK([test "$shlibpath_var" != "$aux_shlibpath_var"])
+
+AT_DATA([a1.c],
+[[int a () { return 0; }
+]])
+
+AT_DATA([a2.c],
+[[int a () { return 42; }
+]])
+
+AT_DATA([main.c],
+[[extern int a ();
+int main () { return a (); }
+]])
+
+inst=`pwd`/inst
+for n in 1 2; do
+  mkdir -p a$n inst/lib
+  AT_CHECK([$LIBTOOL --tag=CC --tag=disable-static --mode=compile ]dnl
+          [$CC $CPPFLAGS $CFLAGS -c a$n.c], [], [ignore], [ignore])
+  AT_CHECK([$LIBTOOL --tag=CC --tag=disable-static --mode=link ]dnl
+          [$CC $CFLAGS $LDFLAGS -o a$n/liba.la a$n.lo -rpath $inst/lib],
+          [], [ignore], [ignore])
+  AT_CHECK([$LIBTOOL --mode=install cp a$n/liba.la $inst/lib/liba.la],
+          [], [ignore], [ignore])
+  AT_CHECK([mv inst/lib inst/lib$n])
+done
+$CC $CPPFLAGS $CFLAGS -c main.c
+mv inst/lib1 inst/lib
+AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -no-install -o main$EXEEXT 
]dnl
+        [main.$OBJEXT -Linst/lib -la], [], [ignore], [ignore])
+mv inst/lib inst/lib1
+
+sep=
+eval test -n \"\$$shlibpath_var\" && sep=:
+auxsep=
+eval test -n \"\$$aux_shlibpath_var\" && auxsep=:
+
+# Prerequisite: setting shlibpath_var can be used to actually find the library.
+# We cannot use $LIBTOOL because we want to verify the semantics of the
+# libtool.m4 settings and not rely on stuff inside the libtool script.
+AT_CHECK([eval "$shlibpath_var=\$inst/lib1\$sep\$$shlibpath_var 
./main\$EXEEXT" || exit 77],
+        [], [ignore], [ignore])
+
+# Hypothesis: aux_shlibpath_var can be used to find the library.
+AT_CHECK([eval "$aux_shlibpath_var=\$inst/lib1\$auxsep\$$aux_shlibpath_var 
./main\$EXEEXT"],
+        [], [ignore], [ignore])
+
+# Hypothesis: setting shlibpath_var or aux_shlibpath_var right is *necessary*
+# to find the moved library.
+AT_CHECK([./main\$EXEEXT || exit 1], [1], [ignore], [ignore])
+AT_CHECK([eval "$shlibpath_var=\$inst/lib2\$sep\$$shlibpath_var 
./main\$EXEEXT"],
+        [42], [ignore], [ignore])
+AT_CHECK([eval "$aux_shlibpath_var=\$inst/lib2\$auxsep\$$aux_shlibpath_var 
./main\$EXEEXT"],
+        [42], [ignore], [ignore])
+
+# Hypothesis: aux_shlibpath_var, if set, overrides shlibpath_var.
+AT_CHECK([eval "$shlibpath_var=\$inst/lib2\$sep\$$shlibpath_var ]dnl
+        [      $aux_shlibpath_var=\$inst/lib1\$auxsep\$$aux_shlibpath_var ]dnl
+        [./main\$EXEEXT"], [], [ignore], [ignore])
+AT_CHECK([eval "$shlibpath_var=\$inst/lib1\$sep\$$shlibpath_var ]dnl
+        [      $aux_shlibpath_var=\$inst/lib2\$auxsep\$$aux_shlibpath_var ]dnl
+        [./main\$EXEEXT"], [42], [ignore], [ignore])
+
+# TODO: Semantics for dlopening.
+
+AT_CLEANUP




    Adjust existing testsuite tests for aux_shlibpath_var.
    
    * tests/demo/Makefile.am (hc-libpath): Also set
    $aux_shlibpath_var if appropriate.
    * tests/pdemo/Makefile.am (hc-libpath): Likewise.
    * tests/link-order2.at (Link order of deplibs): If
    $aux_shlibpath_var is set, prepend to that, instead of
    prepending to $shlibpath_var.
    * tests/shlibpath.at (shlibpath_overrides_runpath):
    Likewise.
    * tests/lt_dlopenext.at (lt_dlopenext error messages):
    Also try finding the variable by setting $aux_shlibpath_var
    if aux_shlibpath_var is nonempty.

diff --git a/tests/demo/Makefile.am b/tests/demo/Makefile.am
index a3c6144..8324f36 100644
--- a/tests/demo/Makefile.am
+++ b/tests/demo/Makefile.am
@@ -127,11 +127,15 @@ hc-libpath: $(hell_OBJECTS) $(hell_DEPENDENCIES) 
$(libdir)/libhello.la
        @rm -f hc-libpath
        @echo "You may ignore any linking errors from the following command:"
        @$(SET_HARDCODE_FLAGS); \
-         eval `$(LIBTOOL) --config | grep '^shlibpath_var='`; \
+         eval `$(LIBTOOL) --config | $(EGREP) '^(aux_)?shlibpath_var='`; \
+         if test -z "$$aux_shlibpath_var" \
+            || eval test -z \"\$$$$aux_shlibpath_var\"; then \
+           aux_shlibpath_var=innocent_var; \
+         fi; \
          libdir=$(libdir); \
          flag=`eval echo \"$$hardcode_libdir_flag_spec\"`; \
-         echo "$$shlibpath_var=./$(objdir) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ 
$(hell_OBJECTS) -lhello $(LIBS) $(LIBM) $$flag || echo unsupported > $@"; \
-         eval "$$shlibpath_var=./$(objdir) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ 
$(hell_OBJECTS) -lhello $(LIBS) $(LIBM) $$flag || echo unsupported > $@"
+         echo "$$aux_shlibpath_var=./$(objdir) $$shlibpath_var=./$(objdir) 
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(hell_OBJECTS) -lhello $(LIBS) $(LIBM) $$flag 
|| echo unsupported > $@"; \
+         eval "$$aux_shlibpath_var=./$(objdir) $$shlibpath_var=./$(objdir) 
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(hell_OBJECTS) -lhello $(LIBS) $(LIBM) $$flag 
|| echo unsupported > $@"
 
 hc-minusL: $(hell_OBJECTS) $(hell_DEPENDENCIES)
        @rm -f hc-minusL
diff --git a/tests/link-order2.at b/tests/link-order2.at
index a6eea0e..5ba3c32 100644
--- a/tests/link-order2.at
+++ b/tests/link-order2.at
@@ -1,6 +1,6 @@
 # link-order2.at -- test link order of deplibs                -*- Autotest -*-
 #
-#   Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
+#   Copyright (C) 2006, 2007, 2008, 2010 Free Software Foundation, Inc.
 #   Written by Ralf Wildenhues, 2006
 #
 #   This file is part of GNU Libtool.
@@ -47,7 +47,7 @@ AT_SETUP([Link order of deplibs])
 AT_KEYWORDS([libtool])
 AT_KEYWORDS([interactive])dnl running 'wrong' may cause a popup window.
 
-eval `$LIBTOOL --config | $EGREP '^(shlibpath_var|allow_undefined_flag)='`
+eval `$LIBTOOL --config | $EGREP 
'^((aux_)?shlibpath_var|allow_undefined_flag)='`
 
 undefined_setting=-no-undefined
 shared_fails=no
@@ -108,9 +108,16 @@ for type_of_depdepl in libtool non-libtool; do
       addpath=$defbindir
     fi
     sep=
-    eval test -n \"\$$shlibpath_var\" && sep=:
-    eval $shlibpath_var='$addpath$sep$'$shlibpath_var
-    export $shlibpath_var
+    if test -n "$aux_shlibpath_var" \
+       && eval test \"\${$aux_shlibpath_var+set}\" = set; then
+      eval test -n \"\$$aux_shlibpath_var\" && sep=:
+      eval $aux_shlibpath_var='$addpath$sep$'$aux_shlibpath_var
+      export $aux_shlibpath_var
+    else
+      eval test -n \"\$$shlibpath_var\" && sep=:
+      eval $shlibpath_var='$addpath$sep$'$shlibpath_var
+      export $shlibpath_var
+    fi
   fi
   for static in '' -static-libtool-libs; do
     case `$LIBTOOL --features` in
diff --git a/tests/lt_dlopenext.at b/tests/lt_dlopenext.at
index 6631124..918e098 100644
--- a/tests/lt_dlopenext.at
+++ b/tests/lt_dlopenext.at
@@ -212,7 +212,7 @@ AT_CHECK([$LIBTOOL --mode=clean rm -f simple-module.la], 
[], [ignore], [ignore])
 # Finding the module without the .la file will not work if MODULE_EXT
 # aka. shared_ext is empty.
 
-eval `$LIBTOOL --config | $EGREP '^(shlibpath_var|shrext_cmds)='`
+eval `$LIBTOOL --config | $EGREP '^((aux_)?shlibpath_var|shrext_cmds)='`
 
 module=no
 eval shared_ext=\"$shrext_cmds\"
@@ -236,7 +236,7 @@ for lafile in $have_lafile; do
                     [$dir/simple-module World])
     AT_CHECK([grep "Hello, World" stdout], [], [ignore])
 
-    for var in MODULE_PATH LTDL_LIBRARY_PATH $shlibpath_var
+    for var in MODULE_PATH LTDL_LIBRARY_PATH $aux_shlibpath_var $shlibpath_var
     do
       eval $var=\$dir
       export $var
diff --git a/tests/pdemo/Makefile.am b/tests/pdemo/Makefile.am
index 91fe1e2..5dde2b6 100644
--- a/tests/pdemo/Makefile.am
+++ b/tests/pdemo/Makefile.am
@@ -120,11 +120,15 @@ hc-libpath: $(hell_OBJECTS) $(hell_DEPENDENCIES) 
$(libdir)/libhello.la
        @rm -f hc-libpath
        @echo "You may ignore any linking errors from the following command:"
        @$(SET_HARDCODE_FLAGS); \
-         eval `$(LIBTOOL) --config | grep '^shlibpath_var='`; \
+         eval `$(LIBTOOL) --config | $(EGREP) '^(aux_)?shlibpath_var='`; \
+         if test -z "$$aux_shlibpath_var" \
+            || eval test -z \"\$$$$aux_shlibpath_var\"; then \
+           aux_shlibpath_var=innocent_var; \
+         fi; \
          libdir=$(libdir); \
          flag=`eval echo \"$$hardcode_libdir_flag_spec\"`; \
-         echo "$$shlibpath_var=./$(objdir) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ 
$(hell_OBJECTS) -lhello $(LIBS) $(LIBM) $$flag || echo unsupported > $@"; \
-         eval "$$shlibpath_var=./$(objdir) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ 
$(hell_OBJECTS) -lhello $(LIBS) $(LIBM) $$flag || echo unsupported > $@"
+         echo "$$aux_shlibpath_var=./$(objdir) $$shlibpath_var=./$(objdir) 
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(hell_OBJECTS) -lhello $(LIBS) $(LIBM) $$flag 
|| echo unsupported > $@"; \
+         eval "$$aux_shlibpath_var=./$(objdir) $$shlibpath_var=./$(objdir) 
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(hell_OBJECTS) -lhello $(LIBS) $(LIBM) $$flag 
|| echo unsupported > $@"
 
 hc-minusL: $(hell_OBJECTS) $(hell_DEPENDENCIES)
        @rm -f hc-minusL
diff --git a/tests/shlibpath.at b/tests/shlibpath.at
index ba0c241..4d341a1 100644
--- a/tests/shlibpath.at
+++ b/tests/shlibpath.at
@@ -48,7 +48,7 @@ $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o liba.la a.lo 
-rpath `pwd`/sub/lib
 $LIBTOOL --mode=install cp liba.la `pwd`/sub/lib/liba.la
 $LIBTOOL --mode=clean rm -f liba.la
 
-eval `$LIBTOOL --config | $EGREP 
'^(shlibpath_var|shlibpath_overrides_runpath)='`
+eval `$LIBTOOL --config | $EGREP 
'^((aux_)?shlibpath_var|shlibpath_overrides_runpath)='`
 
 # No point checking a system with static libraries:
 LT_AT_EXEC_CHECK([./m], [1], [ignore], [ignore], [|| exit 1 && exit 77])
@@ -59,9 +59,16 @@ else
   addpath=`pwd`/moved/lib
 fi
 sep=
-eval test -n \"\$$shlibpath_var\" && sep=:
-eval $shlibpath_var='$addpath$sep$'$shlibpath_var
-export $shlibpath_var
+if test -n "$aux_shlibpath_var" \
+   && eval test \"\${$aux_shlibpath_var+set}\" = set; then
+  eval test -n \"\$$aux_shlibpath_var\" && sep=:
+  eval $aux_shlibpath_var='$addpath$sep$'$aux_shlibpath_var
+  export $aux_shlibpath_var
+else
+  eval test -n \"\$$shlibpath_var\" && sep=:
+  eval $shlibpath_var='$addpath$sep$'$shlibpath_var
+  export $shlibpath_var
+fi
 if test "$shlibpath_overrides_runpath" != no; then
   LT_AT_EXEC_CHECK([./m], [0], [ignore], [ignore])
 else



reply via email to

[Prev in Thread] Current Thread [Next in Thread]