Skip to content

Commit 0847a7f

Browse files
Make cache mismatch log more informative (#48168)
1 parent db7d762 commit 0847a7f

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

base/loading.jl

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2505,6 +2505,29 @@ function check_clone_targets(clone_targets)
25052505
end
25062506
end
25072507

2508+
struct CacheFlags
2509+
# ??OOCDDP - see jl_cache_flags
2510+
use_pkgimages::Bool
2511+
debug_level::Int
2512+
check_bounds::Bool
2513+
opt_level::Int
2514+
2515+
CacheFlags(f::Int) = CacheFlags(UInt8(f))
2516+
function CacheFlags(f::UInt8)
2517+
use_pkgimages = Bool(f & 1)
2518+
debug_level = Int((f >> 1) & 3)
2519+
check_bounds = Bool((f >> 2) & 1)
2520+
opt_level = Int((f >> 4) & 3)
2521+
new(use_pkgimages, debug_level, check_bounds, opt_level)
2522+
end
2523+
end
2524+
function show(io::IO, cf::CacheFlags)
2525+
print(io, "use_pkgimages = ", cf.use_pkgimages)
2526+
print(io, ", debug_level = ", cf.debug_level)
2527+
print(io, ", check_bounds = ", cf.check_bounds)
2528+
print(io, ", opt_level = ", cf.opt_level)
2529+
end
2530+
25082531
# returns true if it "cachefile.ji" is stale relative to "modpath.jl" and build_id for modkey
25092532
# otherwise returns the list of dependencies to also check
25102533
@constprop :none function stale_cachefile(modpath::String, cachefile::String; ignore_loaded::Bool = false)
@@ -2523,7 +2546,11 @@ end
25232546
return true # ignore empty file
25242547
end
25252548
if ccall(:jl_match_cache_flags, UInt8, (UInt8,), flags) == 0
2526-
@debug "Rejecting cache file $cachefile for $modkey since the flags are mismatched" cachefile_flags=flags current_flags=ccall(:jl_cache_flags, UInt8, ())
2549+
@debug """
2550+
Rejecting cache file $cachefile for $modkey since the flags are mismatched
2551+
current session: $(CacheFlags(ccall(:jl_cache_flags, UInt8, ())))
2552+
cache file: $(CacheFlags(flags))
2553+
"""
25272554
return true
25282555
end
25292556
pkgimage = !isempty(clone_targets)

src/staticdata_utils.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ JL_DLLEXPORT uint8_t jl_cache_flags(void)
621621
flags |= (jl_options.opt_level & 3) << 4;
622622
// NOTES:
623623
// In contrast to check-bounds, inline has no "observable effect"
624+
// CacheFlags in loading.jl should be kept in-sync with this
624625
return flags;
625626
}
626627

0 commit comments

Comments
 (0)