Skip to content

Commit 8ff037a

Browse files
committed
check if cachefile dependencies can be fulfilled
1 parent eed97e9 commit 8ff037a

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

base/loading.jl

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,16 @@ function parse_cache_header(f::IO)
699699
push!(files, (String(read(f, n)), ntoh(read(f, Float64))))
700700
end
701701
@assert totbytes == 4 "header of cache file appears to be corrupt"
702-
return modules, files
702+
# read the list of modules that are required to be present during loading
703+
required_modules = Dict{Symbol, UInt64}()
704+
while true
705+
n = ntoh(read(f, Int32))
706+
n == 0 && break
707+
sym = Symbol(read(f, n)) # module symbol
708+
uuid = ntoh(read(f, UInt64)) # module UUID
709+
required_modules[sym] = uuid
710+
end
711+
return modules, files, required_modules
703712
end
704713

705714
function parse_cache_header(cachefile::String)
@@ -713,15 +722,7 @@ function parse_cache_header(cachefile::String)
713722
end
714723

715724
function cache_dependencies(f::IO)
716-
defs, files = parse_cache_header(f)
717-
modules = []
718-
while true
719-
n = ntoh(read(f, Int32))
720-
n == 0 && break
721-
sym = Symbol(read(f, n)) # module symbol
722-
uuid = ntoh(read(f, UInt64)) # module UUID (mostly just a timestamp)
723-
push!(modules, (sym, uuid))
724-
end
725+
defs, files, modules = parse_cache_header(f)
725726
return modules, files
726727
end
727728

@@ -742,7 +743,17 @@ function stale_cachefile(modpath::String, cachefile::String)
742743
DEBUG_LOADING[] && info("JL_DEBUG_LOADING: Rejecting cache file $cachefile due to it containing an invalid cache header.")
743744
return true # invalid cache file
744745
end
745-
modules, files = parse_cache_header(io)
746+
modules, files, required_modules = parse_cache_header(io)
747+
748+
# Check if transitive dependencies can be fullfilled
749+
for mod in keys(required_modules)
750+
isdefined(Main, mod) && continue
751+
name = string(mod)
752+
path = find_in_node_path(name, nothing, 1)
753+
if path === nothing
754+
return true # Won't be able to fullfill dependency
755+
end
756+
end
746757

747758
# check if this file is going to provide one of our concrete dependencies
748759
# or if it provides a version that conflicts with our concrete dependencies

0 commit comments

Comments
 (0)