[PATCH] Fix ld-cdtest if CFLAGS contains -fexceptions (take 2)

Jakub Jelinek jakub@redhat.com
Tue Aug 16 12:25:00 GMT 2005


On Fri, Jul 29, 2005 at 03:49:04PM +0100, Nick Clifton wrote:
> >We compile most of the packages with -fexceptions these days,
> >but this breaks ld-cdtest.  Although it adds -fno-exceptions to cc
> >in ld_compile, ld_compile then appends $CFLAGS and therefore -fexceptions
> >comes after -fno-exceptions and wins.
> >The following patch fixes that by adding full path of libsupc++.a to the
> >command line if it exists.
> 
> Surely this is the wrong solution.  Surely ld_compile ought to prepend 
> $CFLAGS rather than append it, so that the individual linker tests can 
> override command line switches like -fexceptions.
> 
> ie if the cdtest.exp wants to use -fno-exceptions then it should be 
> allowed to and we should not be trying to work around this by restoring 
> the exception handling library to the linker command line.

Is the following better?

Alternatively, we could add a separate argument to ld_compile (guess
in between cc and source) that would contain the flags, so callers could
decide which options they want to prepend to $CFLAGS and which to append.

2005-08-16  Jakub Jelinek  <jakub@redhat.com>

	* lib/ld-lib.exp (default_ld_compile): Append $cc arguments after
	$CFLAGS instead of prepending them.

--- ld/testsuite/lib/ld-lib.exp.jj	2005-08-16 11:21:50.000000000 +0200
+++ ld/testsuite/lib/ld-lib.exp	2005-08-16 14:18:11.000000000 +0200
@@ -226,8 +226,11 @@ proc default_ld_compile { cc source obje
     # based on the name of the compiler.
     set ccexe $cc
     set ccparm [string first " " $cc]
+    set ccflags ""
     if { $ccparm > 0 } then {
+	set ccflags [string range $cc $ccparm end]
 	set ccexe [string range $cc 0 $ccparm]
+	set cc $ccexe
     }
     set ccexe [string replace $ccexe 0 [string last "/" $ccexe] ""]
     if {[string match "*gcc*" $ccexe] || [string match "*++*" $ccexe]} then {
@@ -238,9 +241,9 @@ proc default_ld_compile { cc source obje
 	append flags " [board_info [target_info name] multilib_flags]"
     }
 
-    verbose -log "$cc $flags -c $source -o $object"
+    verbose -log "$cc $flags $ccflags -c $source -o $object"
 
-    catch "exec $cc $flags -c $source -o $object" exec_output
+    catch "exec $cc $flags $ccflags -c $source -o $object" exec_output
     set exec_output [prune_warnings $exec_output]
     if [string match "" $exec_output] then {
 	if {![file exists $object]} then {


	Jakub



More information about the Binutils mailing list