From: Joel Rosdahl Date: Tue, 4 Oct 2022 19:31:12 +0000 (+0200) Subject: feat: Improve handling of -frandom-seed and description of sloppiness X-Git-Tag: v4.7~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d097f32f671b07dccb1b36ebe0fcc4c435211508;p=thirdparty%2Fccache.git feat: Improve handling of -frandom-seed and description of sloppiness I should not be necessary to distinguish between existence and non-existence of -frandom-seed if random_seed sloppiness is requested, so don't hash the "-frandom-seed=" part either. --- diff --git a/doc/MANUAL.adoc b/doc/MANUAL.adoc index d979818e0..fd67d1693 100644 --- a/doc/MANUAL.adoc +++ b/doc/MANUAL.adoc @@ -1003,8 +1003,9 @@ preprocessing first. Ignore `+__DATE__+`, `+__TIME__+` and `+__TIMESTAMP__+` being present in the source code. *random_seed*:: - By default, ccache will respect argument changes with `-frandom-seed`. This - sloppiness will allow cache hits even if the seed value is different. + Ignore the `-frandom-seed` option and its arguments when computing the input + hash. This is useful if your build system generates different seeds between + builds and you are OK with reusing cached results. -- + See the discussion under _<>_ for more information. diff --git a/src/ccache.cpp b/src/ccache.cpp index 29e90de7b..b065f829a 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -1555,12 +1555,9 @@ hash_argument(const Context& ctx, return {}; } - // If we treat random_seed sloppily we ignore the argument when - // hashing. if (util::starts_with(args[i], "-frandom-seed=") && ctx.config.sloppiness().is_enabled(core::Sloppy::random_seed)) { - hash.hash_delimiter("arg"); - hash.hash("-frandom-seed="); + LOG("Ignoring {} since random_seed sloppiness is requested", args[i]); return {}; } diff --git a/src/core/Sloppiness.hpp b/src/core/Sloppiness.hpp index a7aa08eea..ef45907dd 100644 --- a/src/core/Sloppiness.hpp +++ b/src/core/Sloppiness.hpp @@ -49,7 +49,7 @@ enum class Sloppy : uint32_t { ivfsoverlay = 1U << 10, // Allow us to include incorrect working directory in .gcno files. gcno_cwd = 1U << 11, - // Ignore changes in -frandom-seed + // Ignore -frandom-seed=*string*. random_seed = 1U << 12, };