public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [8/8] Tidy up testsuite handling of LD_LIBRARY_PATH (needs   testsuite maintainer)
@ 2009-07-02 14:41 David Edelsohn
  2009-07-02 15:56 ` David Edelsohn
  0 siblings, 1 reply; 5+ messages in thread
From: David Edelsohn @ 2009-07-02 14:41 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: gcc-patches

Richard,

This patch actually breaks some of the testsuite on AIX.

> The patch adds a new function, find_libgcc_s, that finds the
> libgcc_s directory for the current multilib.  The patch also adds a
> utility function called add_path for adding new components to a path.
> This function is a no-op if the new component is empty, avoiding the
> empty path problem mentioned in (2) above.

This design is fine for 32/64, but makes an incorrect assumption about
pthread support.  Some components in GCC, such as libgomp, always are
built with pthreads enabled -- the pthread and non-pthread multilibs
are identical.  By default, the testsuite runs in 32 bit, non-pthread
mode, so the explicit overriding of LD_LIBRARY_PATH does not insert
the pthread directory and all tests fail.  The original logic added
pthread because libgomp requires pthreads.

David

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [8/8] Tidy up testsuite handling of LD_LIBRARY_PATH (needs   testsuite maintainer)
  2009-07-02 14:41 [8/8] Tidy up testsuite handling of LD_LIBRARY_PATH (needs testsuite maintainer) David Edelsohn
@ 2009-07-02 15:56 ` David Edelsohn
  2009-07-02 19:44   ` Richard Sandiford
  0 siblings, 1 reply; 5+ messages in thread
From: David Edelsohn @ 2009-07-02 15:56 UTC (permalink / raw)
  To: Richard Sandiford, janis187; +Cc: gcc-patches

Richard,

The appended patch fixes libgomp for me.  I do not know if there is a
better / cleaner way.  I tried setting TARGET_OPTIONS to -pthread for
target AIX, but that did not seem to affect the multilib directory
choice.

Thanks, David

libgomp/

* testsuite/lib/libgomp.exp (libgomp_init): Append "/pthread" to
ld_library_path for AIX.

Index: libgomp.exp
===================================================================
--- libgomp.exp (revision 149150)
+++ libgomp.exp (working copy)
@@ -87,7 +87,12 @@
     }

     set always_ld_library_path "${blddir}/.libs"
-    add_path always_ld_library_path [find_libgcc_s $GCC_UNDER_TEST]
+    set dir [find_libgcc_s $GCC_UNDER_TEST]
+    # Append "/pthread" for AIX
+    if { [istarget *-*-aix*] && $dir != "" } {
+       append dir "/pthread"
+    }
+    add_path always_ld_library_path $dir

     set ALWAYS_CFLAGS ""
     if { $blddir != "" } {

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [8/8] Tidy up testsuite handling of LD_LIBRARY_PATH (needs   testsuite maintainer)
  2009-07-02 15:56 ` David Edelsohn
@ 2009-07-02 19:44   ` Richard Sandiford
  2009-07-02 21:21     ` Janis Johnson
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Sandiford @ 2009-07-02 19:44 UTC (permalink / raw)
  To: David Edelsohn; +Cc: janis187, gcc-patches

I just wanted to say a public "sorry" for all the fallout from this patch.
Something obviosly went wrong with my testing.

David Edelsohn <dje.gcc@gmail.com> writes:
> The appended patch fixes libgomp for me.  I do not know if there is a
> better / cleaner way.  I tried setting TARGET_OPTIONS to -pthread for
> target AIX, but that did not seem to affect the multilib directory
> choice.

libgomp stores various libgomp-specific options in a variable called
ALWAYS_CFLAGS.  These options are then used in every compilation test.
The problem is that the same options aren't included when running
"$cc --print-multi-lib", so the compiler isn't aware that
we're using -fopenmp, and thus need pthreads.

The patch below "fixes" this.  I sent it to David privately because the
AIX machine I use is down at the moment, and he confirms it fixes the
problem (thanks!).  OK to install?

Richard


libgomp/
	* testsuite/lib/libgomp.exp (libgomp_init): Use the ALWAYS_CFLAGS
	options when choosing a multilib.

Index: libgomp/testsuite/lib/libgomp.exp
===================================================================
--- libgomp/testsuite/lib/libgomp.exp	2009-07-01 09:02:12.000000000 +0100
+++ libgomp/testsuite/lib/libgomp.exp	2009-07-02 18:18:12.000000000 +0100
@@ -86,9 +86,6 @@ proc libgomp_init { args } {
 	set CFLAGS ""
     }
 
-    set always_ld_library_path "${blddir}/.libs"
-    add_path always_ld_library_path [find_libgcc_s $GCC_UNDER_TEST]
-
     set ALWAYS_CFLAGS ""
     if { $blddir != "" } {
         lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/"
@@ -122,6 +119,16 @@ proc libgomp_init { args } {
 
     # And, gee, turn on OpenMP.
     lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
+
+    set compiler $GCC_UNDER_TEST
+    foreach flag $ALWAYS_CFLAGS {
+	if { [regexp {^(additional_flags|ldflags)=(.*)} $flag d1 d2 option] } {
+	    lappend compiler $option
+	}
+    }
+
+    set always_ld_library_path "${blddir}/.libs"
+    add_path always_ld_library_path [find_libgcc_s $compiler]
 }
 
 #

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [8/8] Tidy up testsuite handling of LD_LIBRARY_PATH (needs  testsuite maintainer)
  2009-07-02 19:44   ` Richard Sandiford
@ 2009-07-02 21:21     ` Janis Johnson
  0 siblings, 0 replies; 5+ messages in thread
From: Janis Johnson @ 2009-07-02 21:21 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: David Edelsohn, gcc-patches

On Thu, 2009-07-02 at 20:38 +0100, Richard Sandiford wrote:
> I just wanted to say a public "sorry" for all the fallout from this patch.
> Something obviosly went wrong with my testing.

Testsuite infrastructure cleanups usually break something somewhere,
but thanks for handling it quickly.

> David Edelsohn <dje.gcc@gmail.com> writes:
> > The appended patch fixes libgomp for me.  I do not know if there is a
> > better / cleaner way.  I tried setting TARGET_OPTIONS to -pthread for
> > target AIX, but that did not seem to affect the multilib directory
> > choice.
> 
> libgomp stores various libgomp-specific options in a variable called
> ALWAYS_CFLAGS.  These options are then used in every compilation test.
> The problem is that the same options aren't included when running
> "$cc --print-multi-lib", so the compiler isn't aware that
> we're using -fopenmp, and thus need pthreads.
> 
> The patch below "fixes" this.  I sent it to David privately because the
> AIX machine I use is down at the moment, and he confirms it fixes the
> problem (thanks!).  OK to install?

OK.

Janis

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [8/8] Tidy up testsuite handling of LD_LIBRARY_PATH (needs testsuite maintainer)
  2009-06-02 12:03 [0/8] AIX cross toolchains Richard Sandiford
@ 2009-06-02 12:33 ` Richard Sandiford
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Sandiford @ 2009-06-02 12:33 UTC (permalink / raw)
  To: gcc-patches

This patch tries to tidy up (and tighten up) the runtime library paths
that we use during testing.  From an AIX standpoint, the two main problems
with the current paths are:

  (1) We often add the directories for all libgcc_s multilibs,
      not just the current multilib.

  (2) We often add the current directory to the path, either explicitly
      through "." or implicitly (and probably accidentally) by having
      empty path components like ":foo:bar:..." or "foo::bar:...".

This is redundant but harmless on most unixy targets, which skip
libraries that don't use the right ABI.  However, it's wrong on AIX
for two reasons:

  - We have separate multilibs for AIX threads and POSIX threads.
    This has led to the following special case in libgomp:

	# Add AIX pthread directory first.
	if { [llength [glob -nocomplain ${gccdir}/pthread/libgcc_s*.a]] >= 1 } {
	    append always_ld_library_path ":${gccdir}/pthread"
	}

    but the problem hits libstdc++ too.

  - AIX shared libraries are normal .a archives that have shared
    objects within them.  Archives aren't ABI-specific, and can even
    contain objects that follow different ABIs.  (E.g. you can put
    64-bit and 32-bit shared objects in the same archive.)  The idea of
    "skipping incompatible libraries" is therefore less well-defined
    than it is for other targets, and the loader doesn't try to do it.
    The upshot is that -maix64 tests run against the 32-bit libraries,
    causing every execution test to fail.

There are still some cases where we need "." to be in the path:

  - Some testsuites might build their own shared libraries and store
    them in the current directory.  There's nothing wrong with this
    _provided that_ "." doesn't also contain installable libraries
    for the default multilib.

    libjava falls into this category (and its "." is safe).

    I think the default should be not to be add "." to the path.
    The testsuites that really do need "." to be in the path
    should then add it explicitly, with a comment explaining why.

  - Some remote-testing setups copy libraries to the target's
    current directory.

    I think these setups should add "."  to the library paths themselves,
    such as by adding it to the appropriate environment variable.  Using
    "." can be actively harmful for other remote-testing setups.

The patch adds a new function, find_libgcc_s, that finds the
libgcc_s directory for the current multilib.  The patch also adds a
utility function called add_path for adding new components to a path.
This function is a no-op if the new component is empty, avoiding the
empty path problem mentioned in (2) above.

There's a further problem that I don't try to fix here.  When running
tests natively, we use the new library paths for both the compilation
and execution phases of a test.  This means that we run the compiler
itself with the new paths.  These days, the compilers (can) depend on
libgcc_s via libmpfr, and we'll end up using the newly-built libgcc_s
instead of the usual one.

Again, this probably isn't much of a problem on most unixy systems,
because the loader can skip objects that use the wrong ABI, and because
libgcc_s is supposed to be backwards-compatible.  But it causes problems
on AIX when the multilib you're testing is not the one that the compiler
itself uses, for the same reasons as above.

Tested on powerpc-ibm-aix6.1 and x86_64-linux-gnu.  OK to install?

Richard


gcc/testsuite/
	* lib/gcc-defs.exp (gcc-set-multilib-library-path): Delete.
	* lib/target-libpath.exp (ld_library_path_vars): New variable.
	(init_ld_library_path_env_vars): New function, replacing the
	orig_*_saved assignments.  Call it after defining it.
	(set_ld_library_path_env_vars): Rewrite to use ld_library_path_vars.
	(restore_ld_library_path_env_vars): Likewise.
	(add_path, find_libgcc_s): New functions.
	* lib/objc.exp (objc_init): Use find_libgcc_s instead of
	gcc-set-multilib-library-path.
	(objc_target_compile): Don't add "." to ld_library_path.
	Use add_path.
	* lib/gfortran.exp (gfortran_link_flags): Don't add "." to
	ld_library_path.  Use add_path.  Use find_libgcc_s instead of
	gcc-set-multilib-library-path.
	* lib/g++.exp (g++_link_flags): Likewise.
	* lib/obj-c++.exp (obj-c++_link_flags): Likewise.
	* lib/c-torture.exp: Do not manipulate ld_library_path at the
	top level; do it...
	(c-torture-execute): ...here instead.  Use $ld_library_path_multilib
	to tell when this needs to happen.  Use find_libgcc_s instead of
	gcc-set-multilib-library-path.
	* lib/gcc-dg.exp: Likewise.
	* lib/gnat.exp (gnat_target_compile): Don't add "." to ld_library_path.
	* g++.dg/compat/compat.exp (alt_ld_library_path): Don't add "."
	unless it is in $ALT_LD_LIBRARY_PATH.
	* g++.dg/compat/struct-layout-1.exp (alt_ld_library_path): Likewise.

libffi/
	* testsuite/lib/libffi-dg.exp (libffi-init): Don't add "."
	to ld_library_path.  Use add_path.  Add just find_libgcc_s
	to ld_library_path, not every libgcc multilib directory.

libgomp/
	* testsuite/lib/libgomp.exp (libgomp_init): Don't add "." to
	ld_library_path.  Use add_path.  Add just find_libgcc_s to
	ld_library_path, not every libgcc multilib directory.
	* testsuite/libgomp.c/c.exp (ld_library_path): Don't call
	gcc-set-multilib-library-path; rely on $always_ld_library_path instead.
	* testsuite/libgomp.c++/c++.exp (ld_library_path): Likewise.
	Use add_path.
	* testsuite/libgomp.fortran/fortran.exp (ld_library_path): Likewise.

libjava/
	* testsuite/lib/libjava.exp (libjava_init): Just add
	find_libgcc_s to libjava_libgcc_s_path, rather than every
	libgcc multilib directory.
	(libjava_arguments): Explain why we add "." to ld_library_path.
	(gcj_invoke, exec_gij, libjava_invoke): Use add_path.

libmudflap/
	* testsuite/lib/libmudflap.exp (libmudflap-init): Don't add "."
	to ld_library_path.  Use add_path.  Add just find_libgcc_s to
	ld_library_path, not every libgcc multilib directory.

libstdc++-v3/
	* testsuite/lib/libstdc++.exp (libstdc++_init): Don't add "."
	to ld_library_path.  Use add_path.  Add just find_libgcc_s to
	ld_library_path, not every libgcc multilib directory.

Index: gcc/testsuite/lib/gcc-defs.exp
===================================================================
--- gcc/testsuite/lib/gcc-defs.exp	2009-06-02 13:05:35.000000000 +0100
+++ gcc/testsuite/lib/gcc-defs.exp	2009-06-02 13:06:11.000000000 +0100
@@ -233,35 +233,3 @@ proc dg-additional-files-options { optio
 
     return $options
 }
-
-# Return a colon-separate list of directories to search for libraries
-# for COMPILER, including multilib directories.
-
-proc gcc-set-multilib-library-path { compiler } {
-    global rootme
-
-    # ??? rootme will not be set when testing an installed compiler.
-    # In that case, we should perhaps use some other method to find
-    # libraries.
-    if {![info exists rootme]} {
-	return ""
-    }
-
-    set libpath ":${rootme}"
-    set compiler [lindex $compiler 0]
-    if { [is_remote host] == 0 && [which $compiler] != 0 } {
-	foreach i "[exec $compiler --print-multi-lib]" {
-	    set mldir ""
-	    regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
-	    set mldir [string trimright $mldir "\;@"]
-	    if { "$mldir" == "." } {
-		continue
-	    }
-	    if { [llength [glob -nocomplain ${rootme}/${mldir}/libgcc_s*.so.*]] >= 1 } {
-		append libpath ":${rootme}/${mldir}"
-	    }
-	}
-    }
-
-    return $libpath
-}
Index: gcc/testsuite/lib/target-libpath.exp
===================================================================
--- gcc/testsuite/lib/target-libpath.exp	2009-06-02 13:05:35.000000000 +0100
+++ gcc/testsuite/lib/target-libpath.exp	2009-06-02 13:06:11.000000000 +0100
@@ -16,175 +16,106 @@
 
 # This file was contributed by John David Anglin (dave.anglin@nrc-cnrc.gc.ca)
 
+# A list of ld library path environment variables that might need to be
+# defined.
+#
+# Some variables represent ABI-specific paths, and if these variables
+# aren't defined, the dynamic loader might fall back on a more general
+# variable.  We must do the same when trying to read the current setting
+# of such a path.  Each element of this list is therefore itself a list:
+# the first element of each sublist specifies the name of the variable,
+# and the other elements specify fallback alternatives.  We use FOO as a
+# shorthand for { FOO }.
+set ld_library_path_vars {
+    LD_LIBRARY_PATH
+    LD_RUN_PATH
+    SHLIB_PATH
+    { LD_LIBRARYN32_PATH LD_LIBRARY_PATH }
+    { LD_LIBRARY64_PATH LD_LIBRARY_PATH }
+    { LD_LIBRARY_PATH_32 LD_LIBRARY_PATH }
+    { LD_LIBRARY_PATH_64 LD_LIBRARY_PATH }
+    DYLD_LIBRARY_PATH
+}
+
+# Set up the global orig_FOO_saved variables.  We define this as a function
+# to avoid polluting the global namespace with local variables.
+proc init_ld_library_path_env_vars { } {
+    global ld_library_path_vars
+
+    foreach spec $ld_library_path_vars {
+	set var orig_[string tolower [lindex $spec 0]]_saved
+	global $var
+	set $var 0
+    }
+}
+init_ld_library_path_env_vars
 set orig_environment_saved 0
-set orig_ld_library_path_saved 0
-set orig_ld_run_path_saved 0
-set orig_shlib_path_saved 0
-set orig_ld_libraryn32_path_saved 0
-set orig_ld_library64_path_saved 0
-set orig_ld_library_path_32_saved 0
-set orig_ld_library_path_64_saved 0
-set orig_dyld_library_path_saved 0
 set orig_gcc_exec_prefix_saved 0
 set orig_gcc_exec_prefix_checked 0
-
+set ld_library_path_multilib unset
 
 #######################################
 # proc set_ld_library_path_env_vars { }
 #######################################
 
 proc set_ld_library_path_env_vars { } {
-  global ld_library_path
-  global orig_environment_saved
-  global orig_ld_library_path_saved
-  global orig_ld_run_path_saved
-  global orig_shlib_path_saved
-  global orig_ld_libraryn32_path_saved
-  global orig_ld_library64_path_saved
-  global orig_ld_library_path_32_saved
-  global orig_ld_library_path_64_saved
-  global orig_dyld_library_path_saved
-  global orig_gcc_exec_prefix_saved
-  global orig_gcc_exec_prefix_checked
-  global orig_ld_library_path
-  global orig_ld_run_path
-  global orig_shlib_path
-  global orig_ld_libraryn32_path
-  global orig_ld_library64_path
-  global orig_ld_library_path_32
-  global orig_ld_library_path_64
-  global orig_dyld_library_path
-  global orig_gcc_exec_prefix
-  global TEST_GCC_EXEC_PREFIX
-  global env
-
-  # Save the original GCC_EXEC_PREFIX.
-  if { $orig_gcc_exec_prefix_checked == 0 } {
-    if [info exists env(GCC_EXEC_PREFIX)] {
-      set orig_gcc_exec_prefix "$env(GCC_EXEC_PREFIX)"
-      set orig_gcc_exec_prefix_saved 1
-    }
-    set orig_gcc_exec_prefix_checked 1
-  }
-
-  # Set GCC_EXEC_PREFIX for the compiler under test to pick up files not in
-  # the build tree from a specified location (normally the install tree).
-  if [info exists TEST_GCC_EXEC_PREFIX] {
-    setenv GCC_EXEC_PREFIX "$TEST_GCC_EXEC_PREFIX"
-  }
-
-  # Setting the ld library path causes trouble when testing cross-compilers.
-  if { [is_remote target] } {
-    return
-  }
-
-  if { $orig_environment_saved == 0 } {
+    global ld_library_path
+    global orig_environment_saved
+    global ld_library_path_vars
+    global orig_gcc_exec_prefix_saved
+    global orig_gcc_exec_prefix_checked
+    global orig_gcc_exec_prefix
+    global TEST_GCC_EXEC_PREFIX
+    global ld_library_path_multilib
+    global env
+
+    # Save the original GCC_EXEC_PREFIX.
+    if { $orig_gcc_exec_prefix_checked == 0 } {
+	if [info exists env(GCC_EXEC_PREFIX)] {
+	    set orig_gcc_exec_prefix "$env(GCC_EXEC_PREFIX)"
+	    set orig_gcc_exec_prefix_saved 1
+	}
+	set orig_gcc_exec_prefix_checked 1
+    }
+
+    # Set GCC_EXEC_PREFIX for the compiler under test to pick up files not in
+    # the build tree from a specified location (normally the install tree).
+    if [info exists TEST_GCC_EXEC_PREFIX] {
+	setenv GCC_EXEC_PREFIX "$TEST_GCC_EXEC_PREFIX"
+    }
+
+    # Setting the ld library path causes trouble when testing cross-compilers.
+    if { [is_remote target] } {
+	return
+    }
+
+    set ld_library_path_multilib [board_info target multilib_flags]
+
+    foreach spec $ld_library_path_vars {
+	set var [lindex $spec 0]
+	set lvar [string tolower $var]
+
+	global orig_$lvar
+	global orig_${lvar}_saved
+
+	if { $orig_environment_saved == 0 } {
+	    if [info exists env($var)] {
+		set orig_$lvar [set env($var)]
+		set orig_${lvar}_saved 1
+	    }
+	}
+	set value $ld_library_path
+	foreach extra $spec {
+	    set lextra [string tolower $extra]
+	    if [set orig_${lextra}_saved] {
+		add_path value [set orig_$lextra]
+		break
+	    }
+	}
+	setenv $var $value
+    }
     set orig_environment_saved 1
-
-    # Save the original environment.
-    if [info exists env(LD_LIBRARY_PATH)] {
-      set orig_ld_library_path "$env(LD_LIBRARY_PATH)"
-      set orig_ld_library_path_saved 1
-    }
-    if [info exists env(LD_RUN_PATH)] {
-      set orig_ld_run_path "$env(LD_RUN_PATH)"
-      set orig_ld_run_path_saved 1
-    }
-    if [info exists env(SHLIB_PATH)] {
-      set orig_shlib_path "$env(SHLIB_PATH)"
-      set orig_shlib_path_saved 1
-    }
-    if [info exists env(LD_LIBRARYN32_PATH)] {
-      set orig_ld_libraryn32_path "$env(LD_LIBRARYN32_PATH)"
-      set orig_ld_libraryn32_path_saved 1
-    }
-    if [info exists env(LD_LIBRARY64_PATH)] {
-      set orig_ld_library64_path "$env(LD_LIBRARY64_PATH)"
-      set orig_ld_library64_path_saved 1
-    }
-    if [info exists env(LD_LIBRARY_PATH_32)] {
-      set orig_ld_library_path_32 "$env(LD_LIBRARY_PATH_32)"
-      set orig_ld_library_path_32_saved 1
-    }
-    if [info exists env(LD_LIBRARY_PATH_64)] {
-      set orig_ld_library_path_64 "$env(LD_LIBRARY_PATH_64)"
-      set orig_ld_library_path_64_saved 1
-    }
-    if [info exists env(DYLD_LIBRARY_PATH)] {
-      set orig_dyld_library_path "$env(DYLD_LIBRARY_PATH)"
-      set orig_dyld_library_path_saved 1
-    }
-  }
-
-  # We need to set ld library path in the environment.  Currently,
-  # unix.exp doesn't set the environment correctly for all systems.
-  # It only sets SHLIB_PATH and LD_LIBRARY_PATH when it executes a
-  # program.  We also need the environment set for compilations, etc.
-  #
-  # On IRIX 6, we have to set variables akin to LD_LIBRARY_PATH, but
-  # called LD_LIBRARYN32_PATH (for the N32 ABI) and LD_LIBRARY64_PATH
-  # (for the 64-bit ABI).  The same applies to Darwin (DYLD_LIBRARY_PATH),
-  # Solaris 32 bit (LD_LIBRARY_PATH_32), Solaris 64 bit (LD_LIBRARY_PATH_64),
-  # and HP-UX (SHLIB_PATH).  In some cases, the variables are independent
-  # of LD_LIBRARY_PATH, and in other cases LD_LIBRARY_PATH is used if the
-  # variable is not defined.
-  #
-  # Doing this is somewhat of a hack as ld_library_path gets repeated in
-  # SHLIB_PATH and LD_LIBRARY_PATH when unix_load sets these variables.
-  if { $orig_ld_library_path_saved } {
-    setenv LD_LIBRARY_PATH "$ld_library_path:$orig_ld_library_path"
-  } else {
-    setenv LD_LIBRARY_PATH "$ld_library_path"
-  }
-  if { $orig_ld_run_path_saved } {
-    setenv LD_RUN_PATH "$ld_library_path:$orig_ld_run_path"
-  } else {
-    setenv LD_RUN_PATH "$ld_library_path"
-  }
-  # The default shared library dynamic path search for 64-bit
-  # HP-UX executables searches LD_LIBRARY_PATH before SHLIB_PATH.
-  # LD_LIBRARY_PATH isn't used for 32-bit executables.  Thus, we
-  # set LD_LIBRARY_PATH and SHLIB_PATH as if they were independent.
-  if { $orig_shlib_path_saved } {
-    setenv SHLIB_PATH "$ld_library_path:$orig_shlib_path"
-  } else {
-    setenv SHLIB_PATH "$ld_library_path"
-  }
-  if { $orig_ld_libraryn32_path_saved } {
-    setenv LD_LIBRARYN32_PATH "$ld_library_path:$orig_ld_libraryn32_path"
-  } elseif { $orig_ld_library_path_saved } {
-    setenv LD_LIBRARYN32_PATH "$ld_library_path:$orig_ld_library_path"
-  } else {
-    setenv LD_LIBRARYN32_PATH "$ld_library_path"
-  }
-  if { $orig_ld_library64_path_saved } {
-    setenv LD_LIBRARY64_PATH "$ld_library_path:$orig_ld_library64_path"
-  } elseif { $orig_ld_library_path_saved } {
-    setenv LD_LIBRARY64_PATH "$ld_library_path:$orig_ld_library_path"
-  } else {
-    setenv LD_LIBRARY64_PATH "$ld_library_path"
-  }
-  if { $orig_ld_library_path_32_saved } {
-    setenv LD_LIBRARY_PATH_32 "$ld_library_path:$orig_ld_library_path_32"
-  } elseif { $orig_ld_library_path_saved } {
-    setenv LD_LIBRARY_PATH_32 "$ld_library_path:$orig_ld_library_path"
-  } else {
-    setenv LD_LIBRARY_PATH_32 "$ld_library_path"
-  }
-  if { $orig_ld_library_path_64_saved } {
-    setenv LD_LIBRARY_PATH_64 "$ld_library_path:$orig_ld_library_path_64"
-  } elseif { $orig_ld_library_path_saved } {
-    setenv LD_LIBRARY_PATH_64 "$ld_library_path:$orig_ld_library_path"
-  } else {
-    setenv LD_LIBRARY_PATH_64 "$ld_library_path"
-  }
-  if { $orig_dyld_library_path_saved } {
-    setenv DYLD_LIBRARY_PATH "$ld_library_path:$orig_dyld_library_path"
-  } else {
-    setenv DYLD_LIBRARY_PATH "$ld_library_path"
-  }
-
-  verbose -log "set_ld_library_path_env_vars: ld_library_path=$ld_library_path"
+    verbose -log "set_ld_library_path_env_vars: ld_library_path=$ld_library_path"
 }
 
 #######################################
@@ -192,77 +123,35 @@ proc set_ld_library_path_env_vars { } {
 #######################################
 
 proc restore_ld_library_path_env_vars { } {
-  global orig_environment_saved
-  global orig_ld_library_path_saved
-  global orig_ld_run_path_saved
-  global orig_shlib_path_saved
-  global orig_ld_libraryn32_path_saved
-  global orig_ld_library64_path_saved
-  global orig_ld_library_path_32_saved
-  global orig_ld_library_path_64_saved
-  global orig_dyld_library_path_saved
-  global orig_gcc_exec_prefix_saved
-  global orig_ld_library_path
-  global orig_ld_run_path
-  global orig_shlib_path
-  global orig_ld_libraryn32_path
-  global orig_ld_library64_path
-  global orig_ld_library_path_32
-  global orig_ld_library_path_64
-  global orig_dyld_library_path
-  global orig_gcc_exec_prefix
-  global env
-
-  if { $orig_gcc_exec_prefix_saved } {
-    setenv GCC_EXEC_PREFIX "$orig_gcc_exec_prefix"
-  } elseif [info exists env(GCC_EXEC_PREFIX)] {
-    unsetenv GCC_EXEC_PREFIX
-  }
-
-  if { $orig_environment_saved == 0 } {
-    return
-  }
-
-  if { $orig_ld_library_path_saved } {
-    setenv LD_LIBRARY_PATH "$orig_ld_library_path"
-  } elseif [info exists env(LD_LIBRARY_PATH)] {
-    unsetenv LD_LIBRARY_PATH
-  }
-  if { $orig_ld_run_path_saved } {
-    setenv LD_RUN_PATH "$orig_ld_run_path"
-  } elseif [info exists env(LD_RUN_PATH)] {
-    unsetenv LD_RUN_PATH
-  }
-  if { $orig_shlib_path_saved } {
-    setenv SHLIB_PATH "$orig_shlib_path"
-  } elseif [info exists env(SHLIB_PATH)] {
-    unsetenv SHLIB_PATH
-  }
-  if { $orig_ld_libraryn32_path_saved } {
-    setenv LD_LIBRARYN32_PATH "$orig_ld_libraryn32_path"
-  } elseif [info exists env(LD_LIBRARYN32_PATH)] {
-    unsetenv LD_LIBRARYN32_PATH
-  }
-  if { $orig_ld_library64_path_saved } {
-    setenv LD_LIBRARY64_PATH "$orig_ld_library64_path"
-  } elseif [info exists env(LD_LIBRARY64_PATH)] {
-    unsetenv LD_LIBRARY64_PATH
-  }
-  if { $orig_ld_library_path_32_saved } {
-    setenv LD_LIBRARY_PATH_32 "$orig_ld_library_path_32"
-  } elseif [info exists env(LD_LIBRARY_PATH_32)] {
-    unsetenv LD_LIBRARY_PATH_32
-  }
-  if { $orig_ld_library_path_64_saved } {
-    setenv LD_LIBRARY_PATH_64 "$orig_ld_library_path_64"
-  } elseif [info exists env(LD_LIBRARY_PATH_64)] {
-    unsetenv LD_LIBRARY_PATH_64
-  }
-  if { $orig_dyld_library_path_saved } {
-    setenv DYLD_LIBRARY_PATH "$orig_dyld_library_path"
-  } elseif [info exists env(DYLD_LIBRARY_PATH)] {
-    unsetenv DYLD_LIBRARY_PATH
-  }
+    global orig_environment_saved
+    global ld_library_path_vars
+    global orig_gcc_exec_prefix_saved
+    global orig_gcc_exec_prefix
+    global env
+
+    if { $orig_gcc_exec_prefix_saved } {
+	setenv GCC_EXEC_PREFIX "$orig_gcc_exec_prefix"
+    } elseif [info exists env(GCC_EXEC_PREFIX)] {
+	unsetenv GCC_EXEC_PREFIX
+    }
+
+    if { $orig_environment_saved == 0 } {
+	return
+    }
+
+    foreach spec $ld_library_path_vars {
+	set var [lindex $spec 0]
+	set lvar [string tolower $var]
+
+	global orig_$lvar
+	global orig_${lvar}_saved
+
+	if [set orig_${lvar}_saved] {
+	    setenv $var [set orig_$lvar]
+	} elseif [info exists env($var)] {
+	    unsetenv $var
+	}
+    }
 }
 
 #######################################
@@ -284,3 +173,46 @@ proc get_shlib_extension { } {
     return $shlib_ext
 }
 
+# If DIR is not an empty string, add it to the end of variable UPPATH,
+# which represents a colon-separated path.
+proc add_path { uppath dir } {
+    upvar $uppath path
+
+    if { $dir != "" } {
+	if { [info exists path] && $path != "" } {
+	    append path ":"
+	}
+	append path $dir
+    }
+}
+
+# Return the directory that contains the shared libgcc for this multilib,
+# or "" if we don't know.
+proc find_libgcc_s { compiler } {
+    # Remote host testing requires an installed compiler (get_multilibs
+    # imposes the same restriction).  It is up to the board file or
+    # tester to make sure that the installed compiler's libraries
+    # can be found in the library path.
+    if { [is_remote host] } {
+	return ""
+    }
+    # The same goes if we can't find the compiler.
+    set compiler_path [which [lindex $compiler 0]]
+    if { $compiler_path == "" } {
+	return ""
+    }
+    # Run the compiler with the current multilib flags to get the
+    # relative multilib directory.
+    set subdir [eval exec $compiler [board_info target multilib_flags] \
+		    --print-multi-directory]
+    # We are only interested in cases where libgcc_s is in the same
+    # directory as the compiler itself.
+    set dir [file dirname $compiler_path]
+    if { $subdir != "." } {
+	set dir [file join $dir $subdir]
+    }
+    if { ![file exists $dir] } {
+	return ""
+    }
+    return $dir
+}
Index: gcc/testsuite/lib/objc.exp
===================================================================
--- gcc/testsuite/lib/objc.exp	2009-06-02 13:05:35.000000000 +0100
+++ gcc/testsuite/lib/objc.exp	2009-06-02 13:06:11.000000000 +0100
@@ -121,7 +121,7 @@ proc objc_init { args } {
 
     objc_maybe_build_wrapper "${tmpdir}/objc-testglue.o"
 
-    set objc_libgcc_s_path [gcc-set-multilib-library-path $OBJC_UNDER_TEST]
+    set objc_libgcc_s_path [find_libgcc_s $OBJC_UNDER_TEST]
 }
 
 proc objc_target_compile { source dest type options } {
@@ -135,7 +135,7 @@ proc objc_target_compile { source dest t
     global objc_libgcc_s_path
     global shlib_ext
 
-    set ld_library_path ".:${objc_libgcc_s_path}"
+    set ld_library_path ${objc_libgcc_s_path}
     lappend options "libs=-lobjc"
     set shlib_ext [get_shlib_extension]
     verbose "shared lib extension: $shlib_ext"
@@ -191,7 +191,7 @@ proc objc_target_compile { source dest t
 	set libobjc_dir [file dirname ${libobjc_dir}]
 	set objc_link_flags "-L${libobjc_dir}"
 	lappend options "additional_flags=${objc_link_flags}"
-	append ld_library_path ":${libobjc_dir}"
+	add_path ld_library_path ${libobjc_dir}
     }
     if { $type == "precompiled_header" } {
 	# If we generating a precompiled header, we have say this is an
Index: gcc/testsuite/lib/gfortran.exp
===================================================================
--- gcc/testsuite/lib/gfortran.exp	2009-06-02 13:05:35.000000000 +0100
+++ gcc/testsuite/lib/gfortran.exp	2009-06-02 13:06:11.000000000 +0100
@@ -84,7 +84,7 @@ proc gfortran_link_flags { paths } {
     set gccpath ${paths}
     set libio_dir ""
     set flags ""
-    set ld_library_path "."
+    set ld_library_path ""
     set shlib_ext [get_shlib_extension]
     verbose "shared lib extension: $shlib_ext"
 
@@ -94,11 +94,11 @@ proc gfortran_link_flags { paths } {
           # for uninstalled testing.
           append flags "-B${gccpath}/libgfortran/.libs "
           append flags "-L${gccpath}/libgfortran/.libs "
-          append ld_library_path ":${gccpath}/libgfortran/.libs"
+	  add_path ld_library_path "${gccpath}/libgfortran/.libs"
       }
       if [file exists "${gccpath}/libgfortran/.libs/libgfortran.${shlib_ext}"] {
 	  append flags "-L${gccpath}/libgfortran/.libs "
-	  append ld_library_path ":${gccpath}/libgfortran/.libs"
+	  add_path ld_library_path "${gccpath}/libgfortran/.libs"
       }
       if [file exists "${gccpath}/libgfortran/libgforbegin.a"] {
           append flags "-L${gccpath}/libgfortran "
@@ -106,8 +106,7 @@ proc gfortran_link_flags { paths } {
       if [file exists "${gccpath}/libiberty/libiberty.a"] {
           append flags "-L${gccpath}/libiberty "
       }
-      append ld_library_path \
-	[gcc-set-multilib-library-path $GFORTRAN_UNDER_TEST]
+      add_path ld_library_path [find_libgcc_s $GFORTRAN_UNDER_TEST]
     }
 
     set_ld_library_path_env_vars
Index: gcc/testsuite/lib/g++.exp
===================================================================
--- gcc/testsuite/lib/g++.exp	2009-06-02 13:05:35.000000000 +0100
+++ gcc/testsuite/lib/g++.exp	2009-06-02 13:06:11.000000000 +0100
@@ -106,52 +106,51 @@ proc g++_link_flags { paths } {
     set gccpath ${paths}
     set libio_dir ""
     set flags ""
-    set ld_library_path "."
+    set ld_library_path ""
 
     set shlib_ext [get_shlib_extension]
     verbose "shared lib extension: $shlib_ext"
 
     if { $gccpath != "" } {
       if [file exists "${gccpath}/lib/libstdc++.a"] {
-          append ld_library_path ":${gccpath}/lib"
+	  add_path ld_library_path "${gccpath}/lib"
       }
       if [file exists "${gccpath}/libg++/libg++.a"] {
           append flags "-L${gccpath}/libg++ "
-          append ld_library_path ":${gccpath}/libg++"
+	  add_path ld_library_path "${gccpath}/libg++"
       }
       if [file exists "${gccpath}/libstdc++/libstdc++.a"] {
           append flags "-L${gccpath}/libstdc++ "
-          append ld_library_path ":${gccpath}/libstdc++"
+	  add_path ld_library_path "${gccpath}/libstdc++"
       }
       if [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] {
           append flags " -L${gccpath}/libstdc++-v3/src/.libs "
-          append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
+	  add_path ld_library_path "${gccpath}/libstdc++-v3/src/.libs"
       }
       # Look for libstdc++.${shlib_ext}.
       if [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] {
 	  append flags " -L${gccpath}/libstdc++-v3/src/.libs "
-	  append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
+	  add_path ld_library_path "${gccpath}/libstdc++-v3/src/.libs"
       }
-
       if [file exists "${gccpath}/libiberty/libiberty.a"] {
           append flags "-L${gccpath}/libiberty "
       }
       if [file exists "${gccpath}/librx/librx.a"] {
           append flags "-L${gccpath}/librx "
       }
-      append ld_library_path [gcc-set-multilib-library-path $GXX_UNDER_TEST]
+      add_path ld_library_path [find_libgcc_s $GXX_UNDER_TEST]
     } else {
       global tool_root_dir
 
       set libgpp [lookfor_file ${tool_root_dir} libg++]
       if { $libgpp != "" } {
           append flags "-L${libgpp} "
-          append ld_library_path ":${libgpp}"
+	  add_path ld_library_path ${libgpp}
       }
       set libstdcpp [lookfor_file ${tool_root_dir} libstdc++]
       if { $libstdcpp != "" } {
           append flags "-L${libstdcpp} "
-          append ld_library_path ":${libstdcpp}"
+	  add_path ld_library_path ${libstdcpp}
       }
       set libiberty [lookfor_file ${tool_root_dir} libiberty]
       if { $libiberty != "" } {
Index: gcc/testsuite/lib/obj-c++.exp
===================================================================
--- gcc/testsuite/lib/obj-c++.exp	2009-06-02 13:05:35.000000000 +0100
+++ gcc/testsuite/lib/obj-c++.exp	2009-06-02 13:06:11.000000000 +0100
@@ -106,30 +106,30 @@ proc obj-c++_link_flags { paths } {
     set gccpath ${paths}
     set libio_dir ""
     set flags ""
-    set ld_library_path "."
+    set ld_library_path ""
     set shlib_ext [get_shlib_extension]
     verbose "shared lib extension: $shlib_ext"
 
     if { $gccpath != "" } {
       if [file exists "${gccpath}/lib/libstdc++.a"] {
-          append ld_library_path ":${gccpath}/lib"
+	  add_path ld_library_path "${gccpath}/lib"
       }
       if [file exists "${gccpath}/libg++/libg++.a"] {
           append flags "-L${gccpath}/libg++ "
-          append ld_library_path ":${gccpath}/libg++"
+	  add_path ld_library_path "${gccpath}/libg++"
       }
       if [file exists "${gccpath}/libstdc++/libstdc++.a"] {
           append flags "-L${gccpath}/libstdc++ "
-          append ld_library_path ":${gccpath}/libstdc++"
+	  add_path ld_library_path "${gccpath}/libstdc++"
       }
       if [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] {
           append flags " -L${gccpath}/libstdc++-v3/src/.libs "
-          append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
+	  add_path ld_library_path "${gccpath}/libstdc++-v3/src/.libs"
       }
       # Look for libstdc++.${shlib_ext}.
       if [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] {
 	  append flags " -L${gccpath}/libstdc++-v3/src/.libs "
-	  append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
+	  add_path ld_library_path "${gccpath}/libstdc++-v3/src/.libs"
       }
       if [file exists "${gccpath}/libiberty/libiberty.a"] {
           append flags "-L${gccpath}/libiberty "
@@ -158,23 +158,21 @@ proc obj-c++_link_flags { paths } {
       if { $libobjc_dir != "" } {
 	  set libobjc_dir [file dirname ${libobjc_dir}]
 	  append flags "-L${libobjc_dir}"
-	  append ld_library_path ":${libobjc_dir}"
+	  add_path ld_library_path ${libobjc_dir}
       }
-      append ld_library_path \
-	  [gcc-set-multilib-library-path $OBJCXX_UNDER_TEST]
-
+      add_path ld_library_path [find_libgcc_s $OBJCXX_UNDER_TEST]
     } else {
       global tool_root_dir;
 
       set libgpp [lookfor_file ${tool_root_dir} libg++];
       if { $libgpp != "" } {
           append flags "-L${libgpp} ";
-          append ld_library_path ":${libgpp}"
+	  add_path ld_library_path ${libgpp}
       }
       set libstdcpp [lookfor_file ${tool_root_dir} libstdc++];
       if { $libstdcpp != "" } {
           append flags "-L${libstdcpp} ";
-          append ld_library_path ":${libstdcpp}"
+	  add_path ld_library_path ${libstdcpp}
       }
       set libiberty [lookfor_file ${tool_root_dir} libiberty];
       if { $libiberty != "" } {
Index: gcc/testsuite/lib/c-torture.exp
===================================================================
--- gcc/testsuite/lib/c-torture.exp	2009-06-02 13:05:35.000000000 +0100
+++ gcc/testsuite/lib/c-torture.exp	2009-06-02 13:06:11.000000000 +0100
@@ -54,15 +54,6 @@ if ![info exists GCC_UNDER_TEST] {
     set GCC_UNDER_TEST "[find_gcc]"
 }
 
-global orig_environment_saved
-
-# This file may be sourced, so don't override environment settings
-# that have been previously setup.
-if { $orig_environment_saved == 0 } {
-    append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
-    set_ld_library_path_env_vars
-}
-
 #
 # c-torture-compile -- runs the Tege C-torture test
 #
@@ -108,6 +99,13 @@ proc c-torture-compile { src option } {
 #
 proc c-torture-execute { sources args } {
     global tmpdir tool srcdir output compiler_conditional_xfail_data
+    global ld_library_path ld_library_path_multilib GCC_UNDER_TEST
+
+    if { "$ld_library_path_multilib"
+	 != "[board_info target multilib_flags]" } {
+	set ld_library_path [find_libgcc_s $GCC_UNDER_TEST]
+	set_ld_library_path_env_vars
+    }
 
     # Use the first source filename given as the filename under test.
     set src [lindex $sources 0]
Index: gcc/testsuite/lib/gcc-dg.exp
===================================================================
--- gcc/testsuite/lib/gcc-dg.exp	2009-06-02 13:05:35.000000000 +0100
+++ gcc/testsuite/lib/gcc-dg.exp	2009-06-02 13:06:11.000000000 +0100
@@ -65,15 +65,6 @@ if ![info exists GCC_UNDER_TEST] {
     set GCC_UNDER_TEST "[find_gcc]"
 }
 
-global orig_environment_saved
-
-# This file may be sourced, so don't override environment settings
-# that have been previously setup.
-if { $orig_environment_saved == 0 } {
-    append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
-    set_ld_library_path_env_vars
-}
-
 # Define gcc callbacks for dg.exp.
 
 proc gcc-dg-test-1 { target_compile prog do_what extra_tool_flags } {
@@ -117,6 +108,14 @@ proc gcc-dg-test-1 { target_compile prog
 	    set output_file "[file rootname [file tail $prog]].o"
 	}
 	"run" {
+	    global ld_library_path ld_library_path_multilib GCC_UNDER_TEST
+
+	    if { "$ld_library_path_multilib"
+		 != "[board_info target multilib_flags]" } {
+		set ld_library_path [find_libgcc_s $GCC_UNDER_TEST]
+		set_ld_library_path_env_vars
+	    }
+
 	    set compile_type "executable"
 	    # FIXME: "./" is to cope with "." not being in $PATH.
 	    # Should this be handled elsewhere?
Index: gcc/testsuite/lib/gnat.exp
===================================================================
--- gcc/testsuite/lib/gnat.exp	2009-06-02 13:05:35.000000000 +0100
+++ gcc/testsuite/lib/gnat.exp	2009-06-02 13:06:11.000000000 +0100
@@ -147,7 +147,7 @@ proc gnat_target_compile { source dest t
         set GNAT_UNDER_TEST "$GNAT_UNDER_TEST_ORIG $gnat_rts_opt"
     }
 
-    set ld_library_path ".:${gnat_libgcc_s_path}"
+    set ld_library_path ${gnat_libgcc_s_path}
     lappend options "compiler=$GNAT_UNDER_TEST -q -f"
     lappend options "timeout=[timeout_value]"
 
Index: gcc/testsuite/g++.dg/compat/compat.exp
===================================================================
--- gcc/testsuite/g++.dg/compat/compat.exp	2009-06-02 13:05:35.000000000 +0100
+++ gcc/testsuite/g++.dg/compat/compat.exp	2009-06-02 13:06:11.000000000 +0100
@@ -103,14 +103,14 @@ set sid "cp_compat"
 # are different.
 set use_alt 0
 set same_alt 0
-set alt_ld_library_path "."
+set alt_ld_library_path ""
 if [info exists ALT_CXX_UNDER_TEST] then {
     set use_alt 1
     if [string match "same" $ALT_CXX_UNDER_TEST] then {
 	set same_alt 1
     } else {
 	if [info exists ALT_LD_LIBRARY_PATH] then {
-	    append alt_ld_library_path ":${ALT_LD_LIBRARY_PATH}"
+	    set alt_ld_library_path $ALT_LD_LIBRARY_PATH
 	}
     }
 }
Index: gcc/testsuite/g++.dg/compat/struct-layout-1.exp
===================================================================
--- gcc/testsuite/g++.dg/compat/struct-layout-1.exp	2009-06-02 13:05:35.000000000 +0100
+++ gcc/testsuite/g++.dg/compat/struct-layout-1.exp	2009-06-02 13:06:11.000000000 +0100
@@ -109,14 +109,14 @@ set sid "cp_compat"
 # are different.
 set use_alt 0
 set same_alt 0
-set alt_ld_library_path "."
+set alt_ld_library_path ""
 if [info exists ALT_CXX_UNDER_TEST] then {
     set use_alt 1
     if [string match "same" $ALT_CXX_UNDER_TEST] then {
 	set same_alt 1
     } else {
 	if [info exists ALT_LD_LIBRARY_PATH] then {
-	    append alt_ld_library_path ":${ALT_LD_LIBRARY_PATH}"
+	    set alt_ld_library_path $ALT_LD_LIBRARY_PATH
 	}
     }
 }
Index: libffi/testsuite/lib/libffi-dg.exp
===================================================================
--- libffi/testsuite/lib/libffi-dg.exp	2009-06-02 13:05:35.000000000 +0100
+++ libffi/testsuite/lib/libffi-dg.exp	2009-06-02 13:06:11.000000000 +0100
@@ -108,32 +108,11 @@ proc libffi-init { args } {
     verbose "libstdc++ $blddircxx"
 
     set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
-    if {$gccdir != ""} {
-	set gccdir [file dirname $gccdir]
-    }
-    verbose "gccdir $gccdir"
-
-    set ld_library_path "."
-    append ld_library_path ":${gccdir}"
-
-    set compiler "${gccdir}/xgcc"
-    if { [is_remote host] == 0 && [which $compiler] != 0 } {
-	foreach i "[exec $compiler --print-multi-lib]" {
-	    set mldir ""
-	    regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
-	    set mldir [string trimright $mldir "\;@"]
-	    if { "$mldir" == "." } {
-		continue
-	    }
-	    if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
-		append ld_library_path ":${gccdir}/${mldir}"
-	    }
-	}
-    }
+    add_path ld_library_path [find_libgcc_s "$gccdir/xgcc"]
     # add the library path for libffi.
-    append ld_library_path ":${blddirffi}/.libs"
+    add_path ld_library_path "${blddirffi}/.libs"
     # add the library path for libstdc++ as well.
-    append ld_library_path ":${blddircxx}/src/.libs"
+    add_path ld_library_path "${blddircxx}/src/.libs"
 
     verbose "ld_library_path: $ld_library_path"
 
Index: libgomp/testsuite/lib/libgomp.exp
===================================================================
--- libgomp/testsuite/lib/libgomp.exp	2009-06-02 13:05:35.000000000 +0100
+++ libgomp/testsuite/lib/libgomp.exp	2009-06-02 13:06:11.000000000 +0100
@@ -86,39 +86,8 @@ proc libgomp_init { args } {
 	set CFLAGS ""
     }
 
-    # Locate libgcc.a so we don't need to account for different values of
-    # SHLIB_EXT on different platforms
-    set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
-    if {$gccdir != ""} {
-        set gccdir [file dirname $gccdir]
-    }
-
-    # Compute what needs to be put into LD_LIBRARY_PATH
-    set always_ld_library_path ".:${blddir}/.libs"
-
-    # Compute what needs to be added to the existing LD_LIBRARY_PATH.
-    if {$gccdir != ""} {
-	# Add AIX pthread directory first.
-	if { [llength [glob -nocomplain ${gccdir}/pthread/libgcc_s*.a]] >= 1 } {
-	    append always_ld_library_path ":${gccdir}/pthread"
-	}
-	append always_ld_library_path ":${gccdir}"
-	set compiler [lindex $GCC_UNDER_TEST 0]
-
-	if { [is_remote host] == 0 && [which $compiler] != 0 } {
-	  foreach i "[exec $compiler --print-multi-lib]" {
-	    set mldir ""
-	    regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
-	    set mldir [string trimright $mldir "\;@"]
-	    if { "$mldir" == "." } {
-	      continue
-	    }
-	    if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
-	      append always_ld_library_path ":${gccdir}/${mldir}"
-	    }
-	  }
-	}
-    }
+    set always_ld_library_path "${blddir}/.libs"
+    add_path always_ld_library_path [find_libgcc_s $GCC_UNDER_TEST]
 
     set ALWAYS_CFLAGS ""
     if { $blddir != "" } {
Index: libgomp/testsuite/libgomp.c/c.exp
===================================================================
--- libgomp/testsuite/libgomp.c/c.exp	2009-06-02 13:05:35.000000000 +0100
+++ libgomp/testsuite/libgomp.c/c.exp	2009-06-02 13:06:11.000000000 +0100
@@ -20,7 +20,6 @@ dg-init
 set tests [lsort [find $srcdir/$subdir *.c]]
 
 set ld_library_path $always_ld_library_path
-append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
 set_ld_library_path_env_vars
 
 # Main loop.
Index: libgomp/testsuite/libgomp.c++/c++.exp
===================================================================
--- libgomp/testsuite/libgomp.c++/c++.exp	2009-06-02 13:05:35.000000000 +0100
+++ libgomp/testsuite/libgomp.c++/c++.exp	2009-06-02 13:06:11.000000000 +0100
@@ -37,12 +37,10 @@ if { $lang_test_file_found } {
     # Gather a list of all tests.
     set tests [lsort [glob -nocomplain $srcdir/$subdir/*.C]]
 
+    set ld_library_path $always_ld_library_path
     if { $blddir != "" } {
-        set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
-    } else {
-        set ld_library_path "$always_ld_library_path"
+	add_path ld_library_path "${blddir}/${lang_library_path}"
     }
-    append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
     set_ld_library_path_env_vars
 
     set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags"
Index: libgomp/testsuite/libgomp.fortran/fortran.exp
===================================================================
--- libgomp/testsuite/libgomp.fortran/fortran.exp	2009-06-02 13:05:35.000000000 +0100
+++ libgomp/testsuite/libgomp.fortran/fortran.exp	2009-06-02 13:06:11.000000000 +0100
@@ -26,12 +26,10 @@ if { $lang_test_file_found } {
     # Gather a list of all tests.
     set tests [lsort [find $srcdir/$subdir *.\[fF\]{,90,95,03,08}]]
 
+    set ld_library_path $always_ld_library_path
     if { $blddir != "" } {
-        set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
-    } else {
-        set ld_library_path "$always_ld_library_path"
+	add_path ld_library_path "${blddir}/${lang_library_path}"
     }
-    append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
     set_ld_library_path_env_vars
 
     # Main loop.
Index: libjava/testsuite/lib/libjava.exp
===================================================================
--- libjava/testsuite/lib/libjava.exp	2009-06-02 13:05:35.000000000 +0100
+++ libjava/testsuite/lib/libjava.exp	2009-06-02 13:06:11.000000000 +0100
@@ -197,36 +197,8 @@ proc libjava_init { args } {
     }
 
     # Finally, add the gcc build directory so that we can find the
-    # shared libgcc.  This, like much of dejagnu, is hideous.
-    set libjava_libgcc_s_path {}
-
-    if { [istarget "*-*-darwin*"] } {
-	set so_extension "dylib"
-    } elseif { [istarget "*-*-cygwin*"] || [istarget "*-*-mingw*"] } {
-	set so_extension "dll"
-    } else {
-	set so_extension "so"
-    }
-    set gccdir [lookfor_file $tool_root_dir gcc/libgcc_s.${so_extension}]
-    if {$gccdir != ""} {
-	set gccdir [file dirname $gccdir]
-	lappend libjava_libgcc_s_path $gccdir
-	verbose "libjava_libgcc_s_path = $libjava_libgcc_s_path"
-	set compiler ${gccdir}/xgcc
-	if { [is_remote host] == 0 && [which $compiler] != 0 } {
-	    foreach i "[exec $compiler --print-multi-lib]" {
-		set mldir ""
-		regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
-		set mldir [string trimright $mldir "\;@"]
-		if { "$mldir" == "." } {
-		    continue
-		}
-		if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.${so_extension}.*]] >= 1 } {
-		    lappend libjava_libgcc_s_path "${gccdir}/${mldir}"
-		}
-	    }
-	}
-    }
+    # shared libgcc.
+    set libjava_libgcc_s_path [find_libgcc_s $GCJ_UNDER_TEST]
 
     set libjava_initialized 1
 }
@@ -337,6 +309,8 @@ proc libjava_arguments {{mode compile}} 
     # Basically we want to build up a colon separated path list from
     # the value of $libjava.
 
+    # Add "." to the list so that we pick up shared libraries created
+    # by the testsuite itself.
     set lpath "."
     foreach dir [list $libjava] {
 	foreach item [split $dir " "] {
@@ -470,8 +444,8 @@ proc gcj_invoke {program expectFile ld_l
   global ld_library_path
 
   set ld_library_path "$libjava_ld_library_path"
-  if {[llength $ld_library_additions] > 0} {
-    append ld_library_path :[join $ld_library_additions :]
+  foreach path $ld_library_additions {
+    add_path ld_library_path $path
   }
 
   set_ld_library_path_env_vars
@@ -512,8 +486,8 @@ proc exec_gij {jarfile expectFile {ld_li
   global ld_library_path
 
   set ld_library_path "$libjava_ld_library_path"
-  if {[llength $ld_library_additions] > 0} {
-  append ld_library_path :[join $ld_library_additions :]
+  foreach path $ld_library_additions {
+    add_path ld_library_path $path
   }
 	
   set_ld_library_path_env_vars
@@ -562,8 +536,8 @@ proc libjava_invoke {errname testName op
     global ld_library_path
 
     set ld_library_path "$libjava_ld_library_path"
-    if {[llength $ld_library_additions] > 0} {
-	append ld_library_path :[join $ld_library_additions :]
+    foreach path $ld_library_additions {
+	add_path ld_library_path $path
     }
 
     set_ld_library_path_env_vars
Index: libmudflap/testsuite/lib/libmudflap.exp
===================================================================
--- libmudflap/testsuite/lib/libmudflap.exp	2009-06-02 13:05:35.000000000 +0100
+++ libmudflap/testsuite/lib/libmudflap.exp	2009-06-02 13:06:11.000000000 +0100
@@ -60,28 +60,9 @@ proc libmudflap-init { language } {
     # set LD_LIBRARY_PATH so that libgcc_s, libstdc++ binaries can be found.
     # locate libgcc.a so we don't need to account for different values of
     # SHLIB_EXT on different platforms
-    set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
-    if {$gccdir != ""} {
-	set gccdir [file dirname $gccdir]
-    }
-
-    set ld_library_path "."
-    append ld_library_path ":${gccdir}"
-    append ld_library_path ":${cxxblddir}/src/.libs"
-    if {[is_remote host] == 0} {
-	foreach i "[exec ${gccdir}/xgcc --print-multi-lib]" {
-	    set mldir ""
-	    regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
-	    set mldir [string trimright $mldir "\;@"]
-	    if { "$mldir" == "." } {
-		continue
-	    }
-	    if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
-		append ld_library_path ":${gccdir}/${mldir}"
-	    }
-	}
-    }
-    append ld_library_path ":${blddir}/.libs"
+    set ld_library_path [find_libgcc_s $cxx]
+    add_path ld_library_path "${cxxblddir}/src/.libs"
+    add_path ld_library_path "${blddir}/.libs"
 
     set libs "-L${blddir}/.libs"
     set cxxflags "-ggdb3 -DDEBUG_ASSERT"
Index: libstdc++-v3/testsuite/lib/libstdc++.exp
===================================================================
--- libstdc++-v3/testsuite/lib/libstdc++.exp	2009-06-02 13:05:35.000000000 +0100
+++ libstdc++-v3/testsuite/lib/libstdc++.exp	2009-06-02 13:06:11.000000000 +0100
@@ -132,7 +132,6 @@ proc libstdc++_init { testfile } {
     set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
     if {$gccdir != ""} {
         set gccdir [file dirname $gccdir]
-	append ld_library_path_tmp ":${gccdir}"
     }
     v3track gccdir 3
 
@@ -142,7 +141,7 @@ proc libstdc++_init { testfile } {
     if {$libgompdir != ""} {
 	set v3-libgomp 1
         set libgompdir [file dirname $libgompdir]
-	append ld_library_path_tmp ":${libgompdir}"
+	add_path ld_library_path_tmp ${libgompdir}
 	verbose -log "libgomp support detected"
     }
     v3track libgompdir 3
@@ -162,22 +161,8 @@ proc libstdc++_init { testfile } {
     if {$gccdir != ""} {
 	set compiler ${gccdir}/g++
 	set ld_library_path ${ld_library_path_tmp}
-	append ld_library_path ":${blddir}/src/.libs"
-
-	if { [is_remote host] == 0 && [which $compiler] != 0 } {
-	  foreach i "[exec $compiler --print-multi-lib]" {
-	    set mldir ""
-	    regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
-	    set mldir [string trimright $mldir "\;@"]
-	    if { "$mldir" == "." } {
-	      continue
-	    }
-	    if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
-	      append ld_library_path ":${gccdir}/${mldir}"
-	    }
-	  }
-	}
-
+	add_path ld_library_path "${blddir}/src/.libs"
+	add_path ld_library_path [find_libgcc_s $compiler]
 	set_ld_library_path_env_vars
 	if [info exists env(LD_LIBRARY_PATH)] {
 	  verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-07-02 20:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-02 14:41 [8/8] Tidy up testsuite handling of LD_LIBRARY_PATH (needs testsuite maintainer) David Edelsohn
2009-07-02 15:56 ` David Edelsohn
2009-07-02 19:44   ` Richard Sandiford
2009-07-02 21:21     ` Janis Johnson
  -- strict thread matches above, loose matches on Subject: below --
2009-06-02 12:03 [0/8] AIX cross toolchains Richard Sandiford
2009-06-02 12:33 ` [8/8] Tidy up testsuite handling of LD_LIBRARY_PATH (needs testsuite maintainer) Richard Sandiford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).