public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jiong Wang <jiong.wang@foss.arm.com>
Cc: Binutils <binutils@sourceware.org>
Subject: [Patch] Honor ccflags when GCC used as linker driver
Date: Fri, 20 Jan 2017 16:17:00 -0000	[thread overview]
Message-ID: <f863e40d-153d-ac40-093f-a559e682f2e9@foss.arm.com> (raw)
In-Reply-To: <20170120003318.GW32333@bubble.grove.modra.org>

[-- Attachment #1: Type: text/plain, Size: 768 bytes --]

There are a few more failures happen on AArch64 bare-metal recently as we
have enabled more elf tests.

As run_ld_link_exec_tests now always use gcc as linker driver, I think 
it should
start to specify all ccflags as well as ccflags may contain linker 
options for
example spec file.  There was similar fix before

   https://sourceware.org/ml/binutils/2014-10/msg00184.html

Meanwhile one unique test need to do the same thing.

This patch fixed quite a few failures on aarch64 bare-metal linker 
testing, no
regression.

OK for master?

2017-01-20  Jiong Wang  <jiong.wang@arm.com>

         * ld/testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Append
         board_cflags as gcc is used as linker driver.
         * ld/testsuite/ld-unique/unique.exp: Likewise

[-- Attachment #2: k.patch --]
[-- Type: text/x-diff, Size: 2129 bytes --]

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
 	}
 

  reply	other threads:[~2017-01-20 16:17 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-02 13:35 Run more ld tests when not native Alan Modra
2017-01-02 16:05 ` Christophe Lyon
2017-01-03  0:29   ` Alan Modra
2017-01-03  2:36     ` Alan Modra
2017-01-11 19:22     ` Maciej W. Rozycki
2017-01-20  0:33       ` Alan Modra
2017-01-20 16:17         ` Jiong Wang [this message]
2017-01-22 21:18           ` [Patch] Honor ccflags when GCC used as linker driver Alan Modra
2017-01-23 13:51             ` [ld, testsuite] Always assemble those intermeidate .o files used later Jiong Wang
2017-01-23 13:59               ` Christophe Lyon
2017-01-23 14:27                 ` Jiong Wang
2017-01-23 14:29                   ` Christophe Lyon
2017-01-24  0:44               ` Alan Modra
2017-01-31 12:51           ` [ld, testsuite, obvious] Append $board_cflags in one more place in ld-unique/unique.exp Jiong Wang
2017-01-03 21:16 ` Run more ld tests when not native Dimitar Dimitrov
2017-01-03 23:06   ` Alan Modra
2017-01-10 19:01 ` H.J. Lu
2017-01-10 21:50   ` Alan Modra
2017-01-10 22:06     ` H.J. Lu
2017-01-11  0:56       ` Alan Modra
2017-01-11 18:40         ` H.J. Lu
2019-02-14 16:53 ` Thomas Schwinge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f863e40d-153d-ac40-093f-a559e682f2e9@foss.arm.com \
    --to=jiong.wang@foss.arm.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).