# Expect script for LD Bootstrap Tests
-# Copyright 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2004,
-# 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
+# Copyright (C) 1993-2020 Free Software Foundation, Inc.
#
# This file is part of the GNU Binutils.
#
# order to test -r. Then link the result into an executable, ld1, to
# really test -r. Use ld1 to link a fresh ld, ld2. Use ld2 to link a
# new ld, ld3. ld2 and ld3 should be identical.
-set test_flags {"" "strip" "--static" "--traditional-format"
- "--no-keep-memory" "--relax"}
+set test_flags {"" "strip" "--static" "-Wl,--traditional-format"
+ "-Wl,--no-keep-memory" "-Wl,--relax"}
if { [istarget "powerpc-*-*"] } {
- lappend test_flags "--ppc476-workaround"
+ lappend test_flags "-Wl,--ppc476-workaround"
+}
+
+set gcc_B_opt_save $gcc_B_opt
+
+foreach ldexe {ld1 ld2 ld3} {
+ if {![file isdirectory tmpdir/gcc$ldexe]} then {
+ catch "exec mkdir tmpdir/gcc$ldexe" status
+ catch "exec ln -s ../$ldexe tmpdir/gcc$ldexe/ld" status
+ catch "exec ln -s ld tmpdir/gcc$ldexe/collect-ld" status
+ catch "exec ln -s ../../../gas/as-new tmpdir/gcc$ldexe/as" status
+ }
}
foreach flags $test_flags {
+ set gcc_B_opt $gcc_B_opt_save
set do_strip "no"
if {"$flags" == "strip"} {
set testname "bootstrap with $flags"
}}
# --static is meaningless and --relax is incompatible with -r.
- set partial_flags "$flags"
- if { "$flags" == "--static" || "$flags" == "--relax" } {
+ regsub -- "-Wl," $flags "" partial_flags
+ if { "$partial_flags" == "--static" || "$partial_flags" == "--relax" } {
set partial_flags ""
}
continue
}
+ # If -static doesn't work, these tests will fail.
+ if { $flags == "--static" && [string match "" $STATIC_LDFLAGS] } then {
+ untested $testname
+ continue
+ }
+
# Plugin support requires linking with a dynamic library which
# means that these tests will fail.
if { $flags == "--static" && $plugins == "yes" } then {
}
}
+ # Check if the system's zlib library is used.
+ if {[file exists ../zlib/Makefile ]} then {
+ set extralibs "$extralibs -L../zlib -lz"
+ } else {
+ set extralibs "$extralibs -lz"
+ }
+
# Plugin support requires linking with libdl.
if { $plugins == "yes" } {
- set extralibs "$extralibs -ldl"
+ if { ![istarget "*-*-freebsd*"]} {
+ set extralibs "$extralibs -ldl"
+ }
}
# On Irix 5, linking with --static only works if all the files are
setup_xfail "mips*-*-irix5*"
}
- if ![ld_link $ld tmpdir/ld1 "$flags tmpdir/ld-partial.o $BFDLIB $LIBIBERTY $extralibs"] {
+ if ![ld_link $CC tmpdir/ld1 "$flags tmpdir/ld-partial.o $CTFLIB $BFDLIB $LIBIBERTY $extralibs"] {
fail $testname
continue
}
if {"$do_strip" == "yes"} {
verbose -log "$strip tmpdir/ld1"
catch "exec $strip tmpdir/ld1" exec_output
+ set exec_output [prune_warnings $exec_output]
if ![string match "" $exec_output] then {
verbose -log "$exec_output"
fail $testname
}
}
- if ![ld_link tmpdir/ld1 tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
+ regsub /tmpdir/ld/ $gcc_B_opt_save /tmpdir/gccld1/ gcc_B_opt
+ if ![ld_link $CC tmpdir/ld2 "$flags $OFILES $CTFLIB $BFDLIB $LIBIBERTY $extralibs"] {
fail $testname
continue
}
- if ![ld_link tmpdir/ld2 tmpdir/ld3 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
+ regsub /tmpdir/ld/ $gcc_B_opt_save /tmpdir/gccld2/ gcc_B_opt
+ if ![ld_link $CC tmpdir/ld3 "$flags $OFILES $CTFLIB $BFDLIB $LIBIBERTY $extralibs"] {
fail $testname
continue
}
- if {"$flags" == "--static"} {
- if { [istarget ia64-*-elf*]
- || [istarget ia64-*-linux*] } {
- # On ia64, tmpdir/ld2 != tmpdir/ld3 is normal since they are
- # generated by different linkers, tmpdir/ld1 and tmpdir/ld2.
- # So we rebuild tmpdir/ld2 with tmpdir/ld3.
- if ![ld_link tmpdir/ld3 tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
- fail $testname
- continue
- }
- }
- } else {
- if { [istarget mips*-*-linux*] } {
- # On Linux/mips, tmpdir/ld2 != tmpdir/ld3 is normal since
- # they are generated by different linkers, tmpdir/ld1 and
- # tmpdir/ld2. So we rebuild tmpdir/ld2 with tmpdir/ld3.
- if ![ld_link tmpdir/ld3 tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
- fail $testname
- continue
- }
+ if { "$flags" == "--static"
+ && ([istarget ia64-*-elf*]
+ || [istarget ia64-*-linux*]
+ || [istarget mips*-*-linux*]) } {
+ # On ia64 and mips, tmpdir/ld2 != tmpdir/ld3 is normal since they are
+ # generated by different linkers, tmpdir/ld1 and tmpdir/ld2.
+ # So we rebuild tmpdir/ld2 with tmpdir/ld3.
+ regsub /tmpdir/ld/ $gcc_B_opt_save /tmpdir/gccld3/ gcc_B_opt
+ if ![ld_link $CC tmpdir/ld2 "$flags $OFILES $CTFLIB $BFDLIB $LIBIBERTY $extralibs"] {
+ fail $testname
+ continue
}
}
}
}
+set gcc_B_opt $gcc_B_opt_save
catch "exec rm -f tmpdir/ld-partial.o tmpdir/ld1 tmpdir/ld2 tmpdir/ld3" status
catch "exec rm -f tmpdir/ld2tail tmpdir/ld3tail" status