From 0847a7fa3baa2a43b081b9ea1a10a96148e19500 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Sun, 8 Jan 2023 12:42:39 -0500 Subject: [PATCH] Make cache mismatch log more informative (#48168) --- base/loading.jl | 29 ++++++++++++++++++++++++++++- src/staticdata_utils.c | 1 + 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/base/loading.jl b/base/loading.jl index f7ff11f1ae165..9137651007c30 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -2505,6 +2505,29 @@ function check_clone_targets(clone_targets) end end +struct CacheFlags + # ??OOCDDP - see jl_cache_flags + use_pkgimages::Bool + debug_level::Int + check_bounds::Bool + opt_level::Int + + CacheFlags(f::Int) = CacheFlags(UInt8(f)) + function CacheFlags(f::UInt8) + use_pkgimages = Bool(f & 1) + debug_level = Int((f >> 1) & 3) + check_bounds = Bool((f >> 2) & 1) + opt_level = Int((f >> 4) & 3) + new(use_pkgimages, debug_level, check_bounds, opt_level) + end +end +function show(io::IO, cf::CacheFlags) + print(io, "use_pkgimages = ", cf.use_pkgimages) + print(io, ", debug_level = ", cf.debug_level) + print(io, ", check_bounds = ", cf.check_bounds) + print(io, ", opt_level = ", cf.opt_level) +end + # returns true if it "cachefile.ji" is stale relative to "modpath.jl" and build_id for modkey # otherwise returns the list of dependencies to also check @constprop :none function stale_cachefile(modpath::String, cachefile::String; ignore_loaded::Bool = false) @@ -2523,7 +2546,11 @@ end return true # ignore empty file end if ccall(:jl_match_cache_flags, UInt8, (UInt8,), flags) == 0 - @debug "Rejecting cache file $cachefile for $modkey since the flags are mismatched" cachefile_flags=flags current_flags=ccall(:jl_cache_flags, UInt8, ()) + @debug """ + Rejecting cache file $cachefile for $modkey since the flags are mismatched + current session: $(CacheFlags(ccall(:jl_cache_flags, UInt8, ()))) + cache file: $(CacheFlags(flags)) + """ return true end pkgimage = !isempty(clone_targets) diff --git a/src/staticdata_utils.c b/src/staticdata_utils.c index 220a354847dfe..cb107b06a9585 100644 --- a/src/staticdata_utils.c +++ b/src/staticdata_utils.c @@ -621,6 +621,7 @@ JL_DLLEXPORT uint8_t jl_cache_flags(void) flags |= (jl_options.opt_level & 3) << 4; // NOTES: // In contrast to check-bounds, inline has no "observable effect" + // CacheFlags in loading.jl should be kept in-sync with this return flags; }