# ccache breaks buildworld at "i386-elf" - use CCACHE_CPP2



## Beeblebrox (Jun 7, 2011)

I have decided to largely modify the content of my post because the issue seems much clearer now than when I originally posted.

The task of using *ccache* for *buildworld* seems to have several strange problems associated with it.  These are:

1. Suggested settings for make.conf do not work and *ccache* does not kick in when making *buildworld*.  After I commented out the "*if*" statement *ccache* participated in the *buildworld*.

```
[SIZE="3"].if (!empty(.CURDIR:M/usr/src*) || !empty(.CURDIR:M/usr/obj*)) && !defined(NOCCACHE)[/SIZE]
CC=  /usr/local/libexec/ccache/world/cc
CXX= /usr/local/libexec/ccache/world/c++
.endif
```

2. For amd64 systems, the i386-elf build seems to consistently break - posts about this issue exist for FreeBSD branch 8x also.  Mostly suspected is a "compiler problem since it can't compile its own preprocessed output. A workaround for that is to set CCACHE_CPP2" (good example of the issue here).

3. Problem #2 did not clear up when I cleaned out the cache and updated devel/libtool. World builds fine without *ccache* and ommission or inclusion of * -j *option makes no difference.

4. I tried running *ccache* with CCACHE_CPP2 option for i386-elf only by placing in make.conf:

```
.if ${.CURDIR:M*/src/lib/csu/i386-elf}
CCACHE_CPP2= yes
.endif
```
But this did not work. Probably once build starts, it does not re-consult make.conf for every depend so this setting was by-passed.  Question:  What is the command to start the build with CCACHE_CPP2 option for i386-elf only? How would I then integrate this into the *buildworld*? (*buildworld* must skip over this already compiled depend).  My solution would be to edit i386-elf's Makefile and place the option there.  Suggestions?

An alternatively acceptable solution here would be to build i386-elf without *ccache* (by-pass *ccache* for this module). Where & how could I specify that (still calls *ccache* if I just place in the i386-elf/Makefile

```
NOCCACHE= yes
```

5. I think I should clear out all code already cached in *ccache* relating to i386-elf.  Question: What would be the command for clearing that portion out only? Or is it risky and should I just start over completely?

UPDATE:  I disabled *ccache* in make.conf and I ran *make* in /usr/src/lib/csu/i386-elf. It stopped with same error.  I then deleted obj/src and started the build with disabled   *ccache* to make sure - clean build.  My conclusion therefore is that i386-elf with *ccache* breaks, not because of the conditions in i386-elf but because of code placed in *ccache* from previous modules being called for the build of i386-elf.  The solution could be to not compile anything with *ccache* regarding 32bit src compatibility.  Great - what happens when I try to cross-compile for an i386 machine (which I plan to do).
New Thought: Could a Custom Kernel cause this? Compat 32 is enabled (obviously).


----------

