Skip to main content

configure_compilation_cache

Function configure_compilation_cache 

Source
pub fn configure_compilation_cache(
    command: &mut Command,
    sccache_path: &Path,
) -> Result<()>
Expand description

Route a Cargo invocation’s compiles through sccache.

Caching only bites because generated-crate builds also disable incremental compilation — Cargo does not pass -C incremental to registry dependencies but does pass it to every path dependency, which for a WaterUI build is the entire framework, and sccache refuses to cache an incremental compile. That setting lives in crate::build::configure_generated_crate_compilation rather than here, because it must not depend on whether a machine happens to have sccache installed: it changes the compiled ABI, and two builds in one flow have to agree on it.

The server address is namespaced to the invoking user. sccache discovers its server on a host-wide address — TCP 127.0.0.1:4226 unless told otherwise — and every compile job runs inside the server process under the server owner’s identity. Left at the default, a build running as one user borrows a server another user left alive and its artifacts land in this user’s target dir owned by the other uid, ending the build on Permission denied. A unix socket under the user’s own Water home gives each account its own server with no port to collide over, and sccache ≥ 0.9.0 prefers it when both are set; the port is still set unconditionally because older builds ignore the socket variable entirely and would fall back to the shared default address.

§Errors

Returns an error when the socket directory under the user’s Water home cannot be created or exists with permissions wider than 0700.