[cfe-commits] [patch] -MF option is ignored

Dimitry Andric dimitry at andric.com
Sat Sep 15 03:02:09 PDT 2012


As reported in PR 13851, clang (trunk r163208) seems to ignore any -MF
option that is used in combination with -E -M or -E -MM.  For example:

   $ clang -E -MM -MF .depend helloworld.c
   clang: warning: argument unused during compilation: '-MF .depend'

and no dependency file is generated, the dependency information is
dumped to standard output instead.

It does work when also compiling, e.g if -MD or -MMD is used:

   $ clang -MMD -MF .depend -c helloworld.c
   $ cat .depend
   helloworld.o: helloworld.c

Looking at Clang::AddPreprocessingOptions() in lib/Driver/Tools.cpp, it
seems the check for a -MF option is done too late: if dependency output
is requested in any way, the DepFile is always the default filename,
which is standard output if -E is used.

I propose the attached patch to fix this.

-Dimitry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-MF-flag-1.diff
Type: text/x-diff
Size: 931 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120915/f34e57d2/attachment.diff>


More information about the cfe-commits mailing list