Skip to content

Commit aaaa68d

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

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
@@ -1793,7 +1793,7 @@ get_compiletime_preferences(::Nothing) = String[]
17931793

17941794
# returns true if it "cachefile.ji" is stale relative to "modpath.jl"
17951795
# otherwise returns the list of dependencies to also check
1796-
function stale_cachefile(modpath::String, cachefile::String)
1796+
function stale_cachefile(modpath::String, cachefile::String; ignore_loaded = false)
17971797
io = open(cachefile, "r")
17981798
try
17991799
if !isvalid_cache_header(io)
@@ -1814,11 +1814,15 @@ function stale_cachefile(modpath::String, cachefile::String)
18141814
M = root_module(req_key)
18151815
if PkgId(M) == req_key && module_build_id(M) === req_build_id
18161816
depmods[i] = M
1817+
elseif ignore_loaded
1818+
# Used by Pkg.precompile given that there it's ok to precompile different versions of loaded packages
1819+
@goto locate_branch
18171820
else
18181821
@debug "Rejecting cache file $cachefile because module $req_key is already loaded and incompatible."
18191822
return true # Won't be able to fulfill dependency
18201823
end
18211824
else
1825+
@label locate_branch
18221826
path = locate_package(req_key)
18231827
get!(PkgOrigin, pkgorigins, req_key).path = path
18241828
if path === nothing

0 commit comments

Comments
 (0)