2018-06-05 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.misc-tests / linkage.exp
blob0a1cc231acf1c6b6230d348379c9ce36d630406e
1 # Copyright (C) 1988-2018 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with GCC; see the file COPYING3. If not see
15 # <http://www.gnu.org/licenses/>.
17 # This file used to be gcc.c-torture/special/special.exp, which
18 # was written by Rob Savoye. (rob@cygnus.com)
19 # All the other tests driven by that file have since been moved elsewhere.
21 load_lib gcc-defs.exp
23 # These tests don't run runtest_file_p consistently if it
24 # doesn't return the same values, so disable parallelization
25 # of this *.exp file. The first parallel runtest to reach
26 # this will run all the tests serially.
27 if ![gcc_parallel_test_run_p linkage] {
28 return
30 gcc_parallel_test_enable 0
32 if { [isnative] && ![is_remote host] } then {
33 set lines [gcc_target_compile "$srcdir/$subdir/linkage-x.c" "linkage-x.o" object {additional_flags="-w"}]
34 if ![string match "" $lines] then {
35 fail "$subdir/linkage.c compile"
36 } else {
37 # This is a completely bogus test. Sorry.
39 # Need to ensure ABI for native compiler matches gcc
40 set native_cflags ""
41 if [istarget "sparc*-sun-solaris2*"] {
42 set file_string [exec file "linkage-x.o"]
43 if [ string match "*64*" $file_string ] {
44 set native_cflags "-xarch=v9"
47 if {[istarget "i?86*-*-solaris2*"] || [istarget "x86_64-*-solaris2.1\[0-9\]*"]} {
48 set file_string [exec file "linkage-x.o"]
49 if [ string match "*64*" $file_string ] {
50 set native_cflags "-xarch=amd64"
53 if [istarget "s390*-*-linux*"] {
54 set file_string [exec file "linkage-x.o"]
55 if [ string match "*32-bit*" $file_string ] {
56 set native_cflags "-m31"
58 if [ string match "*64-bit*" $file_string ] {
59 set native_cflags "-m64"
61 } elseif {[istarget "i?86-*-linux*"] || [istarget "x86_64-*-linux*"]
62 || [istarget "i?86-*-gnu*"] || [istarget "x86_64-*-gnu*"] } then {
63 set file_string [exec file "linkage-x.o"]
64 if [ string match "*32-bit*" $file_string ] {
65 set native_cflags "-m32"
67 if [ string match "*64-bit*" $file_string ] {
68 set native_cflags "-m64"
70 } elseif [istarget "*-hp-hpux*"] {
71 set file_string [exec file "linkage-x.o"]
72 if [ string match "*ELF-64*" $file_string ] {
73 set native_cflags "+DD64"
75 } elseif [istarget "powerpc*-*-linux*"] {
76 set file_string [exec file "linkage-x.o"]
77 if [ string match "*64-bit*" $file_string ] {
78 set native_cflags "-m64"
79 } elseif [ string match "*32-bit*" $file_string ] {
80 set native_cflags "-m32"
82 } elseif [istarget "powerpc*-*-darwin*"] {
83 set file_string [exec file "linkage-x.o"]
84 if [ string match "*ppc64" $file_string ] {
85 set native_cflags "-m64"
86 } elseif [ string match "*ppc" $file_string ] {
87 set native_cflags "-m32"
89 } elseif [istarget "tilegx-*-linux*"] {
90 set file_string [exec file "linkage-x.o"]
91 if [ string match "*64-bit*" $file_string ] {
92 set native_cflags "-m64"
93 } elseif [ string match "*32-bit*" $file_string ] {
94 set native_cflags "-m32"
96 } elseif [istarget "*86*-*-darwin*"] {
97 set file_string [exec file "linkage-x.o"]
98 if [ string match "*64*" $file_string ] {
99 set native_cflags "-m64"
100 } elseif [ string match "*i386" $file_string ] {
101 set native_cflags "-m32"
105 if [file exists "linkage-y.o"] then {
106 file delete "linkage-y.o"
108 send_log "cc -c $native_cflags $srcdir/$subdir/linkage-y.c >&/dev/null\n"
109 catch { exec cc -c $native_cflags "$srcdir/$subdir/linkage-y.c" >&/dev/null }
110 if ![file exists "linkage-y.o"] then {
111 send_log "c89 -c $native_cflags $srcdir/$subdir/linkage-y.c >&/dev/null\n"
112 catch { exec c89 -c $native_cflags "$srcdir/$subdir/linkage-y.c" >&/dev/null }
114 if [file exists "linkage-y.o"] then {
115 set lines [gcc_target_compile "linkage-y.o linkage-x.o" "linkage.exe" executable ""]
116 if [string match "" $lines] then {
117 pass "$subdir/linkage.c link"
118 file delete "linkage.exe"
119 } else {
120 fail "$subdir/linkage.c link"
122 file delete "linkage-y.o"
123 } else {
124 unsupported "$subdir/linkage.c native compile failed"
126 file delete "linkage-x.o"
130 gcc_parallel_test_enable 1