[PATCH:macros] XORG_TESTSET_CFLAG: Try to both compile & link with the flags

Alan Coopersmith alan.coopersmith at oracle.com
Thu Dec 1 14:52:25 PST 2011


On 12/01/11 14:18, Gaetan Nadon wrote:
> On Linux the same "gcc" command is issued which is expected.
> It wouldn't hurt the name some of compilers/linkers combination that are
> inconsistent in the treatment of unknown flags.

On most systems the same compiler is called to link, but for linking it runs
ld, gld, or gold under the hood, with various arguments & input files added to
the command, and the compiler options it recognizes either translated to
appropriate linker flags (like -m64) or omitted because it knows the
linker doesn't need those details (like warning flags for C syntax).

I actually hit this problem on Solaris, using the wrapper around either
gcc or clang that our parfait static analyzer uses, which is based on
older gcc versions that don't yet support all the -W flags, so attempts
to fallback to the Studio cc -err flags, which it thinks might be linker
flags and fails:

configure:13491: checking if parfait-gcc -std=gnu99 supports -Werror=implicit
configure:13497: parfait-gcc -std=gnu99 -c  -g -O2 -m64 -Werror=implicit [...]
cc1: error: unrecognized command line option "-Werror=implicit"
parfait-gcc: error: Error executing `/usr/sfw/bin/gcc "-std=gnu99" -c -g -O2 
-m64 "-Werror=implicit" [...] conftest.c`. Native gcc tool gave non-zero result 1.
configure:13497: $? = 1
configure:13503: result: no

configure:13524: checking if parfait-gcc -std=gnu99 supports 
-errwarn=E_NO_EXPLICIT_TYPE_GIVEN -errwarn=E_NO_IMPLICIT_DECL_ALLOWED
configure:13530: parfait-gcc -std=gnu99 -c  -g -O2 -m64 
-errwarn=E_NO_EXPLICIT_TYPE_GIVEN -errwarn=E_NO_IMPLICIT_DECL_ALLOWED [...]
clang: warning: argument unused during compilation: '-e 
rrwarn=E_NO_EXPLICIT_TYPE_GIVEN'
clang: warning: argument unused during compilation: '-e 
rrwarn=E_NO_IMPLICIT_DECL_ALLOWED'
configure:13530: $? = 0
configure:13536: result: yes

so it passes configure when it doesn't try linking, then fails when linking:

parfait-gcc -std=gnu99 -Wall -Wpointer-arith -Wstrict-prototypes 
-Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wbad-function-cast 
-Wformat=2 -Wold-style-definition -Wdeclaration-after-statement -Wunused 
-Wuninitialized -Wshadow -Wcast-qual -Wmissing-noreturn 
-Wmissing-format-attribute -Wredundant-decls -Winline 
-errwarn=E_NO_EXPLICIT_TYPE_GIVEN -errwarn=E_NO_IMPLICIT_DECL_ALLOWED 
-errwarn=E_FUNC_HAS_NO_RETURN_STMT -errwarn=E_BAD_PTR_INT_COMBINATION 
-fno-strict-aliasing -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS 
-I/usr/X11R7/include   -g -O2 -m64  -Wl,-B,direct 
-Wl,-M,/usr/lib/ld/map.pagealign -z guidance -o xinit xinit.o -lX11
ld: warning: entry point option (-e, --entry) appears more than once, first 
setting taken
ld: warning: entry point option (-e, --entry) appears more than once, first 
setting taken
ld: warning: entry point option (-e, --entry) appears more than once, first 
setting taken
ld: fatal: entry point symbol 'rrwarn=E_NO_EXPLICIT_TYPE_GIVEN' is undefined
collect2: ld returned 1 exit status
gmake[2]: *** [xinit] Error 1


(No problems with the gcc 4.5 I normally use for testing gcc builds on
  Solaris, since all the flags with Sun cc -err fallbacks are already
  supported in that release.)

-- 
	-Alan Coopersmith-        alan.coopersmith at oracle.com
	 Oracle Solaris Platform Engineering: X Window System



More information about the xorg-devel mailing list