[cfe-dev] ccache and 'unused argument' warning

Jakob Stoklund Olesen stoklund at 2pi.dk
Sat Jun 19 10:53:16 PDT 2010


On Jun 18, 2010, at 10:30 PM, Chris Lattner wrote:

> A user who uses ccache reported that it is apparently doing something that causes it to emit tons of "argument unused during compilation warnings".  A typical invocation is something like this:
> 
> ccache clang++ -m32 -mmmx -msse  -pipe -march=pentium-m -I/usr/include/malloc -fasm-blocks -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -Wno-invalid-offsetof -Wno-unknown-pragmas -Wno-unused-parameter -Wno-reorder -Wno-unused-value -Wno-missing-field-initializers -Wno-sign-compare -Wno-invalid-offsetof -Wno-write-strings -gdwarf-2 -g2 -O3 -fno-strict-aliasing -DNDEBUG -DGNUC -DPOSIX -D_OSX -DOSX -Ifoo -c foo.cpp -o foo.o 
> 
> which produces warnings like this:
> clang: warning: argument unused during compilation: '-c'
> clang: warning: argument unused during compilation: '-I/usr/include/malloc'
> clang: warning: argument unused during compilation: '-isysroot /Developer/SDKs/MacOSX10.5.sdk'
> clang: warning: argument unused during compilation: '-DNDEBUG'
> clang: warning: argument unused during compilation: '-DGNUC'
> clang: warning: argument unused during compilation: '-DPOSIX'
> clang: warning: argument unused during compilation: '-D_OSX'
> clang: warning: argument unused during compilation: '-DOSX'
> clang: warning: argument unused during compilation: '-Ifoo'
> 
> etc.  This is apparently local to something that ccache is doing: it must be running clang multiple times, one with some funny options.  The user was alarmed because he didn't think that clang had implemented such exotic options as -D and -I :) due to these warnings.
> 
> The question is: is this a ccache bug, or should we hack clang somehow to work better with ccache?  I don't use ccache or know anything about it, so I don't really have an opinion here.

ccache runs the compiler twice: First with -E to create a preprocessed file, second it compiles the preprocessed file if it doesn't have a matching object file in its cache.

On the first run, '-c' is unused because -E was added.
On the second run, '-I', '-D', and '-isysroot' are ignored because the preprocessor isn't run.

I am guessing that ccache doesn't know what clang is, so it doesn't remove any options, just to be sure.

/jakob





More information about the cfe-dev mailing list