This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: other/17466: Testsuites in gcc override LD_LIBRARY_PATH
- From: "H. J. Lu" <hjl at lucon dot org>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 17 Nov 2004 16:56:07 -0800
- Subject: PATCH: other/17466: Testsuites in gcc override LD_LIBRARY_PATH
I updated the patch. We don't need to set LD_LIBRARY_PATH in
lib/gcc-dg.exp. We should do it in lib/gcc.exp for C. Other
languages set it themselves.
H.J.
---
2004-11-17 H.J. Lu <hongjiu.lu@intel.com>
PR other/17466:
* lib/gcc-defs.exp (${tool}_set_ld_library_path): New procedure.
* g++.dg/compat/compat.exp (ld_library_path): Renamed to
gcc_ld_library_path.
(compat-fix-library-path): Removed.
(compat-use-alt-compiler): Call ${tool}_set_ld_library_path to
switch library path.
(compat-use-tst-compiler): Likewise.
* 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, LD_LIBRARY_PATH_32, LD_LIBRARY_PATH_64 and
DYLD_LIBRARY_PATH.
* lib/gcc.exp (gcc_init): Likewise.
* lib/gfortran.exp (gfortran_link_flags): Likewise.
* lib/objc.exp (objc_target_compile): Likewise.
* lib/gcc-dg.exp: Don't set LD_LIBRARY_PATH, SHLIB_PATH,
LD_LIBRARYN32_PATH, LD_LIBRARY64_PATH, LD_LIBRARY_PATH_32,
LD_LIBRARY_PATH_64 and DYLD_LIBRARY_PATH.
--- gcc/testsuite/g++.dg/compat/compat.exp.shlib 2004-02-03 10:16:15.000000000 -0800
+++ gcc/testsuite/g++.dg/compat/compat.exp 2004-11-17 12:12:39.000000000 -0800
@@ -30,40 +30,22 @@ if $tracelevel then {
}
global GXX_UNDER_TEST
-global ld_library_path
+global gcc_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
- }
-}
-
-#
# compat-use-alt-compiler -- make the alternate compiler the default
#
proc compat-use-alt-compiler { } {
global GXX_UNDER_TEST ALT_CXX_UNDER_TEST
global CXXFLAGS
global ALWAYS_CXXFLAGS
- global ld_library_path alt_ld_library_path
+ global alt_ld_library_path
global same_alt
+ global tool
# We don't need to do this if the alternate compiler is actually
# the same as the compiler under test.
@@ -71,8 +53,7 @@ proc compat-use-alt-compiler { } {
set GXX_UNDER_TEST $ALT_CXX_UNDER_TEST
set CXXFLAGS ""
set ALWAYS_CXXFLAGS ""
- set ld_library_path $alt_ld_library_path
- compat-fix-library-path
+ ${tool}_set_ld_library_path $alt_ld_library_path
}
}
@@ -83,8 +64,9 @@ proc compat-use-tst-compiler { } {
global GXX_UNDER_TEST save_gxx_under_test
global CXXFLAGS save_cxxflags
global ALWAYS_CXXFLAGS save_always_cxxflags
- global ld_library_path save_ld_library_path
+ global save_ld_library_path
global same_alt
+ global tool
# We don't need to do this if the alternate compiler is actually
# the same as the compiler under test.
@@ -93,8 +75,7 @@ proc compat-use-tst-compiler { } {
set GXX_UNDER_TEST $save_gxx_under_test
set CXXFLAGS $save_cxxflags
set ALWAYS_CXXFLAGS $save_always_cxxflags
- set ld_library_path $save_ld_library_path
- compat-fix-library-path
+ ${tool}_set_ld_library_path $save_ld_library_path
}
}
@@ -109,7 +90,7 @@ g++_init
set save_gxx_under_test $GXX_UNDER_TEST
set save_cxxflags $CXXFLAGS
set save_always_cxxflags $ALWAYS_CXXFLAGS
-set save_ld_library_path $ld_library_path
+set save_ld_library_path $gcc_ld_library_path
# Define an identifier for use with this suite to avoid name conflicts
# with other compat tests running at the same time.
--- gcc/testsuite/lib/g++.exp.shlib 2004-11-16 10:13:59.000000000 -0800
+++ gcc/testsuite/lib/g++.exp 2004-11-17 12:12:39.000000000 -0800
@@ -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,36 +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.
- # 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)] {
- # If we've already added these directories once, keep the
- # existing path.
- if {$ld_library_path == $env(LD_LIBRARY_PATH)
- || [string first $ld_library_path: \
- $env(LD_LIBRARY_PATH)] == 0} {
- set ld_library_path $env(LD_LIBRARY_PATH)
- } elseif { $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
- }
+ ${tool}_set_ld_library_path $ld_library_path
return "$flags"
}
--- gcc/testsuite/lib/gcc-defs.exp.shlib 2004-09-13 15:36:13.000000000 -0700
+++ gcc/testsuite/lib/gcc-defs.exp 2004-11-17 12:12:39.000000000 -0800
@@ -219,3 +219,40 @@ proc dg-additional-files-options { optio
return $options
}
+
+proc ${tool}_set_ld_library_path { 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]} {
+ # Save the longest path for g++.dg/compat/compat.exp
+ global gcc_ld_library_path
+ set gcc_ld_library_path ""
+ 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 {$ld_library_path != $env($path)
+ && [string first $ld_library_path: $env($path)] != 0} {
+ setenv $path "$ld_library_path:$env($path)"
+ if {[string length "$ld_library_path:$env($path)"] > [string length $gcc_ld_library_path]} {
+ set gcc_ld_library_path "$ld_library_path:$env($path)"
+ }
+ }
+ } else {
+ setenv $path "$ld_library_path"
+ }
+ }
+ if {$gcc_ld_library_path == ""} {
+ set gcc_ld_library_path "$ld_library_path"
+ }
+ }
+}
--- gcc/testsuite/lib/gcc-dg.exp.shlib 2004-11-17 09:39:31.000000000 -0800
+++ gcc/testsuite/lib/gcc-dg.exp 2004-11-17 15:21:22.286215040 -0800
@@ -45,63 +45,6 @@ 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}"
- }
- }
-}
-
-# 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]} {
- if [info exists env(LD_LIBRARY_PATH)] {
- setenv LD_LIBRARY_PATH "$libgcc_s_path:$env(LD_LIBRARY_PATH)"
- } else {
- setenv LD_LIBRARY_PATH $libgcc_s_path
- }
- if [info exists env(SHLIB_PATH)] {
- setenv SHLIB_PATH "$libgcc_s_path:$env(SHLIB_PATH)"
- } else {
- setenv SHLIB_PATH $libgcc_s_path
- }
- if [info exists env(LD_LIBRARYN32_PATH)] {
- setenv LD_LIBRARYN32_PATH "$libgcc_s_path:$env(LD_LIBRARYN32_PATH)"
- } else {
- setenv LD_LIBRARYN32_PATH $libgcc_s_path
- }
- if [info exists env(LD_LIBRARY64_PATH)] {
- setenv LD_LIBRARY64_PATH "$libgcc_s_path:$env(LD_LIBRARY64_PATH)"
- } else {
- setenv LD_LIBRARY64_PATH $libgcc_s_path
- }
- if [info exists env(DYLD_LIBRARY_PATH)] {
- setenv DYLD_LIBRARY_PATH "$libgcc_s_path:$env(DYLD_LIBRARY_PATH)"
- } else {
- setenv DYLD_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/gcc.exp.shlib 2004-09-13 15:36:13.000000000 -0700
+++ gcc/testsuite/lib/gcc.exp 2004-11-17 15:35:10.734394962 -0800
@@ -92,6 +92,7 @@ proc gcc_init { args } {
global gcc_initialized
global GCC_UNDER_TEST
global TOOL_EXECUTABLE
+ global rootme
if { $gcc_initialized == 1 } { return; }
@@ -108,6 +109,24 @@ proc gcc_init { args } {
}
gcc_maybe_build_wrapper "${tmpdir}/gcc-testglue.o"
+
+ 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}"
+ }
+ }
+ }
+
+ gcc_set_ld_library_path $libgcc_s_path
}
#
--- gcc/testsuite/lib/gfortran.exp.shlib 2004-11-16 10:13:59.000000000 -0800
+++ gcc/testsuite/lib/gfortran.exp 2004-11-17 12:12:39.000000000 -0800
@@ -74,7 +74,7 @@ proc gfortran_version { } {
proc gfortran_link_flags { paths } {
global rootme
global srcdir
- global ld_library_path
+ global tool
global GFORTRAN_UNDER_TEST
set gccpath ${paths}
@@ -110,36 +110,7 @@ proc gfortran_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)] {
- # If we've already added these directories once, keep the
- # existing path.
- if {$ld_library_path == $env(LD_LIBRARY_PATH)
- || [string first $ld_library_path: \
- $env(LD_LIBRARY_PATH)] == 0} {
- set ld_library_path $env(LD_LIBRARY_PATH)
- } elseif { $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
- }
+ ${tool}_set_ld_library_path $ld_library_path
return "$flags"
}
--- gcc/testsuite/lib/objc.exp.shlib 2004-11-16 10:13:59.000000000 -0800
+++ gcc/testsuite/lib/objc.exp 2004-11-17 12:12:39.000000000 -0800
@@ -138,7 +138,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}"
@@ -187,21 +187,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
+ ${tool}_set_ld_library_path $ld_library_path
return [target_compile $source $dest $type $options]
}