[ccache] Inline assembly .incbin directive

Joel Rosdahl joel at rosdahl.net
Fri Mar 5 12:49:55 MST 2010


On Tue, 2 Mar 2010 22:21:08 +0000
Stefan Hajnoczi <stefanha at gmail.com> wrote:

> ccache does not detect when the GNU assembler .incbin directive [1] is used
> to include a binary file.
> [...]
> Since this bug breaks the idea that ccache does not affect the semantics of
> the build, only the performance, I feel it makes sense to treat it as a bug
> and fix it.

Ouch, that's a nasty feature from a ccache perspective. To do this right,
ccache would have to parse the preprocessed source code to find __asm__
statements (and if using the direct mode, parse the raw source code, which
means implementing most functionality of a preprocessor) and then parse the
strings in the __asm__ sections. I think this is way beyond what's reasonable
for ccache to do, unfortunately. Another way of detecting it would be to use
strace or LD_PRELOAD tricks to find out which files are read by the compiler,
but then ccache would be a very different program.

The only reasonable way I see to tackle this is to avoid caching any source
code that has a string literal containing ".incbin". It would be easy to fool,
and there will be a few false positives, but maybe it's good enough. On the
other hand, I guess a very tiny part of ccache's users compile things with
".incbin". Do you think it's worth the effort to try to detect this or is it
enough to just document it as limitation?

(It would be easy to make a slightly better work-around available than setting
CCACHE_DISABLE, though: Introduce a CCACHE_EXTRA_FILES_TO_HASH variable
containing paths to files whose content ccache should include in the hash.)

-- Joel


More information about the ccache mailing list