* [binutils-gdb] ld/testsuite: consistently add board_ldflags when linking with GCC
@ 2022-10-17 11:03 =?unknown-8bit?q?Cl=E9ment_Chigot_=3Chelflym=40sourceware=2Eorg=3E?=
0 siblings, 0 replies; only message in thread
From: =?unknown-8bit?q?Cl=E9ment_Chigot_=3Chelflym=40sourceware=2Eorg=3E?= @ 2022-10-17 11:03 UTC (permalink / raw)
To: bfd-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=95a20247e8caf4b2dfe3ccc587fe59d53d0e5bb6
commit 95a20247e8caf4b2dfe3ccc587fe59d53d0e5bb6
Author: Clément Chigot <chigot@adacore.com>
Date: Thu Sep 15 09:23:50 2022 +0200
ld/testsuite: consistently add board_ldflags when linking with GCC
Currently, the functions checking if the compiler is available or if a
feature is available add both board_cflags and board_ldflags.
However, functions running the tests only retrieve board_cflags. This
can lead to unexpected errors when mandaratory flags are defined in
board_ldflags and not board_cflags.
ld/ChangeLog:
* testsuite/ld-unique/unique.exp: Add board_ldflags when
linking with GCC.
* testsuite/lib/ld-lib.exp: Likewise.
Diff:
---
ld/testsuite/ld-unique/unique.exp | 8 +++++++-
ld/testsuite/lib/ld-lib.exp | 22 ++++++++++++++++++----
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/ld/testsuite/ld-unique/unique.exp b/ld/testsuite/ld-unique/unique.exp
index f3d5a5a6b7d..ab24eef50c3 100644
--- a/ld/testsuite/ld-unique/unique.exp
+++ b/ld/testsuite/ld-unique/unique.exp
@@ -122,8 +122,14 @@ if [board_info [target_info name] exists cflags] {
set board_cflags ""
}
+if [board_info [target_info name] exists ldflags] {
+ set board_ldflags " [board_info [target_info name] ldflags]"
+} else {
+ set board_ldflags ""
+}
+
# Create executable containing unique symbol.
-if ![ld_link "$CC_FOR_TARGET $NOPIE_LDFLAGS $board_cflags" "tmpdir/unique_prog" "tmpdir/unique.o"] {
+if ![ld_link "$CC_FOR_TARGET $NOPIE_LDFLAGS $board_cflags $board_ldflags" "tmpdir/unique_prog" "tmpdir/unique.o"] {
fail "Could not link a unique executable"
set fails [expr $fails + 1]
}
diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
index ec27388a72e..2cd840c0169 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -690,6 +690,7 @@ proc run_ld_link_exec_tests { ldtests args } {
global errcnt
global exec_output
global board_cflags
+ global board_ldflags
global STATIC_LDFLAGS
# When using GCC as the linker driver, we need to specify board cflags when
@@ -702,6 +703,12 @@ proc run_ld_link_exec_tests { ldtests args } {
set board_cflags ""
}
+ if [board_info [target_info name] exists ldflags] {
+ set board_ldflags " [board_info [target_info name] ldflags]"
+ } else {
+ set board_ldflags ""
+ }
+
foreach testitem $ldtests {
set testname [lindex $testitem 0]
set ld_options [lindex $testitem 1]
@@ -777,11 +784,11 @@ proc run_ld_link_exec_tests { ldtests args } {
continue;
} else {
if { [string match "" $STATIC_LDFLAGS] \
- && [regexp -- ".* \[-\]+static .*" " $board_cflags $ld_options $objfiles $ld_after "] } {
+ && [regexp -- ".* \[-\]+static .*" " $board_cflags $board_ldflags $ld_options $objfiles $ld_after "] } {
untested $testname
continue
}
- if ![$link_proc $link_cmd $binfile "$board_cflags -L$srcdir/$subdir $ld_options $objfiles $ld_after"] {
+ if ![$link_proc $link_cmd $binfile "$board_cflags $board_ldflags -L$srcdir/$subdir $ld_options $objfiles $ld_after"] {
set failed 1
}
}
@@ -858,6 +865,7 @@ proc run_cc_link_tests { ldtests } {
global ar
global exec_output
global board_cflags
+ global board_ldflags
global STATIC_LDFLAGS
if [board_info [target_info name] exists cflags] {
@@ -866,6 +874,12 @@ proc run_cc_link_tests { ldtests } {
set board_cflags ""
}
+ if [board_info [target_info name] exists ldflags] {
+ set board_ldflags " [board_info [target_info name] ldflags]"
+ } else {
+ set board_ldflags ""
+ }
+
foreach testitem $ldtests {
set testname [lindex $testitem 0]
set ldflags [lindex $testitem 1]
@@ -968,11 +982,11 @@ proc run_cc_link_tests { ldtests } {
}
} else {
if { [string match "" $STATIC_LDFLAGS] \
- && [regexp -- ".* \[-\]+static .*" " $board_cflags $ldflags $objfiles "] } {
+ && [regexp -- ".* \[-\]+static .*" " $board_cflags $board_ldflags $ldflags $objfiles "] } {
untested $testname
continue
}
- ld_link $cc_cmd $binfile "$board_cflags -L$srcdir/$subdir $ldflags $objfiles"
+ ld_link $cc_cmd $binfile "$board_cflags $board_ldflags -L$srcdir/$subdir $ldflags $objfiles"
set ld_output "$exec_output"
if { $check_ld(source) == "regexp" } then {
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-10-17 11:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-17 11:03 [binutils-gdb] ld/testsuite: consistently add board_ldflags when linking with GCC =?unknown-8bit?q?Cl=E9ment_Chigot_=3Chelflym=40sourceware=2Eorg=3E?=
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).