http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48083
Summary: DEPENDENCIES_OUTPUT + -no-integrated-cpp produces bad dependencies Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: c...@google.com gcc version 4.6.0 20110311 (experimental) (GCC), but I reproduced this all the way back to 4.2.x. $ : > null.c # Hey, we have an empty file! $ DEPENDENCIES_OUTPUT=/dev/stdout ./gcc -c null.c null.o: null.c # Yeah! Those are my deps all right! $ DEPENDENCIES_OUTPUT=/dev/stdout ./gcc -c null.c -no-integrated-cpp null.o: null.c cccUba7s.o: /tmp/cccUba7s.i # Huh?!?! WHAT?!?!?! also happens with -save-temps or -traditional-cpp instead of -no-integrated-cpp. also happens with SUNPRO_DEPENDENCIES instead of DEPENDENCIES_OUTPUT. what's happening is that -no-integrate-cpp causes cc1 to be invoked twice: once with the original source file, and once with the .i file output by the first invocation. While the second invocation would have such as -MMD stripped, it still have has the DEPENDENCIES_OUTPUT or SUNPRO_DEPENDENCIES variables set in its environment. there's a horrible kludge that can be used to make this work as expected (strategically insert -MF/dev/null into the second cc1 invocations in default_compilers), that would be Wrong. Probably a better solution would be to add a new internal option, to indicate that the 'stage' of the compilation, and then use that to avoid processing the env vars. (I would suggest a new -M option to cancel dependency generation, and then pass that internally ... but i think that could be really confusing because of the way gcc handles (or doesn't handle) relative parameter position.)