RFC: Fix ever-growing LD_LIBRARY_PATH

John David Anglin dave@hiauly1.hia.nrc.ca
Thu Jun 24 04:44:00 GMT 2004


This enclosed patch is a work in progress.  It hasn't been updated
since March 5 but I think it will resolve the problem encountered by
Richard.  It also attempts other issues with the various environment
variables used for this purpose other than LD_LIBRARY_PATH.

I think it needs updating for the new libraries added in the ssa
merge.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

Index: gcc/testsuite/g++.dg/compat/compat.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/compat/compat.exp,v
retrieving revision 1.5
diff -u -3 -p -r1.5 compat.exp
--- gcc/testsuite/g++.dg/compat/compat.exp	23 Jan 2004 04:42:39 -0000	1.5
+++ gcc/testsuite/g++.dg/compat/compat.exp	10 Mar 2004 22:35:15 -0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2002 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2004 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -35,25 +35,7 @@ global ld_library_path
 # Load procedures from common libraries. 
 load_lib standard.exp
 load_lib g++.exp
-
-#
-# compat-fix-library-path -- switch LD_LIBRARY_PATH
-#
-proc compat-fix-library-path { } {
-    global ld_library_path
-
-    # See comments in lib/g++.exp for why this is needed.
-    if {![is_remote target]} {
-	# See comments in lib/g++.exp for why this is needed.
-	setenv  LD_LIBRARY_PATH     $ld_library_path
-	setenv  SHLIB_PATH          $ld_library_path
-	setenv  LD_LIBRARYN32_PATH  $ld_library_path
-	setenv  LD_LIBRARY64_PATH   $ld_library_path
-	setenv  LD_LIBRARY_PATH_32  $ld_library_path
-	setenv  LD_LIBRARY_PATH_64  $ld_library_path
-	setenv  DYLD_LIBRARY_PATH   $ld_library_path
-    }
-}
+load_lib target-libpath.exp
 
 #
 # compat-use-alt-compiler -- make the alternate compiler the default
@@ -72,7 +54,7 @@ proc compat-use-alt-compiler { } {
 	set CXXFLAGS ""
 	set ALWAYS_CXXFLAGS ""
 	set ld_library_path $alt_ld_library_path
-	compat-fix-library-path
+	set_ld_library_path_env_vars
     }
 }
 
@@ -94,7 +76,7 @@ proc compat-use-tst-compiler { } {
 	set CXXFLAGS $save_cxxflags
 	set ALWAYS_CXXFLAGS $save_always_cxxflags
 	set ld_library_path $save_ld_library_path
-	compat-fix-library-path
+	set_ld_library_path_env_vars
     }
 }
 
Index: gcc/testsuite/lib/g++.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/lib/g++.exp,v
retrieving revision 1.38
diff -u -3 -p -r1.38 g++.exp
--- gcc/testsuite/lib/g++.exp	28 Feb 2004 09:40:24 -0000	1.38
+++ gcc/testsuite/lib/g++.exp	10 Mar 2004 22:35:17 -0000
@@ -1,5 +1,5 @@
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2003
-# Free Software Foundation, Inc.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2003,
+# 2004 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 #
 load_lib prune.exp
 load_lib gcc-defs.exp
+load_lib target-libpath.exp
 
 #
 # GXX_UNDER_TEST is the compiler under test.
@@ -166,29 +167,7 @@ proc g++_link_flags { paths } {
       }
     }
 
-    # 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 right way to do this would be to modify
-    # unix.exp -- but that's not an option since it's part of DejaGNU
-    # proper, so we do it here.
-    # 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).
-    # Doing this does cause trouble when testing cross-compilers.
-    if {![is_remote target]} {
-	global env;
-	if { [info exists env(LD_LIBRARY_PATH)] 
-	     && $env(LD_LIBRARY_PATH) != "" } {
-		append ld_library_path ":$env(LD_LIBRARY_PATH)";
-	}
-	setenv  LD_LIBRARY_PATH     $ld_library_path
-	setenv  SHLIB_PATH          $ld_library_path
-	setenv  LD_LIBRARYN32_PATH  $ld_library_path
-	setenv  LD_LIBRARY64_PATH   $ld_library_path
-	setenv  LD_LIBRARY_PATH_32  $ld_library_path
-	setenv  LD_LIBRARY_PATH_64  $ld_library_path
-	setenv  DYLD_LIBRARY_PATH   $ld_library_path
-    }
+    set_ld_library_path_env_vars
 
     return "$flags"
 }
Index: gcc/testsuite/lib/g77.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/lib/g77.exp,v
retrieving revision 1.18
diff -u -3 -p -r1.18 g77.exp
--- gcc/testsuite/lib/g77.exp	23 Jan 2004 04:42:39 -0000	1.18
+++ gcc/testsuite/lib/g77.exp	10 Mar 2004 22:35:17 -0000
@@ -1,5 +1,5 @@
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002 Free
-# Software Foundation, Inc.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2004
+# Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 #
 load_lib prune.exp
 load_lib gcc-defs.exp
+load_lib target-libpath.exp
 
 #
 # G77_UNDER_TEST is the compiler under test.
@@ -110,21 +111,7 @@ proc g77_link_flags { paths } {
       }
     }
 
-    # 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 right way to do this would be to modify
-    # unix.exp -- but that's not an option since it's part of DejaGNU
-    # proper, so we do it here.
-    # 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).
-    setenv  LD_LIBRARY_PATH     $ld_library_path
-    setenv  SHLIB_PATH          $ld_library_path
-    setenv  LD_LIBRARYN32_PATH  $ld_library_path
-    setenv  LD_LIBRARY64_PATH   $ld_library_path
-    setenv  LD_LIBRARY_PATH_32  $ld_library_path
-    setenv  LD_LIBRARY_PATH_64  $ld_library_path
-    setenv  DYLD_LIBRARY_PATH   $ld_library_path
+    set_ld_library_path_env_vars
 
     return "$flags"
 }
Index: gcc/testsuite/lib/objc.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/lib/objc.exp,v
retrieving revision 1.21
diff -u -3 -p -r1.21 objc.exp
--- gcc/testsuite/lib/objc.exp	23 Jan 2004 04:42:39 -0000	1.21
+++ gcc/testsuite/lib/objc.exp	10 Mar 2004 22:35:17 -0000
@@ -1,4 +1,4 @@
-# Copyright (C) 1992, 1993, 1994, 1996, 1997, 2000, 2001, 2002
+# Copyright (C) 1992, 1993, 1994, 1996, 1997, 2000, 2001, 2002, 2004
 # Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
@@ -28,6 +28,7 @@
 load_lib libgloss.exp
 load_lib prune.exp
 load_lib gcc-defs.exp
+load_lib target-libpath.exp
 
 #
 # OBJC_UNDER_TEST is the compiler under test.
@@ -184,21 +185,7 @@ proc objc_target_compile { source dest t
     }
     lappend options "compiler=$OBJC_UNDER_TEST"
 
-    # 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 right way to do this would be to modify
-    # unix.exp -- but that's not an option since it's part of DejaGNU
-    # proper, so we do it here.
-    # 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).
-    setenv  LD_LIBRARY_PATH     $ld_library_path
-    setenv  SHLIB_PATH          $ld_library_path
-    setenv  LD_LIBRARYN32_PATH  $ld_library_path
-    setenv  LD_LIBRARY64_PATH   $ld_library_path
-    setenv  LD_LIBRARY_PATH_32  $ld_library_path
-    setenv  LD_LIBRARY_PATH_64  $ld_library_path
-    setenv  DYLD_LIBRARY_PATH   $ld_library_path
+    set_ld_library_path_env_vars
 
     return [target_compile $source $dest $type $options]
 }
Index: gcc/testsuite/lib/treelang.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/lib/treelang.exp,v
retrieving revision 1.2
diff -u -3 -p -r1.2 treelang.exp
--- gcc/testsuite/lib/treelang.exp	20 Jan 2004 01:57:57 -0000	1.2
+++ gcc/testsuite/lib/treelang.exp	10 Mar 2004 22:35:17 -0000
@@ -33,6 +33,7 @@
 load_lib libgloss.exp
 load_lib prune.exp
 load_lib gcc-defs.exp
+load_lib target-libpath.exp
 
 #
 # TREELANG_UNDER_TEST is the compiler under test.
@@ -143,6 +144,7 @@ proc treelang_target_compile { source de
     global treelang_libgcc_s_path
 
     set ld_library_path ".:${treelang_libgcc_s_path}"
+    set_ld_library_path_env_vars
     lappend options "libs=-ltreelang"
 
     if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
Index: libffi/testsuite/lib/libffi-dg.exp
===================================================================
RCS file: /cvs/gcc/gcc/libffi/testsuite/lib/libffi-dg.exp,v
retrieving revision 1.7
diff -u -3 -p -r1.7 libffi-dg.exp
--- libffi/testsuite/lib/libffi-dg.exp	12 Jan 2004 20:49:14 -0000	1.7
+++ libffi/testsuite/lib/libffi-dg.exp	10 Mar 2004 22:35:17 -0000
@@ -16,7 +16,7 @@
 
 load_lib dg.exp
 load_lib libgloss.exp
-
+load_gcc_lib target-libpath.exp
 
 
 # Define libffi callbacks for dg.exp.
@@ -125,21 +125,7 @@ proc libffi-init { args } {
 	lappend libffi_link_flags "-L${blddircxx}/src/.libs"
     }
 
-    # 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 right way to do this would be to modify
-    # unix.exp -- but that's not an option since it's part of DejaGNU
-    # proper, so we do it here.
-    # 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).
-    setenv  LD_LIBRARY_PATH     $ld_library_path
-    setenv  SHLIB_PATH          $ld_library_path
-    setenv  LD_LIBRARYN32_PATH  $ld_library_path
-    setenv  LD_LIBRARY64_PATH   $ld_library_path
-    setenv  LD_LIBRARY_PATH_32  $ld_library_path
-    setenv  LD_LIBRARY_PATH_64  $ld_library_path
-    setenv  DYLD_LIBRARY_PATH   $ld_library_path
+    set_ld_library_path_env_vars
 }
 
 proc libffi_target_compile { source dest type options } {
Index: libjava/testsuite/lib/libjava.exp
===================================================================
RCS file: /cvs/gcc/gcc/libjava/testsuite/lib/libjava.exp,v
retrieving revision 1.57
diff -u -3 -p -r1.57 libjava.exp
--- libjava/testsuite/lib/libjava.exp	12 Jan 2004 21:19:26 -0000	1.57
+++ libjava/testsuite/lib/libjava.exp	10 Mar 2004 22:35:18 -0000
@@ -1,6 +1,8 @@
-# Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation
+# Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
+# Free Software Foundation
 
-load_lib "libgloss.exp"
+load_lib libgloss.exp
+load_gcc_lib target-libpath.exp
 
 # GCJ_UNDER_TEST is the compiler under test.
 
@@ -133,7 +135,6 @@ proc libjava_init { args } {
     global libjava_initialized libjava_uses_threads
     global GCJ_UNDER_TEST
     global TOOL_EXECUTABLE
-    global original_ld_library_path
     global env objdir
     global env libgcj_jar
     global tool_root_dir
@@ -173,24 +174,6 @@ proc libjava_init { args } {
     # Always set encoding used by gcj.
     append GCJ_UNDER_TEST " --encoding=UTF-8"
 
-    if [info exists env(LD_LIBRARY_PATH)] {
-	set original_ld_library_path $env(LD_LIBRARY_PATH)
-	# For HP-UX.
-    } elseif [info exists env(SHLIB_PATH)] {
-	set original_ld_library_path $env(SHLIB_PATH)
-	# For Darwin.
-    } elseif [info exists env(DYLD_LIBRARY_PATH)] {
-	set original_ld_library_path $env(DYLD_LIBRARY_PATH)
-	# For Solaris 32 bit.
-    } elseif [info exists env(LD_LIBRARY_PATH_32)] {
-	set original_ld_library_path $env(LD_LIBRARY_PATH_32)
-	# For Solaris 64 bit.
-    } elseif [info exists env(LD_LIBRARY_PATH_64)] {
-	set original_ld_library_path $env(LD_LIBRARY_PATH_64)
-    } else {
-	set original_ld_library_path ""
-    }
-
     set wrapper_file "";
     set wrap_compile_flags "";
     if [target_info exists needs_status_wrapper] {
@@ -364,10 +347,7 @@ proc libjava_arguments {{mode compile}} 
     # If we wanted to handle an arbitrary value of libjava,
     # then we'd have to do a lot more work.
 
-    # Set variables the dynamic linker looks at.
-    global original_ld_library_path
-    setenv LD_LIBRARY_PATH "$ld_library_path:$original_ld_library_path"
-
+    set_ld_library_path_env_vars
     verbose "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
 
     # Set the CLASSPATH environment variable
@@ -453,7 +433,7 @@ proc gcj_link {program main files {optio
 # Invoke the program and see what happens.  Return 0 on failure.
 proc gcj_invoke {program expectFile ld_library_additions} {
   global env
-  set lib_path $env(LD_LIBRARY_PATH)
+  set lib_path $ld_library_path
 
   set newval .
   if {[llength $ld_library_additions] > 0} {
@@ -461,7 +441,8 @@ proc gcj_invoke {program expectFile ld_l
   }
   append newval :$lib_path
 
-  setenv LD_LIBRARY_PATH $newval
+  set ld_library_path $newval
+  set_ld_library_path_env_vars
 
   verbose "LD_LIBRARY_PATH=$env(LD_LIBRARY_PATH)"
 
@@ -470,7 +451,8 @@ proc gcj_invoke {program expectFile ld_l
   set output [lindex $result 1]
 
   # Restore setting
-  setenv LD_LIBRARY_PATH $lib_path
+  set ld_library_path $lib_path
+  set_ld_library_path_env_vars
 
   if {$status != "pass"} {
     verbose "got $output"
@@ -902,25 +884,6 @@ proc default_libjava_version {} {
 
 proc default_libjava_start { } {
 }
-
-# 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 right way to do this would be to modify
-# unix.exp -- but that's not an option since it's part of DejaGNU
-# proper, so we do it here, by trickery.
-# 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).
-proc ${tool}_set_ld_library_path { name element op } {
-  setenv LD_LIBRARYN32_PATH [getenv LD_LIBRARY_PATH]
-  setenv LD_LIBRARY64_PATH [getenv LD_LIBRARY_PATH]
-  setenv SHLIB_PATH [getenv LD_LIBRARY_PATH]
-  setenv DYLD_LIBRARY_PATH [getenv LD_LIBRARY_PATH]
-  setenv LD_LIBRARY_PATH_32 [getenv LD_LIBRARY_PATH]
-  setenv LD_LIBRARY_PATH_64 [getenv LD_LIBRARY_PATH]
-}
-
-trace variable env(LD_LIBRARY_PATH) w ${tool}_set_ld_library_path
 
 # Local Variables:
 # tcl-indent-level:4
Index: libjava/testsuite/libjava.jacks/jacks.exp
===================================================================
RCS file: /cvs/gcc/gcc/libjava/testsuite/libjava.jacks/jacks.exp,v
retrieving revision 1.5
diff -u -3 -p -r1.5 jacks.exp
--- libjava/testsuite/libjava.jacks/jacks.exp	11 Nov 2003 20:04:22 -0000	1.5
+++ libjava/testsuite/libjava.jacks/jacks.exp	10 Mar 2004 22:35:18 -0000
@@ -1,6 +1,8 @@
 # Run the Jacks test suite.
 # See http://www-124.ibm.com/developerworks/oss/cvs/jikes/~checkout~/jacks/jacks.html
 
+load_gcc_lib target-libpath.exp
+
 proc gcj_jacks_setup_xfail {ary} {
   upvar $ary array
   global srcdir
@@ -16,7 +18,6 @@ proc gcj_jacks_write {filename} {
   global GCJ_UNDER_TEST
   global libgcj_jar
   global libjava_libgcc_s_path
-  global original_ld_library_path
 
   set gcjl [split $GCJ_UNDER_TEST]
   set gcj_cmd [lindex $gcjl 0]
@@ -37,7 +38,8 @@ proc gcj_jacks_write {filename} {
   # puts $fd "set tcltest::testConstraints(jvm) 1"
   close $fd
 
-  setenv LD_LIBRARY_PATH $libjava_libgcc_s_path:$original_ld_library_path
+  set ld_library_path $libjava_libgcc_s_path
+  set_ld_library_path_env_vars
 }
 
 proc gcj_jacks_parse {file} {
Index: libstdc++-v3/testsuite/lib/libstdc++.exp
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/lib/libstdc++.exp,v
retrieving revision 1.19
diff -u -3 -p -r1.19 libstdc++.exp
--- libstdc++-v3/testsuite/lib/libstdc++.exp	4 Mar 2004 23:29:43 -0000	1.19
+++ libstdc++-v3/testsuite/lib/libstdc++.exp	10 Mar 2004 22:35:19 -0000
@@ -50,6 +50,7 @@ load_lib libgloss.exp
 load_gcc_lib target-supports.exp
 load_lib prune.exp
 load_lib dg-options.exp
+load_gcc_lib target-libpath.exp
 
 # Useful for debugging.  Pass the name of a variable and the verbosity
 # threshold (number of -v's on the command line).
@@ -81,7 +82,7 @@ proc libstdc++_init { testfile } {
     global cxx cxxflags
     global includes
     global gluefile wrap_flags
-    global ld_library_path original_ld_library_path
+    global ld_library_path
     global target_triplet
 
     set blddir [lookfor_file [get_multilibs] libstdc++-v3]
@@ -119,26 +120,6 @@ proc libstdc++_init { testfile } {
     v3-copy-files [glob -nocomplain "$srcdir/data/*.tst"] $outdir
     v3-copy-files [glob -nocomplain "$srcdir/data/*.txt"] $outdir
 
-    # Setup LD_LIBRARY_PATH so that libgcc_s, libstdc++ binaries can be found.
-    # Find the existing LD_LIBRARY_PATH.
-    if [info exists env(LD_LIBRARY_PATH)] {
-	set original_ld_library_path $env(LD_LIBRARY_PATH)
-	# For HP-UX
-    } elseif [info exists env(SHLIB_PATH)] {
-	set original_ld_library_path $env(SHLIB_PATH)
-	# For Darwin:
-    } elseif [info exists env(DYLD_LIBRARY_PATH)] {
-	set original_ld_library_path $env(DYLD_LIBRARY_PATH)
-	# For Solaris 32 bit:
-    } elseif [info exists env(LD_LIBRARY_PATH_32)] {
-	set original_ld_library_path $env(LD_LIBRARY_PATH_32)
-	# For Solaris 64 bit:
-    } elseif [info exists env(LD_LIBRARY_PATH_64)] {
-	set original_ld_library_path $env(LD_LIBRARY_PATH_64)
-    } else {
-	set original_ld_library_path ""
-    }
-
     # 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]
@@ -166,22 +147,7 @@ proc libstdc++_init { testfile } {
     }
     append ld_library_path ":${blddir}/src/.libs"
 
-    # 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 right way to do this would be to modify
-    # unix.exp -- but that's not an option since it's part of DejaGNU
-    # proper, so we do it here.
-    # 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).
-    setenv  LD_LIBRARY_PATH     "$ld_library_path:$original_ld_library_path"
-    setenv  SHLIB_PATH          "$ld_library_path:$original_ld_library_path"
-    setenv  LD_LIBRARYN32_PATH  "$ld_library_path:$original_ld_library_path"
-    setenv  LD_LIBRARY64_PATH   "$ld_library_path:$original_ld_library_path"
-    setenv  LD_RUN_PATH         "$ld_library_path:$original_ld_library_path"
-    setenv  LD_LIBRARY_PATH_32  "$ld_library_path:$original_ld_library_path"
-    setenv  LD_LIBRARY_PATH_64  "$ld_library_path:$original_ld_library_path"
-    setenv  DYLD_LIBRARY_PATH   "$ld_library_path:$original_ld_library_path"
+    set_ld_library_path_env_vars
     verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
 
     # Do a bunch of handstands and backflips for cross compiling and
--- /dev/null	2004-06-04 19:04:13.786373048 -0700
+++ gcc/testsuite/lib/target-libpath.exp	2004-04-05 09:57:28.000000000 -0700
@@ -0,0 +1,111 @@
+# Copyright (C) 2004 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# This file was contributed by John David Anglin (dave.anglin@nrc-cnrc.gc.ca)
+
+set orig_environment_saved 0
+
+#######################################
+# 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
+    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
+
+    if { $orig_environment_saved == 0 } {
+	global env;
+
+	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)"
+	} else {
+	    set orig_ld_library_path ""
+	}
+	if [info exists env(LD_RUN_PATH)] {
+	    set orig_ld_run_path ":$env(LD_RUN_PATH)"
+	} else {
+	    set orig_ld_run_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 independently.
+	if [info exists env(SHLIB_PATH)] {
+	    set orig_shlib_path ":$env(SHLIB_PATH)"
+	} else {
+	    set orig_shlib_path ""
+	}
+	if [info exists env(LD_LIBRARYN32_PATH)] {
+	    set orig_ld_libraryn32_path ":$env(LD_LIBRARYN32_PATH)"
+	} else {
+	    set orig_ld_libraryn32_path "$orig_ld_library_path"
+	}
+	if [info exists env(LD_LIBRARY64_PATH)] {
+	    set orig_ld_library64_path ":$env(LD_LIBRARY64_PATH)"
+	} else {
+	    set orig_ld_library64_path "$orig_ld_library_path"
+	}
+	if [info exists env(LD_LIBRARY_PATH_32)] {
+	    set orig_ld_library_path_32 ":$env(LD_LIBRARY_PATH_32)"
+	} else {
+	    set orig_ld_library_path_32 "$orig_ld_library_path"
+	}
+	if [info exists env(LD_LIBRARY_PATH_64)] {
+	    set orig_ld_library_path_64 ":$env(LD_LIBRARY_PATH_64)"
+	} else {
+	    set orig_ld_library_path_64 "$orig_ld_library_path"
+	}
+	if [info exists env(DYLD_LIBRARY_PATH)] {
+	    set orig_dyld_library_path ":$env(DYLD_LIBRARY_PATH)"
+	} else {
+	    set orig_dyld_library_path ""
+	}
+    }
+
+    # 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 execures a
+    # program.  We 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).
+    # Doing this does cause trouble when testing cross-compilers.  It's
+    # also a bit of a hack as ld_library_path gets repeated in SHLIB_PATH
+    # and LD_LIBRARY_PATH when unix_load sets these variables.
+    if {![is_remote target]} {
+	setenv LD_LIBRARY_PATH "$ld_library_path$orig_ld_library_path"
+	setenv LD_RUN_PATH "$ld_library_path$orig_ld_run_path"
+	setenv SHLIB_PATH "$ld_library_path$orig_shlib_path"
+	setenv LD_LIBRARYN32_PATH "$ld_library_path$orig_ld_libraryn32_path"
+	setenv LD_LIBRARY64_PATH "$ld_library_path$orig_ld_library64_path"
+	setenv LD_LIBRARY_PATH_32 "$ld_library_path$orig_ld_library_path_32"
+	setenv LD_LIBRARY_PATH_64 "$ld_library_path$orig_ld_library_path_64"
+	setenv DYLD_LIBRARY_PATH "$ld_library_path$orig_dyld_library_path"
+    }
+}



More information about the Gcc-patches mailing list