Wrong ELF class plugin vs. gcc ld version

When building 32-bit binutils with CC="gcc -m32" CXX="g++ -m32" we can
fail the gcc ld version test due to an error attempting to load a
64-bit plugin into 32-bit ld-new.  This results in bogus errors about
"Your compiler driver ignores -B when choosing ld."

	* testsuite/lib/ld-lib.exp: Whitespace.
	(load_common_lib): Expand single use and delete this proc.
	(run_host_cmd): Use -fno-lto when getting gcc's ld version.
	Use -B for clang too.
This commit is contained in:
Alan Modra 2021-02-18 14:43:14 +10:30
parent 0be51eb4c3
commit 2f973f134d
2 changed files with 79 additions and 72 deletions

View File

@ -1,3 +1,10 @@
2021-02-19 Alan Modra <amodra@gmail.com>
* testsuite/lib/ld-lib.exp: Whitespace.
(load_common_lib): Expand single use and delete this proc.
(run_host_cmd): Use -fno-lto when getting gcc's ld version.
Use -B for clang too.
2021-02-18 Andrew Burgess <andrew.burgess@embecosm.com>
* testplugin.c (record_read_length): Remove debug fprintf.

View File

@ -18,12 +18,7 @@
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
# MA 02110-1301, USA.
proc load_common_lib { name } {
global srcdir
load_file $srcdir/../../binutils/testsuite/lib/$name
}
load_common_lib binutils-common.exp
load_file $srcdir/../../binutils/testsuite/lib/binutils-common.exp
# Returns 1 if the gcc for the target is at least version MAJOR.MINOR
# Returns 0 otherwise.
@ -108,19 +103,24 @@ proc run_host_cmd { prog command } {
set prog $gccexe
}
set gccexe [string replace $gccexe 0 [string last "/" $gccexe] ""]
if {[string match "*cc*" $gccexe] || [string match "*++*" $gccexe]} then {
if {[string match "*cc*" $gccexe] ||
[string match "*++*" $gccexe] ||
[string match "clang*" $gccexe]} then {
set gccflags "$gcc_B_opt $gccflags $ld_L_opt"
if {![info exists gcc_ld_B_opt_tested]} {
set gcc_ld_B_opt_tested 1
set ld_version_message [run_host_cmd "$ld" "--version"]
set gcc_ld_version_message [run_host_cmd "$prog" "$gccflags -Wl,--version"]
set ver "-Wl,--version"
if [check_lto_available] {
set ver "-fno-lto $ver"
}
set gcc_ld_version_message [run_host_cmd "$prog" "$gccflags $ver"]
if {[string first $ld_version_message $gcc_ld_version_message] < 0} {
perror "************************************************************************"
perror "Your compiler driver ignores -B when choosing ld."
perror "You will not be testing the new ld in many of the following tests."
set gcc_ld_version [run_host_cmd "$prog" "$gccflags --print-prog-name=ld"]
if {![string match "" $gcc_ld_version] && ![string match "ld" $gcc_ld_version]} {
perror "It seems you will be testing $gcc_ld_version instead."
}
perror "************************************************************************"