Skip to content

Commit

Permalink
Make cache mismatch log more informative (#48168)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth authored Jan 8, 2023
1 parent db7d762 commit 0847a7f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
29 changes: 28 additions & 1 deletion base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/staticdata_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 0847a7f

Please sign in to comment.