PATCH: other/17466: Testsuites in gcc override LD_LIBRARY_PATH

H. J. Lu hjl@lucon.org
Tue Sep 14 21:27:00 GMT 2004


On Tue, Sep 14, 2004 at 11:33:39AM -0700, H. J. Lu wrote:
> On Tue, Sep 14, 2004 at 12:26:42PM +0100, Richard Sandiford wrote:
> > "H. J. Lu" <hjl@lucon.org> writes:
> > > 	PR other/17466:
> > > 	* lib/gcc-defs.exp (${tool}_set_ld_library_path): New procedure.
> > > 	* lib/g++.exp (g++_link_flags): Don't use global
> > > 	ld_library_path. Call ${tool}_set_ld_library_path to set up
> > > 	LD_LIBRARY_PATH, SHLIB_PATH, LD_LIBRARYN32_PATH,
> > > 	LD_LIBRARY64_PATH and DYLD_LIBRARY_PATH.
> > > 	* lib/g77.exp (g77_link_flags): Likewise.
> > > 	* lib/objc.exp (objc_target_compile): Likewise.
> > > 	* lib/gcc-dg.exp: Call ${tool}_set_ld_library_path to set up
> > > 	LD_LIBRARY_PATH, SHLIB_PATH, LD_LIBRARYN32_PATH,
> > > 	LD_LIBRARY64_PATH and DYLD_LIBRARY_PATH.
> > 
> > Look at what mainline does.  The problem with things like this:
> > 
> > > +	if [info exists env(LD_LIBRARY_PATH)] {
> > > +	    setenv LD_LIBRARY_PATH "$ld_library_path:$env(LD_LIBRARY_PATH)"
> > > +	} else {
> > > +	    setenv LD_LIBRARY_PATH $ld_library_path
> > > +	}
> > 
> > is that ld_library_path will get added each time the function is called,
> > and it can be called several times during a typical testsuite run.
> > The variable can eventually exceed the environment limits on some
> > systems (e.g. IRIX).
> > 
> > Also, since you need to apply the same construct to several variables,
> > please consider using "foreach".
> 
> Thanks. Here is the updated patch for gcc 3.4.
> 

I noticed

ERROR: tcl error sourcing
/net/gnu/export/gnu/src/gcc-3.4-libunwind/gcc/gcc/testsuite/g++.dg/compat/compat.exp.
ERROR: can't read "ld_library_path": no such variable

I need to set "ld_library_path". Here is the updated patch.


H.J.
----
2004-09-13  H.J. Lu  <hongjiu.lu@intel.com>

	PR other/17466:
	* lib/gcc-defs.exp (${tool}_set_ld_library_path): New procedure.
	* lib/g++.exp (g++_link_flags): Don't use global
	ld_library_path. Call ${tool}_set_ld_library_path to set up
	LD_LIBRARY_PATH, SHLIB_PATH, LD_LIBRARYN32_PATH,
	LD_LIBRARY64_PATH and DYLD_LIBRARY_PATH.
	* lib/g77.exp (g77_link_flags): Likewise.
	* lib/objc.exp (objc_target_compile): Likewise.
	* lib/gcc-dg.exp: Call ${tool}_set_ld_library_path to set up
	LD_LIBRARY_PATH, SHLIB_PATH, LD_LIBRARYN32_PATH,
	LD_LIBRARY64_PATH and DYLD_LIBRARY_PATH.

--- gcc/testsuite/lib/g++.exp.shlib	2004-02-23 13:25:33.000000000 -0800
+++ gcc/testsuite/lib/g++.exp	2004-09-14 09:35:19.000000000 -0700
@@ -98,7 +98,7 @@ proc g++_include_flags { paths } {
 proc g++_link_flags { paths } {
     global rootme
     global srcdir
-    global ld_library_path
+    global tool
     global GXX_UNDER_TEST
 
     set gccpath ${paths}
@@ -166,20 +166,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.  We really only need to do 
-    # this on IRIX, but it shouldn't hurt to do it anywhere else.
-    # Doing this does cause trouble when testing cross-compilers.
-    if {![is_remote target]} {
-	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  DYLD_LIBRARY_PATH   $ld_library_path
-    }
+    ${tool}_set_ld_library_path $ld_library_path
 
     return "$flags"
 }
--- gcc/testsuite/lib/g77.exp.shlib	2004-02-23 13:25:33.000000000 -0800
+++ gcc/testsuite/lib/g77.exp	2004-09-14 09:35:19.000000000 -0700
@@ -74,7 +74,7 @@ proc g77_version { } {
 proc g77_link_flags { paths } {
     global rootme
     global srcdir
-    global ld_library_path
+    global tool
     global G77_UNDER_TEST
 
     set gccpath ${paths}
@@ -110,17 +110,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.  We really only need to do 
-    # this on IRIX, but it shouldn't hurt to do it anywhere else.
-    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  DYLD_LIBRARY_PATH   $ld_library_path
+    ${tool}_set_ld_library_path $ld_library_path
 
     return "$flags"
 }
--- gcc/testsuite/lib/gcc-defs.exp.shlib	2003-06-05 15:32:55.000000000 -0700
+++ gcc/testsuite/lib/gcc-defs.exp	2004-09-14 10:13:46.000000000 -0700
@@ -217,3 +217,38 @@ proc dg-additional-files-options { optio
 
     return $options
 }
+
+proc ${tool}_set_ld_library_path { gcc_ld_library_path } {
+    # 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.  We really only need to do 
+    # this on IRIX, but it shouldn't hurt to do it anywhere else.
+    # 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 ld_library_path
+	set ld_library_path_set "no"
+	set ld_path "LD_LIBRARY_PATH SHLIB_PATH LD_LIBRARYN32_PATH LD_LIBRARY64_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 DYLD_LIBRARY_PATH"
+	foreach path $ld_path {
+	    if [info exists env($path)] {
+		# If we've already added these directories once, keep
+		# the existing path.
+		if {$gcc_ld_library_path != $env($path)
+		    && [string first $gcc_ld_library_path: $env($path)] != 0} {
+		    setenv $path "$gcc_ld_library_path:$env($path)"
+		    eval set ld_library_path $$path
+		    set ld_library_path_set "yes"
+		}
+	    } else {
+		setenv $path "$gcc_ld_library_path"
+	    }
+	}
+	if {$ld_library_path_set == "no"} {
+	    set ld_library_path "$gcc_ld_library_path"
+	}
+    }
+}
--- gcc/testsuite/lib/gcc-dg.exp.shlib	2004-04-12 14:56:16.000000000 -0700
+++ gcc/testsuite/lib/gcc-dg.exp	2004-09-14 09:35:19.000000000 -0700
@@ -19,6 +19,7 @@ load_lib file-format.exp
 load_lib target-supports.exp
 load_lib scanasm.exp
 load_lib prune.exp
+load_lib libgloss.exp
 
 if ![info exists TORTURE_OPTIONS] {
     # It is theoretically beneficial to group all of the O2/O3 options together,
@@ -39,6 +40,30 @@ if ![info exists TORTURE_OPTIONS] {
 	{ -Os } ]
 }
 
+global GCC_UNDER_TEST
+if ![info exists GCC_UNDER_TEST] {
+    set GCC_UNDER_TEST "[find_gcc]"
+}
+
+global rootme
+set libgcc_s_path "${rootme}"
+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 ${rootme}/${mldir}/libgcc_s*.so.*]] == 1 } {
+	    append libgcc_s_path ":${rootme}/${mldir}"
+	}
+    }
+}
+
+global tool
+${tool}_set_ld_library_path $libgcc_s_path
 
 # Split TORTURE_OPTIONS into two choices: one for testcases with loops and
 # one for testcases without loops.
--- gcc/testsuite/lib/objc.exp.shlib	2004-02-23 13:25:34.000000000 -0800
+++ gcc/testsuite/lib/objc.exp	2004-09-14 09:35:19.000000000 -0700
@@ -142,7 +142,7 @@ proc objc_target_compile { source dest t
     global srcdir
     global OBJC_UNDER_TEST
     global TOOL_OPTIONS
-    global ld_library_path
+    global tool
     global objc_libgcc_s_path
 
     set ld_library_path ".:${objc_libgcc_s_path}"
@@ -184,17 +184,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.  We really only need to do 
-    # this on IRIX, but it shouldn't hurt to do it anywhere else.
-    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  DYLD_LIBRARY_PATH   $ld_library_path 
+    ${tool}_set_ld_library_path $ld_library_path 
 
     return [target_compile $source $dest $type $options]
 }



More information about the Gcc-patches mailing list