This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] [ld, testsuite] Honor cflags when GCC used as linker driver


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9966f7eece39ced8a09c190616b5b328bf97bfe5

commit 9966f7eece39ced8a09c190616b5b328bf97bfe5
Author: Jiong Wang <jiong.wang@arm.com>
Date:   Mon Jan 23 09:59:10 2017 +0000

    [ld, testsuite] Honor cflags when GCC used as linker driver
    
    ld/
    	* testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Append
    	board_cflags as gcc is used as linker driver.
    	* testsuite/ld-unique/unique.exp: Likewise

Diff:
---
 ld/ChangeLog                      |  6 ++++++
 ld/testsuite/ld-unique/unique.exp | 11 ++++++++++-
 ld/testsuite/lib/ld-lib.exp       | 13 ++++++++++++-
 3 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/ld/ChangeLog b/ld/ChangeLog
index c710222..3461444 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,9 @@
+2017-01-23  Jiong Wang  <jiong.wang@arm.com>
+
+	* testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Append
+	board_cflags as gcc is used as linker driver.
+	* testsuite/ld-unique/unique.exp: Likewise
+
 2017-01-20  Jiong Wang  <jiong.wang@arm.com>
 
 	* testsuite/ld-aarch64/aarch64-elf.exp (aarch64elflinktests): New tests.
diff --git a/ld/testsuite/ld-unique/unique.exp b/ld/testsuite/ld-unique/unique.exp
index 0aecf01..f06622f 100644
--- a/ld/testsuite/ld-unique/unique.exp
+++ b/ld/testsuite/ld-unique/unique.exp
@@ -108,8 +108,17 @@ if ![ld_compile "$CC -c" "$srcdir/$subdir/unique_empty.s" "tmpdir/unique_empty.o
     set fails [expr $fails + 1]
 }
 
+# When using GCC as the linker driver, we need to specify board cflags when
+# linking because cflags may contain linker options.  For example when linker
+# options are included in GCC spec files then we need the -specs option.
+if [board_info [target_info name] exists cflags] {
+  set board_cflags " [board_info [target_info name] cflags]"
+} else {
+  set board_cflags ""
+}
+
 # Create executable containing unique symbol.
-if ![ld_link $CC "tmpdir/unique_prog" "tmpdir/unique.o"] {
+if ![ld_link "$CC $board_cflags" "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 5ca700b..a44358e 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -1381,6 +1381,17 @@ proc run_ld_link_exec_tests { ldtests args } {
     global CXXFLAGS
     global errcnt
     global exec_output
+    global board_cflags
+
+    # When using GCC as the linker driver, we need to specify board cflags when
+    # linking because cflags may contain linker options.  For example when
+    # linker options are included in GCC spec files then we need the -specs
+    # option.
+    if [board_info [target_info name] exists cflags] {
+        set board_cflags " [board_info [target_info name] cflags]"
+    } else {
+	set board_cflags ""
+    }
 
     foreach testitem $ldtests {
 	foreach target $args {
@@ -1440,7 +1451,7 @@ proc run_ld_link_exec_tests { ldtests args } {
 	    # compile only
 	    pass $testname
 	    continue;
-	} elseif ![$link_proc $link_cmd $binfile "-L$srcdir/$subdir $ld_options $objfiles"] {
+	} elseif ![$link_proc $link_cmd $binfile "$board_cflags -L$srcdir/$subdir $ld_options $objfiles"] {
 	    set failed 1
 	}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]