Open Bug 1509961 Opened 3 years ago Updated 2 months ago

Enable sccache by default when available

Categories

(Firefox Build System :: General, enhancement, P3)

enhancement

Tracking

(Not tracked)

People

(Reporter: gps, Unassigned)

References

Details

(Keywords: in-triage)

Not having sccache enabled by default can result in very slow builds, especially for Rust. It is a poor default user experience.

This bug tracks changing the build system so sccache is enabled and required by default and requires an explicit --disable* flag to opt in to a less optimal experience.

Is there a good reason why we shouldn't do this today? Do we need granular control for compiler cache? e.g. ability to trigger compiler cache independently for C/C++/Rust?
In scenarios where you don't build the same code often, sccache/ccache is a net loss. I wouldn't force it down people's throat.

Also, clearly, this shouldn't be the default for --enable-release builds.
Yes, if you are changing a lot of "costly" code (files that invalidate many downstream build targets), sccache can be a net loss.

But I /think/ this only applies to Gecko C++? My intuition is that sccache with Rust (and possibly C) would be a net win, as I don't perceive we have the same problem of large code invalidation with those sources. What do you think?

Also, we have build system telemetry now. So this might be a good change to validate with telemetry!
We probably don't have independent build times for C++/Rust/other. We may want to get telemetry on that...
See Also: → 1373460
Keywords: in-triage

Per conversation with :kmoir, I'm going through untriaged bugs in her components and marking the ones which look to be enhancements/tasks with the enhancement severity to get them out of the triage queue.

If this incorrect, please remove the tag.

Severity: normal → enhancement

I think requiring sccache is a harder sell, but enabling it by default when it's available should be reasonable and developers could still use --without-ccache to disable it. If we install sccache from bootstrap (bug 1499145) then the default state for most developers should be that they'll wind up using the toolchain sccache that we installed and life will be good.

See Also: → 1499145
Summary: Enable and require sccache by default → Enable sccache by default when available

Note that it won't do anything for people who do use ccache, which is kind of sad. However, considering ccache is faster than sccache for C++, it's a hard sell for pick sccache in that case. Plus, it would be a first where we wouldn't actually apply some explicit option, and that would not be great. A reasonable option here would be to add a separate flag for "rust-caching", which would itself default to sccache if available.

FWIW I would love to be able to cache only Rust compilation and not C++. (I often test C++ compiler changes where everything would just end up as a cache miss, but I pretty much never touch Rust sources.)

Priority: -- → P2

(In reply to David Major [:dmajor] from comment #7)

FWIW I would love to be able to cache only Rust compilation and not C++. (I often test C++ compiler changes where everything would just end up as a cache miss, but I pretty much never touch Rust sources.)

I'm under the impression that export RUSTC_WRAPPER=sccache does this.

(In reply to Myk Melez [:myk] [@mykmelez] from comment #8)

(In reply to David Major [:dmajor] from comment #7)

FWIW I would love to be able to cache only Rust compilation and not C++. (I often test C++ compiler changes where everything would just end up as a cache miss, but I pretty much never touch Rust sources.)

I'm under the impression that export RUSTC_WRAPPER=sccache does this.

This doesn't appear to have any effect on my build.

(In reply to David Major [:dmajor] from comment #9)

(In reply to Myk Melez [:myk] [@mykmelez] from comment #8)

I'm under the impression that export RUSTC_WRAPPER=sccache does this.

This doesn't appear to have any effect on my build.

Hmm, indeed. According to this dev.platform thread, mk_add_options "export RUSTC_WRAPPER=sccache" is supposed to work (but doesn't); however putting export RUSTC_WRAPPER=sccache into your shell's profile startup file does work. I've just confirmed that by adding it to ~/.profile (on macOS), building, clobbering, building again, and checking the cache stats via sccache -s.

Priority: P2 → P3
You need to log in before you can comment on or make changes to this bug.