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

Bug#499251: gcc -MMD erroneously regards missing #includes as only warnings



Package: cpp-4.1
Version: 4.1.1-21

mariner:~/junk> cat t.c
#include <nonexistent.h>
int x;
mariner:~/junk> gcc-4.1 -c -MD t.c && echo hi
t.c:1:25: error: nonexistent.h: No such file or directory
mariner:~/junk> gcc-4.1 -c -MMD t.c && echo hi
t.c:1:25: warning: nonexistent.h: No such file or directory
hi
mariner:~/junk>

There is probably confusion because gcc -M needs to regard missing
#includes as only warnings because otherwise in systems with a
separate dependency generation step that step can fail if the .c files
include .h's which are autogenerated.

However when we're actually compiling, with dependency generation
being a side effect (-MD and -MMD), missing headers need to be
reported as actual errors, just as they would be if -MMD wasn't
specified - ie, just as if the dependency generation side effect was
not requested.

As you can see -MD works correctly. The documentation for -MMD says
     Like `-MD' except mention only user header files, not system
     header files.
so I think it's just an oversight that the fix for the -MD special
case is not applied to -MMD.


This bug existed at least as early as etch's gcc-3.4 (in cpp-3.4
3.4.6-5) and also affects lenny's gcc-4.2 (in cpp-4.2 4.2.4-1).
At least some old GCC versions supporting -MMD do not have the bug but
I haven't investigated in detail which ones and I don't know whether
that's true of any Debian GCCs.


I would strongly suggest that this bug NOT be fixed in lenny.
It will almost certainly reveal latent but harmless build system bugs
in existing packages and cause disruption.

It is of course a shame not to fix it straight away - and it's a
pretty surprising bug - but it has remained like this for some years
now and I think the collateral damage inflicted (including delays to
the lenny release) would outweigh the benefits.

Ian.



Reply to: