[PATCH] Support using -flto with libstdc++ testsuite

Jonathan Wakely jwakely@redhat.com
Tue Aug 2 09:40:00 GMT 2016


Richi noticed that using -flto in the testsuite fails badly. It turns
out to be because the support files in libtestc++.a get built with
-flto, but then ar and ranlib don't know what to do with those LTO
objects.

We investigated how to pass the LTO plugin to ar and ranlib but the
simplest solution is to not use LTO for libtestc++.a, as done by this
patch.

	* testsuite/lib/libstdc++.exp (v3-build_support): Add -fno-lto to
	additional flags for compiling libtestc++.a objects.

Tested x86_64-linux, committing to trunk, gcc-6-branch, and gcc-5-branch.


-------------- next part --------------
commit d298b5cab027fc70694ef843bb7cd5a753c8ffa3
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Aug 2 10:33:55 2016 +0100

    Support using -flto with libstdc++ testsuite
    
    	* testsuite/lib/libstdc++.exp (v3-build_support): Add -fno-lto to
    	additional flags for compiling libtestc++.a objects.

diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 7bf91f3..e2afbe5 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -636,8 +636,9 @@ proc v3-build_support { } {
 	set object_file [file tail $obj]
 	# Compile with "-w" so that warnings issued by the compiler
 	# do not prevent compilation.
+        # Disable LTO so that ar/ranlib don't need the LTO plugin.
 	if { [v3_target_compile $srcdir/util/$f $object_file "object" \
-		  [list "incdir=$srcdir" "additional_flags=-w"]]
+		  [list "incdir=$srcdir" "additional_flags=-w -fno-lto"]]
 	     != "" } {
 	    error "could not compile $f"
 	}


More information about the Gcc-patches mailing list