OSDN Git Service

gcc/testsuite:
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.misc-tests / linkage.exp
1 # Copyright (C) 1988, 90-96, 1997, 2000, 2001, 2002, 2007, 2008, 2010
2 # Free Software Foundation, Inc.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GCC; see the file COPYING3.  If not see
16 # <http://www.gnu.org/licenses/>.
17
18 # This file used to be gcc.c-torture/special/special.exp, which
19 # was written by Rob Savoye. (rob@cygnus.com)
20 # All the other tests driven by that file have since been moved elsewhere.
21
22 if { [isnative] && ![is_remote host] } then {
23     set lines [gcc_target_compile "$srcdir/$subdir/linkage-x.c" "linkage-x.o" object {additional_flags="-w"}]
24     if ![string match "" $lines] then {
25         fail "$subdir/linkage.c compile"
26     } else {
27         # This is a completely bogus test. Sorry.
28
29         # Need to ensure ABI for native compiler matches gcc
30         set native_cflags ""
31         if  [istarget "mips-sgi-irix6*"] {
32             set file_string [exec file "linkage-x.o"]
33             if [ string match "*64*" $file_string ] {
34                 set native_cflags "-64"
35             }
36             if [ string match "*ELF 32*" $file_string ] {
37                 set native_cflags "-32"
38             }
39             if [ string match "*N32*" $file_string ] {
40                 set native_cflags "-n32"
41             }
42         }
43         if  [istarget "sparc*-sun-solaris2*"] {
44             set file_string [exec file "linkage-x.o"]
45             if [ string match "*64*" $file_string ] {
46                 set native_cflags "-xarch=v9"
47             }
48         }
49         if  {[istarget "i?86*-*-solaris2*"]
50              || [istarget "x86_64-*-solaris2.1\[0-9\]*"]} {
51             set file_string [exec file "linkage-x.o"]
52             if [ string match "*64*" $file_string ] {
53                 set native_cflags "-xarch=amd64"
54             }
55         }
56         if [istarget "s390*-*-linux*"] {
57             set file_string [exec file "linkage-x.o"]
58             if [ string match "*32-bit*" $file_string ] {
59                 set native_cflags "-m31"
60             }
61             if [ string match "*64-bit*" $file_string ] {
62                 set native_cflags "-m64"
63             }
64         } elseif {[istarget "i*86-*-linux*"] || [istarget "x86_64-*-linux*"]} {
65             set file_string [exec file "linkage-x.o"]
66             if [ string match "*32-bit*" $file_string ] {
67                 set native_cflags "-m32"
68             }
69             if [ string match "*64-bit*" $file_string ] {
70                 set native_cflags "-m64"
71             }
72         } elseif [istarget "*-hp-hpux*"] {
73             set file_string [exec file "linkage-x.o"]
74             if [ string match "*ELF-64*" $file_string ] {
75                 set native_cflags "+DD64"
76             }
77         } elseif [istarget "powerpc*-*-linux*"] {
78             set file_string [exec file "linkage-x.o"]
79             if [ string match "*64-bit*" $file_string ] {
80                 set native_cflags "-m64"
81             } elseif [ string match "*32-bit*" $file_string ] {
82                 set native_cflags "-m32"
83             }
84         } elseif [istarget "powerpc*-*-darwin*"] {
85             set file_string [exec file "linkage-x.o"]
86             if [ string match "*ppc64" $file_string ] {
87                 set native_cflags "-m64"
88             } elseif [ string match "*ppc" $file_string ] {
89                 set native_cflags "-m32"
90             }
91         } elseif [istarget "*86*-*-darwin*"] {
92            set file_string [exec file "linkage-x.o"]
93            if [ string match "*64*" $file_string ] {
94                 set native_cflags "-m64"
95            } elseif [ string match "*i386" $file_string ] {
96                 set native_cflags "-m32"
97            }
98         }
99
100         if [file exists "linkage-y.o"] then {
101             file delete "linkage-y.o"
102         }
103         send_log "cc -c $native_cflags $srcdir/$subdir/linkage-y.c >&/dev/null\n"
104         catch { exec cc -c $native_cflags "$srcdir/$subdir/linkage-y.c" >&/dev/null }
105         if ![file exists "linkage-y.o"] then {
106             send_log "c89 -c $native_cflags $srcdir/$subdir/linkage-y.c >&/dev/null\n"
107             catch { exec c89 -c $native_cflags "$srcdir/$subdir/linkage-y.c" >&/dev/null }
108         }
109         if [file exists "linkage-y.o"] then {
110             set lines [gcc_target_compile "linkage-y.o linkage-x.o" "linkage.exe" executable ""]
111             if [string match "" $lines] then {
112                 pass "$subdir/linkage.c link"
113                 file delete "linkage.exe"
114             } else {
115                 fail "$subdir/linkage.c link"
116             }
117             file delete "linkage-y.o"
118         } else {
119             unsupported "$subdir/linkage.c native compile failed"
120         }
121         file delete "linkage-x.o"
122     }
123 }