From f229c7dfd9f12e7926949f0d2dbb8ea888329e5b Mon Sep 17 00:00:00 2001 From: Ian Date: Thu, 7 Oct 2021 22:35:03 -0400 Subject: [PATCH] add option to allow stale_cachefile to ignore loaded modules --- base/loading.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/base/loading.jl b/base/loading.jl index d8e6c00fcb958..1760da1efdbdf 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -1814,7 +1814,7 @@ get_compiletime_preferences(::Nothing) = String[] # returns true if it "cachefile.ji" is stale relative to "modpath.jl" # otherwise returns the list of dependencies to also check -function stale_cachefile(modpath::String, cachefile::String) +function stale_cachefile(modpath::String, cachefile::String; ignore_loaded = false) io = open(cachefile, "r") try if !isvalid_cache_header(io) @@ -1835,11 +1835,15 @@ function stale_cachefile(modpath::String, cachefile::String) M = root_module(req_key) if PkgId(M) == req_key && module_build_id(M) === req_build_id depmods[i] = M + elseif ignore_loaded + # Used by Pkg.precompile given that there it's ok to precompile different versions of loaded packages + @goto locate_branch else @debug "Rejecting cache file $cachefile because module $req_key is already loaded and incompatible." return true # Won't be able to fulfill dependency end else + @label locate_branch path = locate_package(req_key) get!(PkgOrigin, pkgorigins, req_key).path = path if path === nothing