This is the mail archive of the binutils@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]

[Patch] Honor ccflags when GCC used as linker driver


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
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]