@@ -699,7 +699,16 @@ function parse_cache_header(f::IO)
699
699
push! (files, (String (read (f, n)), ntoh (read (f, Float64))))
700
700
end
701
701
@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
703
712
end
704
713
705
714
function parse_cache_header (cachefile:: String )
@@ -713,15 +722,7 @@ function parse_cache_header(cachefile::String)
713
722
end
714
723
715
724
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)
725
726
return modules, files
726
727
end
727
728
@@ -742,7 +743,22 @@ function stale_cachefile(modpath::String, cachefile::String)
742
743
DEBUG_LOADING[] && info (" JL_DEBUG_LOADING: Rejecting cache file $cachefile due to it containing an invalid cache header." )
743
744
return true # invalid cache file
744
745
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
+ if mod == :Main || mod == :Core || mod == :Base
751
+ continue
752
+ # Module is already loaded
753
+ elseif isdefined (Main, mod)
754
+ continue
755
+ end
756
+ name = string (mod)
757
+ path = find_in_node_path (name, nothing , 1 )
758
+ if path === nothing
759
+ return true # Won't be able to fullfill dependency
760
+ end
761
+ end
746
762
747
763
# check if this file is going to provide one of our concrete dependencies
748
764
# or if it provides a version that conflicts with our concrete dependencies
0 commit comments