This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] do not disregard LD_LIBRARY_PATH for native c++ tests [take 2]
- From: "John David Anglin" <dave at hiauly1 dot hia dot nrc dot ca>
- To: rearnsha at arm dot com
- Cc: gcc-patches at gcc dot gnu dot org, aldh at redhat dot com
- Date: Mon, 1 Mar 2004 14:01:39 -0500 (EST)
- Subject: [patch] do not disregard LD_LIBRARY_PATH for native c++ tests [take 2]
Here is a revised patch which now saves the original environment values
for LD_LIBRARY_PATH, SHLIB_PATH, LD_LIBRARYN32_PATH, LD_LIBRARY64_PATH,
LD_LIBRARY_PATH_32, LD_LIBRARY_PATH_64, and DYLD_LIBRARY_PATH in
independent global variables.
The patch has been tested on hppa-linux with and without LD_LIBRARY_PATH
set. I added some debugging output and have confirmed that LD_LIBRARY_PATH
was consistently getting set throughout the entire g++ suite.
Tested on hppa-unknown-linux-gnu. Ok for 3.5?
Dave
--
J. David Anglin dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6602)
2004-03-01 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
* g++.dg/compat/compat.exp (compat-fix-library-path): Append original
paths to ld_library_path when setting new environment values.
* lib/g++.exp (g++_link_flags): Save original environment values for
LD_LIBRARY_PATH, SHLIB_PATH, LD_LIBRARYN32_PATH, LD_LIBRARY64_PATH,
LD_LIBRARY_PATH_32, LD_LIBRARY_PATH_64, DYLD_LIBRARY_PATH. Append
original values when setting new environment values.
lib/g77.exp (g77_link_flags): Likewise.
lib/objc.exp (objc_target_compile): Likewise.
Index: 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
--- g++.dg/compat/compat.exp 23 Jan 2004 04:42:39 -0000 1.5
+++ g++.dg/compat/compat.exp 29 Feb 2004 17:40:39 -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
@@ -41,17 +41,24 @@ load_lib g++.exp
#
proc compat-fix-library-path { } {
global ld_library_path
+ global orig_ld_library_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
# 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
+ setenv LD_LIBRARY_PATH "$ld_library_path$orig_ld_library_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"
}
}
Index: 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
--- lib/g++.exp 28 Feb 2004 09:40:24 -0000 1.38
+++ lib/g++.exp 29 Feb 2004 17:40:40 -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
@@ -31,6 +31,7 @@ load_lib gcc-defs.exp
set gpp_compile_options ""
+set orig_environment_saved 0
#
# g++_version -- extract and print the version number of the compiler
@@ -100,6 +101,14 @@ proc g++_link_flags { paths } {
global srcdir
global ld_library_path
global GXX_UNDER_TEST
+ global orig_environment_saved
+ global orig_ld_library_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
set gccpath ${paths}
set libio_dir ""
@@ -166,28 +175,70 @@ proc g++_link_flags { paths } {
}
}
+ # First time though, save the original environment. We may change
+ # it below and during compatibility testing.
+ if { $orig_environment_saved == 0 } {
+ global env;
+
+ set orig_environment_saved 1
+
+ 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(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 ""
+ }
+ if [info exists env(LD_LIBRARY64_PATH)] {
+ set orig_ld_library64_path ":$env(LD_LIBRARY64_PATH)"
+ } else {
+ set orig_ld_library64_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 ""
+ }
+ 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 ""
+ }
+ 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 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.
+ # (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]} {
- 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
+ setenv LD_LIBRARY_PATH "$ld_library_path$orig_ld_library_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"
}
return "$flags"
Index: 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
--- lib/g77.exp 23 Jan 2004 04:42:39 -0000 1.18
+++ lib/g77.exp 29 Feb 2004 17:40:40 -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
@@ -31,6 +31,7 @@ load_lib gcc-defs.exp
set gpp_compile_options ""
+set orig_environment_saved 0
#
@@ -76,6 +77,14 @@ proc g77_link_flags { paths } {
global srcdir
global ld_library_path
global G77_UNDER_TEST
+ global orig_environment_saved
+ global orig_ld_library_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
set gccpath ${paths}
set libio_dir ""
@@ -110,21 +119,71 @@ proc g77_link_flags { paths } {
}
}
+ # First time though, save the original environment. We may change
+ # it below and during compatibility testing.
+ if { $orig_environment_saved == 0 } {
+ global env;
+
+ set orig_environment_saved 1
+
+ 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(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 ""
+ }
+ if [info exists env(LD_LIBRARY64_PATH)] {
+ set orig_ld_library64_path ":$env(LD_LIBRARY64_PATH)"
+ } else {
+ set orig_ld_library64_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 ""
+ }
+ 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 ""
+ }
+ 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 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
+ # (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 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"
+ }
return "$flags"
}
Index: 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
--- lib/objc.exp 23 Jan 2004 04:42:39 -0000 1.21
+++ lib/objc.exp 29 Feb 2004 17:40:40 -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
@@ -29,6 +29,8 @@ load_lib libgloss.exp
load_lib prune.exp
load_lib gcc-defs.exp
+set orig_environment_saved 0
+
#
# OBJC_UNDER_TEST is the compiler under test.
#
@@ -144,6 +146,14 @@ proc objc_target_compile { source dest t
global TOOL_OPTIONS
global ld_library_path
global objc_libgcc_s_path
+ global orig_environment_saved
+ global orig_ld_library_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
set ld_library_path ".:${objc_libgcc_s_path}"
lappend options "libs=-lobjc"
@@ -184,21 +194,71 @@ proc objc_target_compile { source dest t
}
lappend options "compiler=$OBJC_UNDER_TEST"
+ # First time though, save the original environment. We may change
+ # it below and during compatibility testing.
+ if { $orig_environment_saved == 0 } {
+ global env;
+
+ set orig_environment_saved 1
+
+ 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(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 ""
+ }
+ if [info exists env(LD_LIBRARY64_PATH)] {
+ set orig_ld_library64_path ":$env(LD_LIBRARY64_PATH)"
+ } else {
+ set orig_ld_library64_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 ""
+ }
+ 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 ""
+ }
+ 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 executes 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 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
+ # (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 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"
+ }
return [target_compile $source $dest $type $options]
}