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]

Re: ld_compile: force CFLAGS really necessary ?


On Wednesday 29 August 2007, Nick Clifton wrote:
>  > are you referring to this code snippet ?
> >
> >     set ccexe [string replace $ccexe 0 [string last "/" $ccexe] ""]
> >     if {[string match "*gcc*" $ccexe] || [string match "*++*" $ccexe]}
> > then { set flags "$gcc_gas_flag $flags"
> >     }
>
> Yes.  I thought that you could split it up into separate "*gcc*" and "*++*"
> tests and add in the append of CFLAGS or CXXFLAGS to flags as appropriate.

updated version attached

2007-09-01  Mike Frysinger  <vapier@gentoo.org>

	* lib/ld-lib.exp (default_ld_compile): Pull in global CXXFLAGS and
	add it to $flags when $ccexe matches *++*.
	(run_ld_link_exec_tests): Pull in global CXXFLAGS and execute CXX
	with CXXFLAGS when $lang matches c++.
	(run_cc_link_tests): Likewise.
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.

2007-09-01  Mike Frysinger  <vapier@gentoo.org>

	* lib/ld-lib.exp (default_ld_compile): Pull in global CXXFLAGS and
	add it to $flags when $ccexe matches *++*.
	(run_ld_link_exec_tests): Pull in global CXXFLAGS and execute CXX
	with CXXFLAGS when $lang matches c++.
	(run_cc_link_tests): Likewise.

--- ld/testsuite/lib/ld-lib.exp
+++ ld/testsuite/lib/ld-lib.exp
@@ -207,6 +207,7 @@ proc default_ld_simple_link { ld target 
 #
 proc default_ld_compile { cc source object } {
     global CFLAGS
+    global CXXFLAGS
     global srcdir
     global subdir
     global host_triplet
@@ -224,7 +225,7 @@ proc default_ld_compile { cc source obje
     remote_file build delete "$object"
     remote_file host delete "$object"
 
-    set flags "-I$srcdir/$subdir $CFLAGS"
+    set flags "-I$srcdir/$subdir"
 
     # If we are compiling with gcc, we want to add gcc_gas_flag to
     # flags.  Rather than determine this in some complex way, we guess
@@ -242,6 +243,12 @@ proc default_ld_compile { cc source obje
 	set flags "$gcc_gas_flag $flags"
     }
 
+    if {[string match "*++*" $ccexe]} {
+	set flags "$flags $CXXFLAGS"
+    } else {
+	set flags "$flags $CFLAGS"
+    }
+
     if [board_info [target_info name] exists multilib_flags] {
 	append flags " [board_info [target_info name] multilib_flags]"
     }
@@ -1285,6 +1292,7 @@ proc run_ld_link_exec_tests { targets_to
     global CC
     global CXX
     global CFLAGS
+    global CXXFLAGS
     global errcnt
     global exec_output
 
@@ -1319,7 +1327,11 @@ proc run_ld_link_exec_tests { targets_to
 	    # We ignore warnings since some compilers may generate
 	    # incorrect section attributes and the assembler will warn
 	    # them.
-	    ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/$src_file $objfile
+	    if { [ string match "c++" $lang ] } {
+		ld_compile "$CXX -c $CXXFLAGS $cflags" $srcdir/$subdir/$src_file $objfile
+	    } else {
+		ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/$src_file $objfile
+	    }
 
 	    # We have to use $CC to build PIE and shared library.
 	    if { [ string match "c" $lang ] } {
@@ -1411,6 +1423,7 @@ proc run_cc_link_tests { ldtests } {
     global CC
     global CXX
     global CFLAGS
+    global CXXFLAGS
 
     foreach testitem $ldtests {
 	set testname [lindex $testitem 0]
@@ -1432,7 +1445,11 @@ proc run_cc_link_tests { ldtests } {
 	    # We ignore warnings since some compilers may generate
 	    # incorrect section attributes and the assembler will warn
 	    # them.
-	    ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/$src_file $objfile
+	    if { [ string match "c++" $lang ] } {
+		ld_compile "$CXX -c $CXXFLAGS $cflags" $srcdir/$subdir/$src_file $objfile
+	    } else {
+		ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/$src_file $objfile
+	    }
 	}
 
 	# Clear error and warning counts.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]