Re: [ccache] Inline assembly .incbin directive

2010-03-05 Thread Joel Rosdahl
On Tue, 2 Mar 2010 22:21:08 +
Stefan Hajnoczi stefa...@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
___
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache


[ccache] Inline assembly .incbin directive

2010-03-02 Thread Stefan Hajnoczi
ccache does not detect when the GNU assembler .incbin directive [1] is
used to include a binary file.

If the contents of the referenced binary file have changed, ccache
gets a false cache hit.  The C source file hasn't changed - it still
has an .incbin directive referencing the same filename but the binary
file has changed.  The result is a stale cached object file.

Several projects carry Makefile workarounds for this.  I am now
introducing a workaround in gPXE [2].

It would be nice to see ccache detect .incbin directives.  The
conservative approach would be to simply detect .incbin and refuse to
cache the file.  A more aggressive approach would include the binary
file in its cache hit decision.

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.

Thoughts?  I can supply a test case if that helps.

Stefan

[1] http://sourceware.org/binutils/docs/as/Incbin.html#Incbin
[2] 
http://git.etherboot.org/?p=people/stefanha/gpxe.git;a=commitdiff;h=c70f00cc6df4b7d6ab05928fa0f6e87eb4527df1
___
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache