1+ const badfile = (nothing , nothing , nothing , UInt128 (0 ))
12function pkg_fileinfo (id:: PkgId )
23 origin = get (Base. pkgorigins, id, nothing )
3- origin === nothing && return nothing , nothing , nothing
4+ origin === nothing && return badfile
45 cachepath = origin. cachepath
5- cachepath === nothing && return nothing , nothing , nothing
6+ cachepath === nothing && return badfile
7+ local checksum
68 provides, includes_requires, required_modules = try
7- @static if VERSION ≥ v " 1.11.0-DEV.683" # https://github.com/JuliaLang/julia/pull/49866
9+ ret = @static if VERSION ≥ v " 1.11.0-DEV.683" # https://github.com/JuliaLang/julia/pull/49866
10+ io = open (cachepath, " r" )
11+ checksum = Base. isvalid_cache_header (io)
12+ iszero (checksum) && (close (io); return badfile)
813 provides, (_, includes_srcfiles_only, requires), required_modules, _... =
9- Base. parse_cache_header (cachepath)
14+ Base. parse_cache_header (io, cachepath)
15+ close (io)
1016 provides, (includes_srcfiles_only, requires), required_modules
1117 else
18+ checksum = UInt64 (0 ) # Buildid prior to v"1.12.0-DEV.764", and the `srcfiles_only` API does not take `io`
1219 Base. parse_cache_header (cachepath, srcfiles_only = true )
1320 end
14- catch
15- return nothing , nothing , nothing
21+ ret
22+ catch err
23+ return badfile
1624 end
1725 includes, _ = includes_requires
1826 for (pkgid, buildid) in provides
1927 if pkgid. uuid === id. uuid && pkgid. name == id. name
20- return cachepath, includes, first .(required_modules)
28+ return cachepath, includes, first .(required_modules), ( UInt128 (checksum) << 64 | buildid)
2129 end
2230 end
2331end
@@ -29,13 +37,17 @@ function parse_pkg_files(id::PkgId)
2937 end
3038 modsym = Symbol (id. name)
3139 if use_compiled_modules ()
32- cachefile, includes, reqs = pkg_fileinfo (id)
40+ cachefile, includes, reqs, buildid = pkg_fileinfo (id)
3341 if cachefile != = nothing
3442 @assert includes != = nothing
3543 @assert reqs != = nothing
3644 pkgdata. requirements = reqs
3745 for chi in includes
38- mod = Base. root_module (id)
46+ if VERSION >= v " 1.12.0-DEV.764" && haskey (Base. loaded_precompiles, id => buildid)
47+ mod = Base. loaded_precompiles[id => buildid]
48+ else
49+ mod = Base. root_module (id)
50+ end
3951 for mpath in chi. modpath
4052 mod = getfield (mod, Symbol (mpath)):: Module
4153 end
0 commit comments