]> Git Repo - binutils.git/blob - ld/testsuite/ld-bootstrap/bootstrap.exp
ld: Skip bootstrap tests for -fprofile-generate=
[binutils.git] / ld / testsuite / ld-bootstrap / bootstrap.exp
1 # Expect script for LD Bootstrap Tests
2 #   Copyright (C) 1993-2020 Free Software Foundation, Inc.
3 #
4 # This file is part of the GNU Binutils.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 # MA 02110-1301, USA.
20 #
21 # Written by Jeffrey Wheat ([email protected])
22 # Rewritten by Ian Lance Taylor ([email protected])
23 #
24
25 # Make sure that ld can bootstrap itself.
26
27 # This test can only be run if ld generates native executables.
28 if ![isnative] {
29     return
30 }
31
32 # Skip for -fprofile-generate=.
33 catch "exec $nm $plug_opt $OFILES" exec_output
34 send_log "foo: $exec_output"
35 if { [ string match "*__gcov_*" $exec_output ] } {
36     return
37 }
38
39 remote_exec host "$nm --help" "" "/dev/null" "plugin-support"
40 set tmp [file_contents "plugin-support"]
41 regexp ".*\(--plugin\).*\n" $tmp foo plugins
42 if [info exists plugins] then {
43     set plugins "yes"
44 } else {
45     set plugins "no"
46 }
47
48 # LD can have plugin support even if BFD does not.
49 if [check_plugin_api_available] {
50     set plugins "yes"
51 }
52
53 # Bootstrap ld.  First link the object files together using -r, in
54 # order to test -r.  Then link the result into an executable, ld1, to
55 # really test -r.  Use ld1 to link a fresh ld, ld2.  Use ld2 to link a
56 # new ld, ld3.  ld2 and ld3 should be identical.
57 set test_flags {"" "strip" "--static" "-Wl,--traditional-format"
58                 "-Wl,--no-keep-memory" "-Wl,--relax"}
59 if { [istarget "powerpc-*-*"] } {
60     lappend test_flags "-Wl,--ppc476-workaround"
61 }
62
63 set gcc_B_opt_save $gcc_B_opt
64
65 foreach ldexe {ld1 ld2 ld3} {
66     if {![file isdirectory tmpdir/gcc$ldexe]} then {
67         catch "exec mkdir tmpdir/gcc$ldexe" status
68         catch "exec ln -s ../$ldexe tmpdir/gcc$ldexe/ld" status
69         catch "exec ln -s ld tmpdir/gcc$ldexe/collect-ld" status
70         catch "exec ln -s ../../../gas/as-new tmpdir/gcc$ldexe/as" status
71     }
72 }
73
74 foreach flags $test_flags {
75     set gcc_B_opt $gcc_B_opt_save
76     set do_strip "no"
77     if {"$flags" == "strip"} { 
78         set testname "bootstrap with $flags"
79         set flags ""
80         set do_strip "yes"
81     } else { if {"$flags" != ""} { 
82         set testname "bootstrap with $flags"
83     } else {
84         set testname "bootstrap"
85     }}
86
87     # --static is meaningless and --relax is incompatible with -r.
88     regsub -- "-Wl," $flags "" partial_flags
89     if { "$partial_flags" == "--static" || "$partial_flags" == "--relax" } {
90         set partial_flags ""
91     }
92
93     if { $partial_flags == "--ppc476-workaround" } {
94         append partial_flags " -T $srcdir/$subdir/ppc476.t"
95     }
96
97     # This test can only be run if we have the ld build directory,
98     # since we need the object files.
99     if {$ld != "$objdir/ld-new"} {
100         untested $testname
101         continue
102     }
103
104     # If -static doesn't work, these tests will fail.
105     if { $flags == "--static" && [string match "" $STATIC_LDFLAGS] } then {
106         untested $testname
107         continue
108     }
109
110     # Plugin support requires linking with a dynamic library which
111     # means that these tests will fail.
112     if { $flags == "--static" && $plugins == "yes" } then {
113         untested $testname
114         continue
115     }
116
117     # If we only have a shared libbfd, we probably can't run the
118     # --static test.
119     if { $flags == "--static" && ! [string match "*libbfd.a*" $BFDLIB] } then {
120         untested $testname
121         continue
122     }
123
124     if ![ld_relocate $ld tmpdir/ld-partial.o "$partial_flags $OFILES"] {
125         fail $testname
126         continue
127     }
128
129     # On AIX, you need to specify an import list when using --static.
130     # You only want the import list when creating the final
131     # executable.
132     if { [istarget "*-*-aix*"] 
133          && ![istarget "ia64-*-aix*"]} {
134         if {"$flags" == "--static"} {
135             set flags "--static -bI:/lib/syscalls.exp"
136         }
137     }
138
139     # On Cygwin, -lintl may require -liconv when linking statically.
140     set extralibs ""
141     if { [istarget "*-*-cygwin*"]} {
142         if {"$flags" == "--static"} {
143             set extralibs "-liconv"
144         }
145     }
146
147     # Check if the system's zlib library is used.
148     if {[file exists ../zlib/Makefile ]} then {
149         set extralibs "$extralibs -L../zlib -lz"
150     } else {
151         set extralibs "$extralibs -lz"
152     }
153
154     # Plugin support requires linking with libdl.
155     if { $plugins == "yes" } {
156         if { ![istarget "*-*-freebsd*"]} {
157             set extralibs "$extralibs -ldl"
158         }
159     }
160
161     # On Irix 5, linking with --static only works if all the files are
162     # compiled using -non_shared.
163     if {"$flags" == "--static"} {
164         setup_xfail "mips*-*-irix5*"
165     }
166
167     if ![ld_link $CC tmpdir/ld1 "$flags tmpdir/ld-partial.o $CTFLIB $BFDLIB $LIBIBERTY $extralibs"] {
168         fail $testname
169         continue
170     }
171
172     if {"$do_strip" == "yes"} { 
173         verbose -log "$strip tmpdir/ld1"     
174         catch "exec $strip tmpdir/ld1" exec_output
175         set exec_output [prune_warnings $exec_output]
176         if ![string match "" $exec_output] then {
177             verbose -log "$exec_output"
178             fail $testname
179             continue
180         }
181     }
182
183     regsub /tmpdir/ld/ $gcc_B_opt_save /tmpdir/gccld1/ gcc_B_opt
184     if ![ld_link $CC tmpdir/ld2 "$flags $OFILES $CTFLIB $BFDLIB $LIBIBERTY $extralibs"] {
185         fail $testname
186         continue
187     }
188
189     regsub /tmpdir/ld/ $gcc_B_opt_save /tmpdir/gccld2/ gcc_B_opt
190     if ![ld_link $CC tmpdir/ld3 "$flags $OFILES $CTFLIB $BFDLIB $LIBIBERTY $extralibs"] {
191         fail $testname
192         continue
193     }
194
195     if { "$flags" == "--static"
196          && ([istarget ia64-*-elf*]
197              || [istarget ia64-*-linux*]
198              || [istarget mips*-*-linux*]) } {
199         # On ia64 and mips, tmpdir/ld2 != tmpdir/ld3 is normal since they are
200         # generated by different linkers, tmpdir/ld1 and tmpdir/ld2.
201         # So we rebuild tmpdir/ld2 with tmpdir/ld3.
202         regsub /tmpdir/ld/ $gcc_B_opt_save /tmpdir/gccld3/ gcc_B_opt
203         if ![ld_link $CC tmpdir/ld2 "$flags $OFILES $CTFLIB $BFDLIB $LIBIBERTY $extralibs"] {
204             fail $testname
205             continue
206         }
207     }
208
209     if {[istarget "*-*-pe"]
210         || [istarget "*-*-wince"]
211         || [istarget "*-*-cygwin*"]
212         || [istarget "*-*-winnt*"]
213         || [istarget "*-*-mingw*"]
214         || [istarget "*-*-interix*"]
215         || [istarget "*-*-beospe*"]
216         || [istarget "*-*-netbsdpe*"]} {
217         # Trim off the date present in PE binaries by only looking
218         #   at the ends of the files
219         # Although this works, a way to set the date would be better.
220         # Removing or zeroing the date stamp in the binary produced by
221         # the linker is not possible as it is required by the target OS.
222         set do_compare [string map {16 220 f1 tmpdir/ld2 f2 tmpdir/ld3 tmp-foo1 tmpdir/ld2tail tmp-foo2 tmpdir/ld3tail} $DO_COMPARE]
223         send_log "$do_compare\n"
224         verbose  "$do_compare"
225         catch "exec sh -c [list $do_compare]" exec_output
226     } else {
227         send_log "cmp tmpdir/ld2 tmpdir/ld3\n"
228         verbose  "cmp tmpdir/ld2 tmpdir/ld3"
229         catch "exec cmp tmpdir/ld2 tmpdir/ld3" exec_output
230     }
231     set exec_output [prune_warnings $exec_output]
232
233     if [string match "" $exec_output] then {
234         pass $testname
235     } else {
236         send_log "$exec_output\n"
237         verbose "$exec_output" 1
238
239         fail $testname
240     }
241 }
242
243 set gcc_B_opt $gcc_B_opt_save
244 catch "exec rm -f tmpdir/ld-partial.o tmpdir/ld1 tmpdir/ld2 tmpdir/ld3" status
245 catch "exec rm -f tmpdir/ld2tail tmpdir/ld3tail" status
This page took 0.039976 seconds and 4 git commands to generate.