Closed Bug 967976 Opened 10 years ago Closed 10 years ago

Sometimes building files more than once on mac and linux


(Release Engineering :: General, defect)

Not set


(Not tracked)



(Reporter: glandium, Assigned: glandium)



(1 file)

See, for example this log:

In that particular build, we're building about 1.6 times the number of files a normal clobber build would. Those are mac universal builds, so all files *are* expected to be built twice, but here's what we get (approximates from a raw grep):
- 1184 files are built four times
- 83 files are built six times
- 145 files are built eight times

So far, this seems to be a mac-only problem.
And it's due to CCACHE_BASEDIR. On my tests on birch, here's the kind of thing i was getting:

Rebuilding Compression.o because /builds/slave/m-in-osx64-nonunified-00000000/build/clang/bin/../lib/clang/3.3/include/stddef.       h, /builds/slave/m-in-osx64-nonunified-00000000/build/clang/bin/../lib/clang/3.3/include/stdint.h, /builds/slave/m-in-osx64-no       nunified-00000000/build/clang/bin/../lib/clang/3.3/include/limits.h was removed

Note the m-in-osx64-nonunified-00000000 path, which is different from bir-osx64-00000000000000000000. So what's happening is that thanks to CCACHE_BASEDIR, a compilation on a random branch can get output from a build on another random branch, which, for objects, is mostly fine, but unfortunately, objects are not the only thing the compiler (and ccache) outputs: dependency files are another. Those dependency files contain path to all files included when preprocessing the source, and that includes all system headers, which, in clang tooltool case, points in the source directory. So when the build gets the dependency file from a build from another branch, it gets one that contains paths in that other branch.

On a clobber build, during the compile tier, dependency files are not around (nor object files), so there's no side effect, but when it's time for the libs tier, the dependency files got there from the compile tier, and since they contain broken dependencies, that makes us rebuild those files.

This might be a ccache bug in how it handles dependency files with dependencies under the BASEDIR. Although, it's weird that it only complains about clang system headers and not about other headers that would be under the BASEDIR.

I think the safest thing to do is to stop setting CCACHE_BASEDIR.
Component: Build Config → General Automation
Product: Core → Release Engineering
QA Contact: catlee
Version: Trunk → unspecified
Attachment #8371218 - Flags: review?(catlee)
Assignee: nobody → mh+mozilla
So, what ccache does with BASEDIR is to rewrite flags, not rewrite the dependency file, so any header under the BASEDIR that would be included by some other things than following what's in -I and other explicit flags is likely to have wrong paths when crossing BASEDIR borders. This happens with clang because of those system headers, I'd actually expect that to happen with tooltool gcc as well, and it so appears that tooltool gcc landed after all the builds i've looked at, so it might well be happening on linux now.

There are two possibilities here, either stop setting CCACHE_BASEDIR, like the patch I attached does, or stop putting the tooltool toolchains under the CCACHE_BASEDIR.
Indeed, this is now happening on linux:

136 files built 4 times, 79 built 3 times, 947 built twice.
Summary: Sometimes building files more than once on mac → Sometimes building files more than once on mac and linux
Attachment #8371218 - Flags: review?(catlee) → review+
in production
Closed: 10 years ago
Resolution: --- → FIXED
Component: General Automation → General
You need to log in before you can comment on or make changes to this bug.