diff --git a/lib/compiler/Maker.zig b/lib/compiler/Maker.zig index 565214d5d05cbe7978f3fc3538374cfc425b89dd..d743ff6647edd13b452666aefb51d0fb466ded90 100644 --- a/lib/compiler/Maker.zig +++ b/lib/compiler/Maker.zig @@ -283,11 +283,11 @@ pub fn main(init: process.Init.Minimal) !void { cache_poison = .poisoned; configure_argv.appendAssumeCapacity("--cache-poison=poisoned"); } else if (mem.cutPrefix(u8, arg, "--cache-poison=")) |rest| { - // Allow the configurer process to report parse failure. - if (stringToEnum(std.Build.Graph.CachePoison, rest)) |poison| { - cache_poison = poison; - } - configure_argv.appendAssumeCapacity(arg); + // We have to report parse failure here otherwise we would + // potentially get false positive cache hits for misspellings. + cache_poison = stringToEnum(std.Build.Graph.CachePoison, rest) orelse + fatalWithHint("expected --cache-poison=[pure|poisoned|disallowed|ignored]; found: {s}", .{arg}); + if (cache_poison != .pure) configure_argv.appendAssumeCapacity(arg); } else if (mem.eql(u8, arg, "--verbose")) { // Intentionally is added both to make and configure but // does not go into the cache hash. diff --git a/lib/compiler/configurer.zig b/lib/compiler/configurer.zig index 9151d0d06bab9540bb2382693553ac06ad8d964e..a4f82bb391b5e35f2ab6cbdb67ec84d2208ae089 100644 --- a/lib/compiler/configurer.zig +++ b/lib/compiler/configurer.zig @@ -113,8 +113,8 @@ pub fn main(init: process.Init.Minimal) !void { } else if (mem.eql(u8, arg, "--verbose")) { graph.verbose = true; } else if (mem.cutPrefix(u8, arg, "--cache-poison=")) |rest| { - graph.cache_poison = std.meta.stringToEnum(std.Build.Graph.CachePoison, rest) orelse - fatalWithHint("expected --cache-poison=[pure|poisoned|disallowed|ignored]; found: {s}", .{arg}); + // Already parsed and validated by Maker. + graph.cache_poison = std.meta.stringToEnum(std.Build.Graph.CachePoison, rest).?; } else if (mem.eql(u8, arg, "--search-prefix")) { try graph.search_prefixes.append(arena, nextArgOrFatal(args, &arg_i)); } else {