NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.68k stars 13.12k forks source link

New reproducibility NIX_CFLAGS_COMPILE breaks ccache caching #109033

Open Kha opened 3 years ago

Kha commented 3 years ago

Describe the bug After https://github.com/NixOS/nixpkgs/pull/102251, a new -frandom-seed C compiler flag is inserted with a value that changes whenever the derivation hash has changed. This will change the ccache cmdline hash, completely defeating any use of ccacheWrapper etc.

Additional context Arguably, ccache should probably ignore frandom-seed since caching modulo that value is no worse than caching a cmdline that did not contain the flag in the first place, which effectively sets it to a random value. But it would be great to be able to at least opt out of the new behavior until this is "fixed" upstream (if accepted at all).

Notify maintainers @andir

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module: programs.ccache
tomberek commented 3 years ago

The solution referenced by the lean4 package works to trim out the -frandom-seed.

stale[bot] commented 2 years ago

I marked this as stale due to inactivity. → More info

Atemu commented 1 year ago

Upstream has added support for the flag. https://github.com/ccache/ccache/pull/1168

You need explicitly enable it via sloppiness = random_seed in the ccache config file though.

Given that we enable it for all packages by default, perhaps ccacheStdenv should enable it by default too.

timgott commented 1 year ago

You can also enable that flag with an environment variable similar to how you set CCACHE_DIR according to https://nixos.wiki/wiki/CCache, by adding

export CCACHE_SLOPPINESS=random_seed

in extraConfig

nixos-discourse commented 3 months ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/bisect-linux-kernel-without-recompiling-every-time/42633/3

nixos-discourse commented 1 month ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/really-low-ccache-hit-rates-when-overriding-a-package/47421/4