diff mbox

[testsuite] Improve LTO testing with -r

Message ID 4CB332FC.5060706@codesourcery.com
State New
Headers show

Commit Message

Jie Zhang Oct. 11, 2010, 3:53 p.m. UTC
Some LTO tests do relocatable linking. Some target boards set a linker 
script which can't be used for relocatable linking. This patch changes 
lto.exp to use the default linker script instead if -r is found in the 
options.

make check RUNTESTFLAGS="lto.exp"

has no regressions on x86_64-unknown-linux-gnu with this patch.

Is it OK?


Regards,

Comments

Mark Mitchell Oct. 11, 2010, 3:56 p.m. UTC | #1
On 10/11/2010 8:53 AM, Jie Zhang wrote:
> Some LTO tests do relocatable linking. Some target boards set a linker
> script which can't be used for relocatable linking. This patch changes
> lto.exp to use the default linker script instead if -r is found in the
> options.

> Is it OK?

I think this patch makes sense.  Ideally, there would be more structure
here, in that tests that use "-r" would set some kind of "relocatable"
flag, which would cause DejaGNU to (a) insert -r, and (b) not use the
default linker script.  But, I don't see how to make that plumbing
practical, at least not without changing all the *_target_compile functions.

OK if no objections within 48 hours.

Thank you,
Jie Zhang Oct. 15, 2010, 6:54 a.m. UTC | #2
On 10/11/2010 11:56 PM, Mark Mitchell wrote:
> On 10/11/2010 8:53 AM, Jie Zhang wrote:
>> Some LTO tests do relocatable linking. Some target boards set a linker
>> script which can't be used for relocatable linking. This patch changes
>> lto.exp to use the default linker script instead if -r is found in the
>> options.
>
>> Is it OK?
>
> I think this patch makes sense.  Ideally, there would be more structure
> here, in that tests that use "-r" would set some kind of "relocatable"
> flag, which would cause DejaGNU to (a) insert -r, and (b) not use the
> default linker script.  But, I don't see how to make that plumbing
> practical, at least not without changing all the *_target_compile functions.
>
> OK if no objections within 48 hours.
>
Committed on trunk now. Thanks!
diff mbox

Patch


	* lib/lto.exp (lto-link-and-maybe-run): Use the default linker
	script when relocatable linking.

Index: lib/lto.exp
===================================================================
--- lib/lto.exp	(revision 165315)
+++ lib/lto.exp	(working copy)
@@ -163,6 +163,7 @@  proc lto-link-and-maybe-run { testname o
     global testcase
     global tool
     global compile_type
+    global board_info
 
     # Check that all of the objects were built successfully.
     foreach obj [split $objlist] {
@@ -177,10 +178,29 @@  proc lto-link-and-maybe-run { testname o
     set options ""
     lappend options "additional_flags=$optall $optfile"
 
+    set target_board [target_info name]
+    set relocatable 0
+
+    # Some LTO tests do relocatable linking. Some target boards set
+    # a linker script which can't be used for relocatable linking.
+    # Use the default linker script instead.
+    if { [lsearch -exact [split "$optall $optfile"] "-r"] >= 0 } {
+	set relocatable 1
+    }
+
+    if { $relocatable } {
+	set saved_ldscript [board_info $target_board ldscript]
+	set board_info($target_board,ldscript) ""
+    }
+
     # Link the objects into an executable.
     set comp_output [${tool}_target_compile "$objlist" $dest executable \
 		     "$options"]
 
+    if { $relocatable } {
+	set board_info($target_board,ldscript) $saved_ldscript
+    }
+
     # Prune unimportant visibility warnings before checking output.
     set comp_output [lto_prune_warns $comp_output]