Skip to content

Add support for sccache#1475

Open
idealseal wants to merge 1 commit into
gentoo:masterfrom
idealseal:sccache
Open

Add support for sccache#1475
idealseal wants to merge 1 commit into
gentoo:masterfrom
idealseal:sccache

Conversation

@idealseal

@idealseal idealseal commented Sep 19, 2025

Copy link
Copy Markdown

This depends on projg2/shadowman#4 and a patched sccache ebuild.

It works exactly as the ccache implementation.

Docs are still missing. Maybe this can be combined with the ccache instructions?

@eli-schwartz

Copy link
Copy Markdown
Member

Specifically, it depends on projg2/shadowman#4

@idealseal

Copy link
Copy Markdown
Author

I'm thinking about how rust could be integrated: should we export RUSTC_WRAPPER and where would this happen? Should this happen in the eclasses?

@idealseal idealseal force-pushed the sccache branch 2 times, most recently from 4f1042d to 5190029 Compare September 19, 2025 12:48
@thesamesam

Copy link
Copy Markdown
Member

Can you explain what this is useful for, given the build cache issue (it keys on the full path)? Are you really using it with live ebuilds enough for it to pay off?

@idealseal

idealseal commented Sep 19, 2025

Copy link
Copy Markdown
Author

given the build cache issue (it keys on the full path)?

I've not thought about this at all. However I have flang live installed, so yes I could benefit from that.

Also I'd be interested to support rust packages, where I also have a couple of live packages installed. Not that it would matter a lot.

But I can see why this might not be worth the hassle.

@eli-schwartz

Copy link
Copy Markdown
Member

I would personally be less concerned about "how often is it even used, and is it worth the hassle" and be more concerned about the exact opposite problem:

People will use it.

And it will be a bad thing that they use it. They will enable it because they think it sounds like a good thing and then they will suffer a pure loss due to the cache fullpath issue.

I'm strongly against merging sccache support in any form, unless it at least answers the question of how to make sure users have a fighting chance of understanding when it's a good idea vs when it's a bad idea. Mostly indifferent as long as that is handled.

One possibility of the top of my head is to make the FEATURES=sccache be ignored unless PROPERTIES=live is also set?

@mgorny

mgorny commented Sep 19, 2025

Copy link
Copy Markdown
Member

Isn't the path issue specific to Rust?

@idealseal

Copy link
Copy Markdown
Author

No that happens for all supported compilers

@idealseal

Copy link
Copy Markdown
Author

One possibility of the top of my head is to make the FEATURES=sccache be ignored unless PROPERTIES=live is also set?

Might be worth the rename the feature flag as well to avoid confusion from the start

@thesamesam

Copy link
Copy Markdown
Member

mozilla/sccache#35 is now fixed (mozilla/sccache#2521) so I think we can go ahead, but I guess Portage may need to set that env var?

@eli-schwartz

Copy link
Copy Markdown
Member

Oh wow, very neat. We should also do a version check on the sccache binary though.

@idealseal

Copy link
Copy Markdown
Author

Would something like this work?

# lib/portage/package/ebuild/doebuild.py
mysettings["SCCACHE_BASEDIRS"] = mysettings["PORTAGE_BUILDDIR"]

@thesamesam

Copy link
Copy Markdown
Member

I think so..

@thesamesam thesamesam left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the man page(s) too? (Just search for ccache.)

The changes look good to me (not tested yet though). Do I need to do any setup?

@thesamesam

thesamesam commented Feb 11, 2026

Copy link
Copy Markdown
Member

And perhaps explicitly add:

This depends on projg2/shadowman#4 and a patched sccache ebuild.
It works exactly as the ccache implementation.

to the commit message, but say "This needed ..." instead for shadowman, and a link to the commit which updated the sccache ebuild.

@idealseal

Copy link
Copy Markdown
Author

The changes look good to me (not tested yet though). Do I need to do any setup?

Nothing special. It just works

@idealseal

Copy link
Copy Markdown
Author

This still lacks a version check for sccache, and I'm not sure, but the SCCACHE_SERVER_PORT variable is not configurable from the outside. Is that ok?

@idealseal idealseal force-pushed the sccache branch 7 times, most recently from 409b7df to 6a020d5 Compare February 11, 2026 10:03
@idealseal

Copy link
Copy Markdown
Author

Ok, so if you stop the background daemon

SCCACHE_SERVER_PORT=6224 sccache --stop-server

the next emerge process hangs at

>>> Completed (1 of 1) sys-apps/ripgrep-15.1.0::gentoo

 * GNU info directory index is up-to-date.

CTRC+C and re-emerging the package then succeeds.

Unsure why this happens.

Also, the server seems to keep file handles from the previously compiled package open, so if you emerge 2 packages after another, the second compilation fails (similar errors for all crates).

error: could not compile `ryu` (lib)

Caused by:
  process didn't exit successfully: `sccache /home/user/gentoo/usr/lib/rust/1.92.0/bin/rustc --crate-name ryu --edition=2018 /var/tmp/portage/sys-apps/ripgrep-15.1.0/work/cargo_home/gentoo/ryu-1.0.20/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -C debuginfo=1 --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("no-panic", "small"))' -C metadata=6a9926eec05d7ae3 -C extra-filename=-86b59015a8f98680 --out-dir /var/tmp/portage/sys-apps/ripgrep-15.1.0/work/ripgrep-15.1.0/target/release/deps -L dependency=/var/tmp/portage/sys-apps/ripgrep-15.1.0/work/ripgrep-15.1.0/target/release/deps --cap-lints allow -C strip=none -C linker=x86_64-pc-linux-gnu-gcc -C target-feature=-crt-static -C link-arg=-Wl,--as-needed -C link-arg=-Wl,-O2 -C target-cpu=broadwell` (exit status: 254)
sccache: encountered fatal error
sccache: error: Failed to create temp dir
sccache: caused by: Failed to create temp dir
sccache: caused by: No such file or directory (os error 2) at path "/var/tmp/portage/app-benchmarks/hyperfine-1.20.0/temp/sccacheFdhCRd"

This needed projg2/shadowman#4 and sccache
v0.14.0 or later (https://codeberg.org/gentoo/gentoo/commit/ced15048f3ace8ef22c5f2ccfd1a96aecc05f700).

Signed-off-by: idealseal <realidealseal@protonmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants