cgcc does not preprocess arbitrary files when -E is used

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I was trying to build dash[1] with cgcc and the compilation failed:

$ git clone git://git.kernel.org/pub/scm/utils/dash/dash.git
$ cd dash/
$ ./autogen
$ CC=cgcc ./configure && make

This was because an auto-generated file was not created.

dash preprocesses a file using gcc[2, line 50] like that:

builtins.def: builtins.def.in $(top_builddir)/config.h
	$(COMPILE) -E -x c -o $@ $<

however preprocessing files which does not have a .c extension seems to
be unsupported with cgcc.

A minimal test example, 'test.c.in':

-----------------------------------------------------------------------
#ifdef HAVE_SOMETHING
something
#endif
-----------------------------------------------------------------------

As said, running cgcc -E does not preprocess the file when passed as an
argument because it does not end with a .c extension:

$ cgcc -DHAVE_SOMETHING -E -x c test.c.in
$

Moreover gcc options which have arguments, like "-x <language>" or "-o
<file>", seem to be unsupported by sparse:

$ cgcc -DHAVE_SOMETHING -E -x c - < test.c.in 

No such file: c
$

Looking at the cgcc code I see that -E disables $do_compile, and in my
case $do_check is disabled too because the input file does not end with
'.c'.

Maybe when -E is passed $do_check should be disabled (don't run sparse
if only preprocessing was requested) and $do_compile unconditionally
enabled?

The issue could be easily fixed in dash by using something like:

$ cgcc -DHAVE_SOMETHING -E - < test.c.in > test.c

or by calling $(CPP) directly instead of $(COMPILER), however other
projects may run into similar issues so maybe fixing cgcc to look
a little more like gcc when -E is passed would be better.

Thank you,
   Antonio

[1] http://gondor.apana.org.au/~herbert/dash/
[2] https://git.kernel.org/pub/scm/utils/dash/dash.git/tree/src/Makefile.am?id=9000b48966335b0b3d7a3ec1ec8c15b045d59e9d#n50

-- 
Antonio Ospite
https://ao2.it
https://twitter.com/ao2it

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux