replacement libgloss.exp
Jeffrey A Law
law@hurl.cygnus.com
Fri Sep 5 14:24:00 GMT 1997
You should be able to use this replacement for dejagnu/lib/libgloss.exp to
get libio/libstdc++ testing working again.
new dependencies
Odds are the next egcs snapshot will depend on this version of libgloss.exp.
You'll need to replace the version in your dejagnu source tree, then do a
make install to get it installed.
I'll put a copy of the new libgloss.exp in the "infrastructure" directory
on the FTP server.
[ I'm looking into the possibility of getting a new dejagnu snapshot made... ]
--
Jeff Law (law@cygnus.com)
Cygnus Solutions EGCS GNU Compiler System
http://www.cygnus.com http://www.cygnus.com/egcs
# Copyright (C) 92, 93, 94, 95, 96, 1997 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# Please email any bugs, comments, and/or additions to this file to:
# bug-dejagnu@prep.ai.mit.edu
# This file was written by Rob Savoye. (rob@cygnus.com)
# this contains a list of gcc options and their respective directories.
#
# Find the pieces of libgloss for testing the GNU development tools
# needed to link a set of object files into an executable.
# This usually means setting the -L and -B paths correctly.
#
proc libgloss_link_flags { args } {
global target_cpu
global srcdir
# libgloss doesn't work native
if [isnative] {
return ""
}
# if we're on a remote host, we can't search for the file, so we can only
# use an installed compiler, so we don't add any paths here.
if [is_remote host] {
return ""
}
set gccpath "[get_multilibs]"
# map the target_cpu to the proper libgloss directory. unfortunately, these
# directory names are hardcoded into libgloss.
switch -glob -- $target_cpu {
"sparclite" {
set cpu sparc
}
"sparclet" {
set cpu sparc
}
"hppa*" {
set cpu pa
}
"mips*" {
set cpu mips
}
"powerpc*" {
set cpu rs6000
}
default {
set cpu $target_cpu
}
}
set gloss_srcdir ""
# look for the libgloss srcdir sp we can find the linker scripts
set gloss_srcdir [lookfor_file ${srcdir} libgloss/$cpu]
# set the proper paths for gcc if the target subdir exists, else assume we
# have no libgloss support for this target.
if { $gloss_srcdir == "" } {
return ""
}
if [file exists $gccpath/libgloss/$cpu] {
verbose "Libgloss path is $gccpath/libgloss/$cpu" 2
return "-B$gccpath/libgloss/$cpu/ -L$gccpath/libgloss/$cpu -L$gloss_srcdir"
} else {
verbose -log "No libgloss support for this target." 2
return "-L$gloss_srcdir"
}
}
# There aren't any, but we'll be orthogonal here.
proc libgloss_include_flags { args } {
return ""
}
#
# Find the newlib libraries in the current source tree.
#
proc newlib_link_flags { args } {
global base_dir
# libgloss doesn't work native
if [isnative] {
return ""
}
# if we're on a remote host, we can't search for the file, so we can only
# use an installed compiler, so we don't add any paths here.
if [is_remote host] {
return ""
}
set ld_script_path [lookfor_file ${base_dir} "ld/ldscripts"];
if { $ld_script_path != "" } {
set result "-L[file dirname $ld_script_path]"
} else {
set result ""
}
set gccpath "[get_multilibs]"
verbose "Looking for $gccpath/newlib"
if [file exists $gccpath/newlib] {
verbose "Newlib path is $gccpath/newlib"
return "$result -B$gccpath/newlib/ -L$gccpath/newlib"
} else {
verbose "No newlib support for this target"
return "$result"
}
}
proc newlib_include_flags { args } {
global srcdir
if [isnative] {
return ""
}
if [is_remote host] {
return ""
}
set gccpath "[get_multilibs]"
if [file exists $gccpath/newlib] {
verbose "Newlib path is $gccpath/newlib"
set newlib_dir [lookfor_file ${srcdir} newlib/libc/include/assert.h]
if { ${newlib_dir} != "" } {
set newlib_dir [file dirname ${newlib_dir}]
}
return " -I$gccpath/newlib/targ-include -I${newlib_dir}"
} else {
verbose "No newlib support for this target"
}
}
proc libio_include_flags { args } {
global srcdir
global base_dir
if [is_remote host] {
return ""
}
set gccpath "[get_multilibs]"
if { $gccpath == "" } {
set gccpath [file dirname [file dirname ${base_dir}]]
}
set libio_bin_dir [lookfor_file ${gccpath} libio/_G_config.h];
set libio_src_dir [lookfor_file ${srcdir} libio/Makefile.in]
if { $libio_bin_dir != "" && $libio_src_dir != "" } {
set libio_src_dir [file dirname ${libio_src_dir}]
set libio_bin_dir [file dirname ${libio_bin_dir}];
return " -I${libio_src_dir} -I${libio_bin_dir}"
} else {
return ""
}
}
proc libio_link_flags { args } {
if [is_remote host] {
return ""
}
set gccpath "[get_multilibs]"
set libio_dir [lookfor_file ${gccpath} libio/libio.a]
if { $libio_dir != "" } {
return "-L[file dirname ${libio_dir}]"
} else {
return ""
}
}
proc g++_include_flags { args } {
global srcdir
if [is_remote host] {
return ""
}
set gccpath [get_multilibs]
set libio_dir ""
set flags ""
set dir [lookfor_file ${srcdir} libg++]
if { ${dir} != "" } {
append flags "-I${dir} -I${dir}/src "
}
set dir [lookfor_file ${srcdir} libstdc++]
if { ${dir} != "" } {
append flags "-I${dir} -I${dir}/stl"
}
return "$flags"
}
proc g++_link_flags { args } {
global srcdir
set gccpath [get_multilibs];
set libio_dir ""
set flags ""
if { $gccpath != "" } {
if [file exists "${gccpath}/libg++/libg++.a"] {
append flags "-L${gccpath}/libg++ "
}
if [file exists "${gccpath}/libstdc++/libstdc++.a"] {
append flags "-L${gccpath}/libstdc++ "
}
if [file exists "${gccpath}/libiberty/libiberty.a"] {
append flags "-L${gccpath}/libiberty "
}
if [file exists "${gccpath}/librx/librx.a"] {
append flags "-L${gccpath}/librx "
}
} else {
global objdir;
set libgpp [lookfor_file ${objdir} libg++];
if { $libgpp != "" } {
append flags "-L${libgpp} ";
}
set libstdcpp [lookfor_file ${objdir} libstdc++];
if { $libstdcpp != "" } {
append flags "-L${libstdcpp} ";
}
set libiberty [lookfor_file ${objdir} libiberty];
if { $libiberty != "" } {
append flags "-L${libiberty} ";
}
set librx [lookfor_file ${objdir} librx];
if { $librx != "" } {
append flags "-L${librx} ";
}
}
return "$flags"
}
proc libstdc++_include_flags { args } {
global srcdir
if [is_remote host] {
return ""
}
set gccpath [get_multilibs]
set libio_dir ""
set flags ""
set dir [lookfor_file ${srcdir} libstdc++]
if { ${dir} != "" } {
append flags "-I${dir} -I${dir}/stl"
}
return "$flags"
}
proc libstdc++_link_flags { args } {
global srcdir
set gccpath [get_multilibs];
set libio_dir ""
set flags ""
if { $gccpath != "" } {
if [file exists "${gccpath}/libstdc++/libstdc++.a"] {
append flags "-L${gccpath}/libstdc++ "
}
if [file exists "${gccpath}/libiberty/libiberty.a"] {
append flags "-L${gccpath}/libiberty "
}
if [file exists "${gccpath}/librx/librx.a"] {
append flags "-L${gccpath}/librx "
}
} else {
global objdir;
set libstdcpp [lookfor_file ${objdir} libstdc++];
if { $libstdcpp != "" } {
append flags "-L${libstdcpp} ";
}
set libiberty [lookfor_file ${objdir} libiberty];
if { $libiberty != "" } {
append flags "-L${libiberty} ";
}
set librx [lookfor_file ${objdir} librx];
if { $librx != "" } {
append flags "-L${librx} ";
}
}
return "$flags"
}
#
# Get the list of directories and -m options for gcc. This is kinda bogus that
# generic testing software needs support for gcc hardwired in, but to make
# testing the GNU tools work right, there didn't seem to be any other way.
#
proc get_multilibs { args } {
global target_alias
global board
global board_info
# if we're on a remote host, we can't search for the file, so we can only
# use an installed compiler, so we don't add any paths here.
if [is_remote host] {
return ""
}
if [info exists board] {
set target_board $board;
} else {
set target_board [target_info name];
}
if { [llength $args] == 0 } {
if [board_info $target_board exists multitop] {
return "[board_info $target_board multitop]";
}
set board_info($target_board,multitop) ""
}
if { [info exists board] && [board_info $target_board exists compiler] } {
set compiler [board_info $target_board compiler];
} else {
set compiler [find_gcc];
}
if { $compiler == "" } {
return "";
}
foreach x "$compiler" {
if [regexp "^-B" "$x"] {
regsub "^-B" "$x" "" comp_base_dir;
set comp_base_dir [file dirname $comp_base_dir];
break;
}
}
if { [llength $args] > 0 } {
set mopts [lindex $args 0];
}
if ![info exists opts] {
if { [info exists board] && [board_info $target_board exists multilib_flags] } {
set mopts [board_info $target_board multilib_flags];
} else {
set mopts ""
}
}
regsub "^-" $mopts "" moptions
regsub -all " -" $moptions " " dirty_moptions
set moptions ""
foreach x [split $dirty_moptions " "] {
if { $x != "" && [lsearch -exact $moptions $x] < 0 } {
lappend moptions $x
}
}
regexp "/.* " $compiler compiler
set compiler [string trimright $compiler " "]
verbose "compiler is $compiler"
if ![info exists comp_base_dir] {
set comp_base_dir [which $compiler];
if { $comp_base_dir == 0 } {
return "";
}
set comp_base_dir [file dirname [file dirname $comp_base_dir]];
} else {
if { [which $compiler] == 0 } {
return "";
}
}
# extract the options and their directory names as know by gcc
foreach i "[exec $compiler --print-multi-lib]" {
set opts ""
set dir ""
regexp -- "\[a-z0-9/\.-\]*;" $i dir
set dir [string trimright $dir "\;@"]
regexp -- "\;@*\[\@a-zA-Z0-9/\.-\]*" $i opts
set opts [split [string trimleft $opts "\;@"] "@"]
lappend multilibs "$dir {$opts }"
}
# search for the top level multilib directory
set multitop [lookfor_file "${comp_base_dir}" "${target_alias}"]
if { $multitop == "" } {
set multitop [lookfor_file "${comp_base_dir}" "libraries"]
if { $multitop == "" } {
set multitop "[lookfor_file ${comp_base_dir} gcc/xgcc]"
if { $multitop != "" } {
set multitop [file dirname [file dirname $multitop]];
} else {
return ""
}
}
}
# make a list of -m<foo> options from the various compiler config variables
set gccpath ""
# compare the lists of gcc options with the list of support multilibs
verbose "Supported multilibs are: $multilibs" 3
foreach i "$multilibs" {
set hits 0
set opts [lindex $i 1];
if { [llength $moptions] == [llength $opts] } {
foreach j "$moptions" {
# see if all the -m<foo> options match any of the multilibs
verbose "Looking in $i for $j" 3
if { [lsearch -exact $opts $j] >= 0 } {
incr hits
}
}
if { $hits == [llength $moptions] } {
verbose "Got a hit, adding [lindex $i 0] to gcc path" 2
set gccpath "[lindex $i 0]"
break
}
}
}
if ![info exists multitop] {
return "";
}
verbose "gccpath is $gccpath" 3
if [file exists $multitop/$gccpath] {
verbose "GCC path is $multitop/$gccpath" 3
if { [llength $args] == 0 } {
set board_info($target_board,multitop) "$multitop/$gccpath"
}
return "$multitop/$gccpath"
} else {
verbose "GCC path is $multitop" 3
set board_info($target_board,multitop) "$multitop"
return "$multitop"
}
}
proc find_gcc {} {
global base_dir
if ![is_remote host] {
set file [lookfor_file $base_dir xgcc];
if { $file == "" } {
set file [lookfor_file $base_dir gcc/xgcc];
}
if { $file != "" } {
set CC "$file -B[file dirname $file]/";
} else {
set CC [transform gcc];
}
} else {
set CC [transform gcc]
}
return $CC;
}
proc find_g++ {} {
global base_dir
if ![is_remote host] {
set file [lookfor_file $base_dir g++];
if { $file == "" } {
set file [lookfor_file $base_dir gcc/g++];
}
if { $file != "" } {
set CC "$file -B[file dirname $file]/";
} else {
set CC [transform g++];
}
} else {
set CC [transform g++]
}
return $CC;
}
proc process_multilib_options { args } {
global board;
global board_variant_list;
global is_gdb_remote;
set is_gdb_remote 0;
if [board_info $board exists multilib_flags] {
return;
}
eval add_multilib_option $args;
set multilib_flags "";
foreach x $board_variant_list {
regsub -all "^\[ \t\]*" "$x" "" x;
regsub -all "\[ \t\]*$" "$x" "" x;
if { $x == "" } {
continue;
}
case $x in {
{ aout } {
set_board_info obj_format "a.out";
}
{ elf } {
set_board_info obj_format "elf";
}
{ pe } {
set_board_info obj_format "pe";
}
{ ecoff } {
set_board_info obj_format "ecoff";
}
{ stabs } {
set_board_info debug_flags "-gstabs";
}
{ dwarf2 } {
set_board_info debug_flags "-gdwarf2";
}
{ gdb*remote } {
set is_gdb_remote 1;
}
{ little*endian el EL } {
append multilib_flags " -EL";
}
{ big*endian eb EB } {
append multilib_flags " -EB";
}
{ "soft*float" } {
append multilib_flags " -msoft-float"
}
{ "-*" } {
append multilib_flags " $x";
}
default {
append multilib_flags " -m$x";
}
}
}
set_board_info multilib_flags $multilib_flags;
}
proc add_multilib_option { args } {
global board_variant_list
if ![info exists board_variant_list] {
set board_variant_list ""
}
set board_variant_list [concat $args $board_variant_list];
}
proc find_gas { } {
global base_dir
set AS ""
if ![is_remote host] {
set AS [lookfor_file $base_dir as-new];
if { $AS == "" } {
set AS [lookfor_file $base_dir gas/as-new];
}
}
if { $AS == "" } {
set AS [transform as];
}
return $AS;
}
proc build_wrapper { gluefile } {
global libdir
if [target_info exists wrap_m68k_aout] {
set flags "additional_flags=-DWRAP_M68K_AOUT";
set result "";
} elseif [target_info exists uses_underscores] {
set flags "additional_flags=-DUNDERSCORES";
set result "-Wl,-wrap,__exit -Wl,-wrap,_main -Wl,-wrap,_abort";
} else {
set flags "";
set result "-Wl,-wrap,exit -Wl,-wrap,main -Wl,-wrap,abort";
}
if [target_info exists wrap_compile_flags] {
lappend flags "additional_flags=[target_info wrap_compile_flags]";
}
if { [target_compile ${libdir}/testglue.c ${gluefile} object $flags] == "" } {
set gluefile [remote_download host ${gluefile} testglue.o];
return [list $gluefile $result];
} else {
return ""
}
}
proc winsup_include_flags { args } {
global srcdir
if [isnative] {
return ""
}
if [is_remote host] {
return ""
}
set gccpath "[get_multilibs]"
if [file exists $gccpath/winsup] {
verbose "Winsup path is $gccpath/winsup"
set winsup_dir [lookfor_file ${srcdir} winsup/include/windows]
if { ${winsup_dir} != "" } {
set winsup_dir [file dirname ${winsup_dir}]
return " -I${winsup_dir}"
}
}
verbose "No winsup support for this target"
}
#
# Find the winsup libraries in the current source tree.
#
proc winsup_link_flags { args } {
global base_dir
# libgloss doesn't work native
if [isnative] {
return ""
}
# if we're on a remote host, we can't search for the file, so we can only
# use an installed compiler, so we don't add any paths here.
if [is_remote host] {
return ""
}
set gccpath "[get_multilibs]"
verbose "Looking for $gccpath/winsup"
if [file exists $gccpath/winsup] {
verbose "Winsup path is $gccpath/newlib"
return "-B$gccpath/winsup/ -L$gccpath/winsup"
} else {
verbose "No winsup support for this target"
return ""
}
}
More information about the Gcc
mailing list