ld_compile: force CFLAGS really necessary ?

Mike Frysinger vapier@gentoo.org
Wed Aug 29 08:19:00 GMT 2007


On Tuesday 28 August 2007, Mike Frysinger wrote:
> i fetched binutils-2.18 and ran it through some `make check` only to find
> ld oddly failling some tests on me ... after digging through it a bit, it
> seems it's due to mixing of CFLAGS and CXXFLAGS.
>
> on my system, i throw -Wimplicit-function-declaration into my CFLAGS which
> does two things: (1) shows me implicit functions so i can send patches to
> fix code and (2) see when packages wrongly mix CFLAGS and CXXFLAGS.
>
> in ld/testsuite/lib/ld-lib.exp, the ld_compile function will append $CFLAGS
> to all commands given it.  this means even tests like ld-cdtest which
> compiles C++ code and which will cause erroneous failures when CFLAGS
> contains things that are not valid in CXXFLAGS.  doing a quick grep against
> ld_compile, i see CFLAGS is explicitly specified in the call to ld_compile
> by over half the tests which use this function ... and on my system, simply
> removing the CFLAGS append inside of the ld_compile function doesnt cause
> any regressions.
>
> so the question is, do we drop this auto CFLAGS append completely ?  or do
> we do a check against the suffix of $source and if it is set to .cc, auto
> append CXXFLAGS rather than CFLAGS ?

maybe something like the attached patch

2007-08-28  Mike Frysinger  <vapier@gentoo.org>

	* lib/ld-lib.exp (default_ld_compile): Pull in global CXXFLAGS and
	add it to $flags when $source matches *.cc.
	(run_ld_link_exec_tests): Pull in global CXXFLAGS and execute CXX
	with CXXFLAGS when $lang matches c++.
	(run_cc_link_tests): Likewise.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 827 bytes
Desc: This is a digitally signed message part.
URL: <https://sourceware.org/pipermail/binutils/attachments/20070829/b164e445/attachment.sig>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: binutils-ld-tests-CXX.patch
Type: text/x-diff
Size: 2335 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20070829/b164e445/attachment.bin>


More information about the Binutils mailing list