Skip to content

Commit a296c74

Browse files
IanButterworthKristofferC
authored andcommitted
add option to allow stale_cachefile to ignore loaded modules (#42545)
(cherry picked from commit bbe9375)
1 parent ba5fcf8 commit a296c74

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

base/loading.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,7 @@ get_compiletime_preferences(::Nothing) = String[]
17121712

17131713
# returns true if it "cachefile.ji" is stale relative to "modpath.jl"
17141714
# otherwise returns the list of dependencies to also check
1715-
function stale_cachefile(modpath::String, cachefile::String)
1715+
function stale_cachefile(modpath::String, cachefile::String; ignore_loaded = false)
17161716
io = open(cachefile, "r")
17171717
try
17181718
if !isvalid_cache_header(io)
@@ -1733,11 +1733,15 @@ function stale_cachefile(modpath::String, cachefile::String)
17331733
M = root_module(req_key)
17341734
if PkgId(M) == req_key && module_build_id(M) === req_build_id
17351735
depmods[i] = M
1736+
elseif ignore_loaded
1737+
# Used by Pkg.precompile given that there it's ok to precompile different versions of loaded packages
1738+
@goto locate_branch
17361739
else
17371740
@debug "Rejecting cache file $cachefile because module $req_key is already loaded and incompatible."
17381741
return true # Won't be able to fulfill dependency
17391742
end
17401743
else
1744+
@label locate_branch
17411745
path = locate_package(req_key)
17421746
get!(PkgOrigin, pkgorigins, req_key).path = path
17431747
if path === nothing

0 commit comments

Comments
 (0)