PATCH: PR other/17466: Testsuites in gcc override LD_LIBRARY_PATH ([RFC] Alternative LD_LIBRARY_PATH)
H. J. Lu
hjl@lucon.org
Wed Nov 24 20:03:00 GMT 2004
On Wed, Nov 24, 2004 at 08:39:24AM -0800, H. J. Lu wrote:
> On Wed, Nov 24, 2004 at 10:18:45AM -0500, John David Anglin wrote:
> > > Works fine on SPARC/Solaris, except for libjava: all execution tests now
> > > fail
> > > with:
> > >
> > > set_ld_library_path_env_vars: ld_library_path=.
> > > Setting LD_LIBRARY_PATH
> > > to .:.:.:/opt/build/eric/gcc/gcc:/opt/build/eric/local/lib
> > > ld.so.1: gij: fatal: libgij.so.0: open failed: No such file or directory
> > > FAIL: Array_3 execution - gij test
> > > UNTESTED: Array_3 output - gij test
> >
> > Ok, I see this on hppa-linux but the tests are picking up an installed
> > library so they don't fail. It looks like the path set in ld_library_path
> > in the libjava test is getting overridden by a sourced file at execution
> > time. There's only a couple of places this could occur. I'll look at
> > this tonight.
>
> Try not to use the global ld_library_path. See
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17469
>
>
This patch does 2 things:
1. Remove the global ld_library_path.
2. Consolidate libgcc_s.so detection in the gcc directory.
H.J.
----
gcc/testsuite/
2004-11-24 H.J. Lu <hongjiu.lu@intel.com>
PR other/17466:
* g++.dg/compat/compat.exp (ld_library_path): Renamed to ...
(last_ld_library_path): This.
(save_ld_library_path): Updated.
(compat-use-alt-compiler): Don't use global ld_library_path.
Update call to set_ld_library_path_env_vars.
(compat-use-tst-compiler): Likewise.
* lib/g++.exp (g++_link_flags): Don't use global
ld_library_path. Use ${libgcc_s_path} for gcc shared library
directory. Update call to set_ld_library_path_env_vars.
* lib/gcc-dg.exp: Likewise.
* lib/gfortran.exp (gfortran_link_flags): Likewise.
* lib/objc.exp (objc_target_compile): Likewise.
* lib/treelang.exp (treelang_target_compile): Likewise.
* lib/gcc-defs.exp (libgcc_s_path): Initialize global variable.
* lib/gcc.exp (gcc_init): Call set_ld_library_path_env_vars
with $libgcc_s_path.
* lib/target-libpath.exp (set_ld_library_path_env_vars): Make
ld_library_path the argument.
libffi/
2004-11-24 H.J. Lu <hongjiu.lu@intel.com>
PR other/17466:
* testsuite/lib/libffi-dg.exp (libffi-init): Don't use global
ld_library_path. Update call to set_ld_library_path_env_vars.
libjava/
2004-11-24 H.J. Lu <hongjiu.lu@intel.com>
PR other/17466:
* testsuite/lib/libjava.exp (libjava_arguments): Don't use
global ld_library_path. Update call to set_ld_library_path_env_vars.
(gcj_link): Likewise.
(libjava_invoke): Likewise.
* testsuite/libjava.jacks/jacks.exp (gcj_jacks_write): Likewise.
libmudflap/
2004-11-24 H.J. Lu <hongjiu.lu@intel.com>
PR other/17466:
* testsuite/lib/libmudflap.exp (libmudflap-init): Don't use
global ld_library_path. Update call to
set_ld_library_path_env_vars.
libstdc++-v3/
2004-11-24 H.J. Lu <hongjiu.lu@intel.com>
PR other/17466:
* testsuite/lib/libstdc++.exp (libstdc++_init): Don't use global
ld_library_path. Update call to set_ld_library_path_env_vars.
--- gcc/gcc/testsuite/g++.dg/compat/compat.exp.shlib 2004-11-24 08:45:59.000000000 -0800
+++ gcc/gcc/testsuite/g++.dg/compat/compat.exp 2004-11-24 10:45:09.640268850 -0800
@@ -30,7 +30,7 @@ if $tracelevel then {
}
global GXX_UNDER_TEST
-global ld_library_path
+global last_ld_library_path
# Load procedures from common libraries.
load_lib standard.exp
@@ -44,7 +44,7 @@ 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
# We don't need to do this if the alternate compiler is actually
@@ -53,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
- set_ld_library_path_env_vars
+ set_ld_library_path_env_vars $alt_ld_library_path
}
}
@@ -65,7 +64,7 @@ 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
# We don't need to do this if the alternate compiler is actually
@@ -75,8 +74,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
- set_ld_library_path_env_vars
+ set_ld_library_path_env_vars $save_ld_library_path
}
}
@@ -91,7 +89,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 $last_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/gcc/testsuite/lib/g++.exp.shlib 2004-11-24 08:46:14.000000000 -0800
+++ gcc/gcc/testsuite/lib/g++.exp 2004-11-24 09:32:28.644664799 -0800
@@ -97,10 +97,8 @@ proc g++_include_flags { paths } {
#
proc g++_link_flags { paths } {
- global rootme
+ global libgcc_s_path
global srcdir
- global ld_library_path
- global GXX_UNDER_TEST
set gccpath ${paths}
set libio_dir ""
@@ -129,21 +127,7 @@ proc g++_link_flags { paths } {
if [file exists "${gccpath}/librx/librx.a"] {
append flags "-L${gccpath}/librx "
}
- append ld_library_path ":${rootme}"
- set compiler [lindex $GXX_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 ld_library_path ":${rootme}/${mldir}"
- }
- }
- }
+ append ld_library_path ":${libgcc_s_path}"
} else {
global tool_root_dir;
@@ -167,7 +151,7 @@ proc g++_link_flags { paths } {
}
}
- set_ld_library_path_env_vars
+ set_ld_library_path_env_vars $ld_library_path
return "$flags"
}
--- gcc/gcc/testsuite/lib/gcc-defs.exp.shlib 2004-09-13 15:36:13.000000000 -0700
+++ gcc/gcc/testsuite/lib/gcc-defs.exp 2004-11-24 09:45:03.495819649 -0800
@@ -219,3 +219,22 @@ proc dg-additional-files-options { optio
return $options
}
+
+# libgcc_s_path -- the gcc shared library directory.
+global rootme
+global libgcc_s_path
+set libgcc_s_path "${rootme}"
+set compiler [lindex [find_gcc] 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/gcc/testsuite/lib/gcc-dg.exp.shlib 2004-11-24 08:46:14.000000000 -0800
+++ gcc/gcc/testsuite/lib/gcc-dg.exp 2004-11-24 09:47:47.662540066 -0800
@@ -46,34 +46,12 @@ if ![info exists TORTURE_OPTIONS] {
{ -Os } ]
}
-global GCC_UNDER_TEST
-if ![info exists GCC_UNDER_TEST] {
- set GCC_UNDER_TEST "[find_gcc]"
-}
-
-global rootme
-global ld_library_path
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 } {
- set ld_library_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 ld_library_path ":${rootme}/${mldir}"
- }
- }
- }
- set_ld_library_path_env_vars
+ set_ld_library_path_env_vars "${libgcc_s_path}"
}
# Split TORTURE_OPTIONS into two choices: one for testcases with loops and
--- gcc/gcc/testsuite/lib/gcc.exp.shlib 2004-09-13 15:36:13.000000000 -0700
+++ gcc/gcc/testsuite/lib/gcc.exp 2004-11-24 09:52:18.505432928 -0800
@@ -28,6 +28,7 @@
load_lib libgloss.exp
load_lib prune.exp
load_lib gcc-defs.exp
+load_lib target-libpath.exp
#
# GCC_UNDER_TEST is the compiler under test.
@@ -86,6 +87,7 @@ proc gcc_version { } {
set gcc_initialized 0
proc gcc_init { args } {
+ global libgcc_s_path
global tmpdir
global libdir
global gluefile wrap_flags
@@ -108,6 +110,8 @@ proc gcc_init { args } {
}
gcc_maybe_build_wrapper "${tmpdir}/gcc-testglue.o"
+
+ set_ld_library_path_env_vars $libgcc_s_path
}
#
--- gcc/gcc/testsuite/lib/gfortran.exp.shlib 2004-11-24 08:46:14.000000000 -0800
+++ gcc/gcc/testsuite/lib/gfortran.exp 2004-11-24 09:50:50.000000000 -0800
@@ -73,9 +73,8 @@ proc gfortran_version { } {
#
proc gfortran_link_flags { paths } {
- global rootme
+ global libgcc_s_path
global srcdir
- global ld_library_path
global GFORTRAN_UNDER_TEST
set gccpath ${paths}
@@ -94,24 +93,10 @@ proc gfortran_link_flags { paths } {
if [file exists "${gccpath}/libiberty/libiberty.a"] {
append flags "-L${gccpath}/libiberty "
}
- append ld_library_path ":${rootme}"
- set compiler [lindex $GFORTRAN_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 ld_library_path ":${rootme}/${mldir}"
- }
- }
- }
+ append ld_library_path ":${libgcc_s_path}"
}
- set_ld_library_path_env_vars
+ set_ld_library_path_env_vars $ld_library_path
return "$flags"
}
--- gcc/gcc/testsuite/lib/objc.exp.shlib 2004-11-24 08:46:14.000000000 -0800
+++ gcc/gcc/testsuite/lib/objc.exp 2004-11-24 09:53:07.545076323 -0800
@@ -86,14 +86,12 @@ proc objc_version { } {
set objc_initialized 0
proc objc_init { args } {
- global rootme
global tmpdir
global libdir
global gluefile wrap_flags
global objc_initialized
global OBJC_UNDER_TEST
global TOOL_EXECUTABLE
- global objc_libgcc_s_path
# We set LC_ALL and LANG to C so that we get the same error messages as expected.
setenv LC_ALL C
@@ -114,22 +112,6 @@ proc objc_init { args } {
}
objc_maybe_build_wrapper "${tmpdir}/objc-testglue.o"
-
- set objc_libgcc_s_path "${rootme}"
- set compiler [lindex $OBJC_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 objc_libgcc_s_path ":${rootme}/${mldir}"
- }
- }
- }
}
proc objc_target_compile { source dest type options } {
@@ -139,10 +121,9 @@ proc objc_target_compile { source dest t
global srcdir
global OBJC_UNDER_TEST
global TOOL_OPTIONS
- global ld_library_path
- global objc_libgcc_s_path
+ global libgcc_s_path
- set ld_library_path ".:${objc_libgcc_s_path}"
+ set ld_library_path ".:${libgcc_s_path}"
lappend options "libs=-lobjc"
if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
@@ -188,7 +169,7 @@ proc objc_target_compile { source dest t
}
lappend options "compiler=$OBJC_UNDER_TEST"
- set_ld_library_path_env_vars
+ set_ld_library_path_env_vars $ld_library_path
return [target_compile $source $dest $type $options]
}
--- gcc/gcc/testsuite/lib/target-libpath.exp.shlib 2004-11-23 20:39:30.000000000 -0800
+++ gcc/gcc/testsuite/lib/target-libpath.exp 2004-11-24 10:44:38.099355768 -0800
@@ -30,8 +30,7 @@ set orig_dyld_library_path_saved 0
# proc set_ld_library_path_env_vars { }
#######################################
-proc set_ld_library_path_env_vars { } {
- global ld_library_path
+proc set_ld_library_path_env_vars { ld_library_path } {
global orig_environment_saved
global orig_ld_library_path_saved
global orig_ld_run_path_saved
@@ -49,12 +48,16 @@ proc set_ld_library_path_env_vars { } {
global orig_ld_library_path_32
global orig_ld_library_path_64
global orig_dyld_library_path
+ global last_ld_library_path
# Setting the ld library path causes trouble when testing cross-compilers.
if { [is_remote target] } {
return
}
+ # We keep a copy of the argument.
+ set last_ld_library_path $ld_library_path
+
if { $orig_environment_saved == 0 } {
global env;
--- gcc/gcc/testsuite/lib/treelang.exp.shlib 2004-11-24 08:46:15.000000000 -0800
+++ gcc/gcc/testsuite/lib/treelang.exp 2004-11-24 09:53:49.000000000 -0800
@@ -83,14 +83,12 @@ proc default_treelang_version { } {
set treelang_initialized 0
proc treelang_init { args } {
- global rootme
global tmpdir
global libdir
global gluefile wrap_flags
global treelang_initialized
global TREELANG_UNDER_TEST
global TOOL_EXECUTABLE
- global treelang_libgcc_s_path
# We set LC_ALL and LANG to C so that we get the same error messages as expected.
@@ -113,22 +111,6 @@ proc treelang_init { args } {
}
treelang_maybe_build_wrapper "${tmpdir}/treelang-testglue.o"
-
- set treelang_libgcc_s_path "${rootme}"
- set compiler [lindex $TREELANG_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 treelang_libgcc_s_path ":${rootme}/${mldir}"
- }
- }
- }
}
proc treelang_target_compile { source dest type options } {
@@ -138,11 +120,10 @@ proc treelang_target_compile { source de
global srcdir
global TREELANG_UNDER_TEST
global TOOL_OPTIONS
- global ld_library_path
- global treelang_libgcc_s_path
+ global libgcc_s_path
- set ld_library_path ".:${treelang_libgcc_s_path}"
- set_ld_library_path_env_vars
+ set ld_library_path ".:${libgcc_s_path}"
+ set_ld_library_path_env_vars $ld_library_path
lappend options "libs=-ltreelang"
if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
--- gcc/libffi/testsuite/lib/libffi-dg.exp.shlib 2004-11-24 08:46:21.000000000 -0800
+++ gcc/libffi/testsuite/lib/libffi-dg.exp 2004-11-24 09:54:30.382338809 -0800
@@ -84,7 +84,6 @@ proc libffi-init { args } {
global libffi_include
global libffi_link_flags
global tool_root_dir
- global ld_library_path
set blddirffi [lookfor_file [get_multilibs] libffi]
verbose "libffi $blddirffi"
@@ -133,7 +132,7 @@ proc libffi-init { args } {
lappend libffi_link_flags "-L${blddircxx}/src/.libs"
}
- set_ld_library_path_env_vars
+ set_ld_library_path_env_vars $ld_library_path
libffi_maybe_build_wrapper "${objdir}/testglue.o"
}
--- gcc/libjava/testsuite/lib/libjava.exp.shlib 2004-11-24 08:46:53.000000000 -0800
+++ gcc/libjava/testsuite/lib/libjava.exp 2004-11-24 09:55:29.747643773 -0800
@@ -323,7 +323,6 @@ proc libjava_arguments {{mode compile}}
global tool_root_dir
global libgcj_jar
global libjava_libgcc_s_path
- global ld_library_path
global target_triplet
if [info exists LIBJAVA] {
@@ -357,7 +356,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_ld_library_path_env_vars
+ set_ld_library_path_env_vars $ld_library_path
if [info exists env(LD_LIBRARY_PATH)] {
verbose "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
}
@@ -453,14 +452,13 @@ 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
- global ld_library_path
set ld_library_path .
if {[llength $ld_library_additions] > 0} {
append ld_library_path :[join $ld_library_additions :]
}
- set_ld_library_path_env_vars
+ set_ld_library_path_env_vars $ld_library_path
if [info exists env(LD_LIBRARY_PATH)] {
verbose "LD_LIBRARY_PATH=$env(LD_LIBRARY_PATH)"
}
@@ -498,14 +496,13 @@ proc gcj_invoke {program expectFile ld_l
proc libjava_invoke {errname testName optName executable inpfile resultfile
ld_library_additions args} {
global env
- global ld_library_path
set ld_library_path .
if {[llength $ld_library_additions] > 0} {
append ld_library_path :[join $ld_library_additions :]
}
- set_ld_library_path_env_vars
+ set_ld_library_path_env_vars $ld_library_path
if [info exists env(LD_LIBRARY_PATH)] {
verbose "LD_LIBRARY_PATH=$env(LD_LIBRARY_PATH)"
}
--- gcc/libjava/testsuite/libjava.jacks/jacks.exp.shlib 2004-11-24 08:46:53.000000000 -0800
+++ gcc/libjava/testsuite/libjava.jacks/jacks.exp 2004-11-24 09:56:41.997278646 -0800
@@ -23,7 +23,6 @@ proc gcj_jacks_write {filename} {
global GCJ_UNDER_TEST
global libgcj_jar
global libjava_libgcc_s_path
- global ld_library_path
set gcjl [split $GCJ_UNDER_TEST]
set gcj_cmd [lindex $gcjl 0]
@@ -50,8 +49,7 @@ proc gcj_jacks_write {filename} {
# puts $fd "set tcltest::testConstraints(jvm) 1"
close $fd
- set ld_library_path $libjava_libgcc_s_path
- set_ld_library_path_env_vars
+ set_ld_library_path_env_vars $libjava_libgcc_s_path
}
proc gcj_jacks_parse {file} {
--- gcc/libmudflap/testsuite/lib/libmudflap.exp.shlib 2004-11-24 08:46:56.000000000 -0800
+++ gcc/libmudflap/testsuite/lib/libmudflap.exp 2004-11-24 09:57:01.933694453 -0800
@@ -37,7 +37,6 @@ proc libmudflap-init { language } {
global includes
global libs
global gluefile wrap_flags
- global ld_library_path
switch $language {
"c" { set cxx [find_gcc] }
@@ -101,7 +100,7 @@ proc libmudflap-init { language } {
global add_flags
append add_flags " $mfconfig_libs"
- set_ld_library_path_env_vars
+ set_ld_library_path_env_vars $ld_library_path
if [info exists env(LD_LIBRARY_PATH)] {
verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
}
--- gcc/libstdc++-v3/testsuite/lib/libstdc++.exp.shlib 2004-11-24 08:47:55.000000000 -0800
+++ gcc/libstdc++-v3/testsuite/lib/libstdc++.exp 2004-11-24 09:57:15.900884001 -0800
@@ -82,7 +82,6 @@ proc libstdc++_init { testfile } {
global cxx cxxflags
global includes
global gluefile wrap_flags
- global ld_library_path
global target_triplet
# We set LC_ALL and LANG to C so that we get the same error messages as expected.
@@ -151,7 +150,7 @@ proc libstdc++_init { testfile } {
}
append ld_library_path ":${blddir}/src/.libs"
- set_ld_library_path_env_vars
+ set_ld_library_path_env_vars $ld_library_path
if [info exists env(LD_LIBRARY_PATH)] {
verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
}
More information about the Gcc-patches
mailing list