# Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation
-load_lib "libgloss.exp"
+proc load_gcc_lib { filename } {
+ global srcdir
+ load_file $srcdir/../../gcc/testsuite/lib/$filename
+}
+
+load_lib libgloss.exp
+load_gcc_lib target-libpath.exp
# GCJ_UNDER_TEST is the compiler under test.
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
global libjava_libgcc_s_path
global target_triplet
+ # We set LC_ALL and LANG to C so that we get the same error messages as expected.
+ setenv LC_ALL C
+ setenv LANG C
+
if { $libjava_initialized == 1 } { return; }
if ![info exists GCJ_UNDER_TEST] {
# 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] {
# Finally, add the gcc build directory so that we can find the
# shared libgcc. This, like much of dejagnu, is hideous.
set libjava_libgcc_s_path {}
-
- if { [string match "powerpc-*-darwin*" $target_triplet] } {
+
+ if { [istarget "*-*-darwin*"] } {
set so_extension "dylib"
} else {
set so_extension "so"
if { [is_remote host] == 0 && [which $compiler] != 0 } {
foreach i "[exec $compiler --print-multi-lib]" {
set mldir ""
- regexp -- "\[a-z0-9=/\.-\]*;" $i mldir
+ regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
set mldir [string trimright $mldir "\;@"]
if { "$mldir" == "." } {
continue
proc libjava_find_lib {dir name} {
global base_dir
set gp [get_multilibs]
- foreach extension {so dll a} {
+ foreach extension {so dll dylib a} {
foreach sub {.libs _libs} {
if {$gp != ""} {
if {[file exists $gp/$dir/$sub/lib${name}.${extension}]} then {
# is used with -B.
proc libjava_find_spec {} {
global objdir
- set gp [get_multilibs]
-
- if {[file exists $gp/libjava/libgcj.spec]} then {
- return "$gp/libjava/"
- }
return "$objdir/../"
}
-# Find `gij'.
+# Find `gij'. Return empty string if not found.
proc libjava_find_gij {} {
- global base_dir
- set gp [get_multilibs]
- if {$gp != ""} {
- set file $gp/libjava/gij
- } else {
- set file $base_dir/../gij
- }
+ global base_dir objdir
- if {[file exists $file]} {
- return $file
+ set gijdir [lookfor_file [get_multilibs] libjava];
+ # Fall back if get_multilibs fails.
+ if {$gijdir == ""} {
+ set gijdir "$objdir/.."
}
- return gij
+ if {! [file exists $gijdir/gij]} {
+ return ""
+ }
+ return $gijdir/gij
}
# Remove a bunch of files.
global tool_root_dir
global libgcj_jar
global libjava_libgcc_s_path
+ global libjava_ld_library_path
+ global ld_library_path
global target_triplet
if [info exists LIBJAVA] {
# Basically we want to build up a colon separated path list from
# the value of $libjava.
- set lpath {}
+ set lpath "."
foreach dir [list $libjava] {
foreach item [split $dir " "] {
switch -glob -- $item {
set lpath [concat $lpath $libjava_libgcc_s_path]
verbose "lpath = $lpath ; libgcc_s_path = $libjava_libgcc_s_path"
set ld_library_path [join $lpath :]
+ set libjava_ld_library_path "$ld_library_path"
# That's enough to make things work for the normal case.
# 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"
-
- verbose "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
+ set_ld_library_path_env_vars
+ if [info exists env(LD_LIBRARY_PATH)] {
+ verbose "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
+ }
# Determine CLASSPATH separator
if { [string match "i?86-pc-mingw32*" $target_triplet] } {
# 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)
+ global libjava_ld_library_path
+ global ld_library_path
- set newval .
+ set ld_library_path "$libjava_ld_library_path"
if {[llength $ld_library_additions] > 0} {
- append newval :[join $ld_library_additions :]
+ append ld_library_path :[join $ld_library_additions :]
}
- append newval :$lib_path
-
- setenv LD_LIBRARY_PATH $newval
- verbose "LD_LIBRARY_PATH=$env(LD_LIBRARY_PATH)"
+ set_ld_library_path_env_vars
+ if [info exists env(LD_LIBRARY_PATH)] {
+ verbose "LD_LIBRARY_PATH=$env(LD_LIBRARY_PATH)"
+ }
set result [libjava_load ./$program]
set status [lindex $result 0]
set output [lindex $result 1]
# Restore setting
- setenv LD_LIBRARY_PATH $lib_path
+ restore_ld_library_path_env_vars
if {$status != "pass"} {
verbose "got $output"
proc libjava_invoke {errname testName optName executable inpfile resultfile
ld_library_additions args} {
global env
- set lib_path $env(LD_LIBRARY_PATH)
+ global libjava_ld_library_path
+ global ld_library_path
- set newval .
+ set ld_library_path "$libjava_ld_library_path"
if {[llength $ld_library_additions] > 0} {
- append newval :[join $ld_library_additions :]
+ append ld_library_path :[join $ld_library_additions :]
}
- append newval :$lib_path
-
- setenv LD_LIBRARY_PATH $newval
+ set_ld_library_path_env_vars
+ if [info exists env(LD_LIBRARY_PATH)] {
+ verbose "LD_LIBRARY_PATH=$env(LD_LIBRARY_PATH)"
+ }
- verbose "LD_LIBRARY_PATH=$env(LD_LIBRARY_PATH)"
upvar $optName opts
if {[info exists opts(no-exec)]} {
set output [lindex $result 1]
# Restore LD_LIBRARY_PATH setting.
- setenv LD_LIBRARY_PATH $lib_path
+ restore_ld_library_path_env_vars
if {[info exists opts(xfail-exec)]} then {
setup_xfail *-*-*
# We purposely ignore errors here; we still want to run the other
# appropriate tests.
set gij [libjava_find_gij]
- # libjava_find_gij will return `gij' if it couldn't find the
+ # libjava_find_gij will return "" if it couldn't find the
# program; in this case we want to skip the test.
- if {$INTERPRETER == "yes" && $gij != "gij"} {
+ if {$INTERPRETER == "yes" && $gij != ""} {
libjava_invoke $errname "gij test" opts $gij \
$inpfile $resultfile "" $main_name
}
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
# End: