@@ -1152,7 +1152,7 @@ const TIMING_IMPORTS = Threads.Atomic{Int}(0)
11521152# these return either the array of modules loaded from the path / content given
11531153# or an Exception that describes why it couldn't be loaded
11541154# and it reconnects the Base.Docs.META
1155- function _include_from_serialized (pkg:: PkgId , path:: String , ocachepath:: Union{Nothing, String} , depmods:: Vector{Any} , ignore_native:: Union{Nothing,Bool} = nothing )
1155+ function _include_from_serialized (pkg:: PkgId , path:: String , ocachepath:: Union{Nothing, String} , depmods:: Vector{Any} , ignore_native:: Union{Nothing,Bool} = nothing ; register :: Bool = true )
11561156 if isnothing (ignore_native)
11571157 if JLOptions (). code_coverage == 0 && JLOptions (). malloc_log == 0
11581158 ignore_native = false
@@ -1201,13 +1201,14 @@ function _include_from_serialized(pkg::PkgId, path::String, ocachepath::Union{No
12011201 for M in restored
12021202 M = M:: Module
12031203 if parentmodule (M) === M && PkgId (M) == pkg
1204+ register && register_root_module (M)
12041205 if timing_imports
12051206 elapsed = round ((time_ns () - t_before) / 1e6 , digits = 1 )
12061207 comp_time, recomp_time = cumulative_compile_time_ns () .- t_comp_before
12071208 print (lpad (elapsed, 9 ), " ms " )
1208- parentid = get (EXT_PRIMED, pkg, nothing )
1209- if parentid != = nothing
1210- print (parentid . name , " → " )
1209+ ext_parent = extension_parent_name (M )
1210+ if ext_parent != = nothing
1211+ print (ext_parent :: String , " → " )
12111212 end
12121213 print (pkg. name)
12131214 if comp_time > 0
@@ -1229,6 +1230,27 @@ function _include_from_serialized(pkg::PkgId, path::String, ocachepath::Union{No
12291230 end
12301231end
12311232
1233+ # if M is an extension, return the string name of the parent. Otherwise return nothing
1234+ function extension_parent_name (M:: Module )
1235+ rootmodule = moduleroot (M)
1236+ src_path = pathof (rootmodule)
1237+ src_path === nothing && return nothing
1238+ pkgdir_parts = splitpath (src_path)
1239+ ext_pos = findlast (== (" ext" ), pkgdir_parts)
1240+ if ext_pos != = nothing && ext_pos >= length (pkgdir_parts) - 2
1241+ parent_package_root = joinpath (pkgdir_parts[1 : ext_pos- 1 ]. .. )
1242+ parent_package_project_file = locate_project_file (parent_package_root)
1243+ if parent_package_project_file isa String
1244+ d = parsed_toml (parent_package_project_file)
1245+ name = get (d, " name" , nothing )
1246+ if name != = nothing
1247+ return name
1248+ end
1249+ end
1250+ end
1251+ return nothing
1252+ end
1253+
12321254function register_restored_modules (sv:: SimpleVector , pkg:: PkgId , path:: String )
12331255 # This function is also used by PkgCacheInspector.jl
12341256 restored = sv[1 ]:: Vector{Any}
@@ -1403,7 +1425,7 @@ function _insert_extension_triggers(parent::PkgId, extensions::Dict{String, Any}
14031425 triggers = triggers:: Union{String, Vector{String}}
14041426 triggers isa String && (triggers = [triggers])
14051427 id = PkgId (uuid5 (parent. uuid:: UUID , ext), ext)
1406- if id in keys (EXT_PRIMED) || haskey (Base. loaded_modules, id)
1428+ if haskey (EXT_PRIMED, id ) || haskey (Base. loaded_modules, id)
14071429 continue # extension is already primed or loaded, don't add it again
14081430 end
14091431 EXT_PRIMED[id] = parent
@@ -1833,8 +1855,7 @@ function _tryrequire_from_serialized(pkg::PkgId, path::String, ocachepath::Union
18331855 depmods[i] = dep
18341856 end
18351857 # then load the file
1836- loaded = _include_from_serialized (pkg, path, ocachepath, depmods, ignore_native)
1837- loaded isa Module && register_root_module (loaded)
1858+ loaded = _include_from_serialized (pkg, path, ocachepath, depmods, ignore_native; register = true )
18381859 return loaded
18391860end
18401861
@@ -1901,8 +1922,7 @@ end
19011922 if dep === nothing
19021923 try
19031924 set_pkgorigin_version_path (modkey, modpath)
1904- dep = _include_from_serialized (modkey, modcachepath, modocachepath, modstaledeps)
1905- dep isa Module && stalecheck && register_root_module (dep)
1925+ dep = _include_from_serialized (modkey, modcachepath, modocachepath, modstaledeps; register = stalecheck)
19061926 finally
19071927 end_loading (modkey, dep)
19081928 end
@@ -1918,9 +1938,8 @@ end
19181938 end
19191939 restored = get (loaded_precompiles, pkg => newbuild_id, nothing )
19201940 if ! isa (restored, Module)
1921- restored = _include_from_serialized (pkg, path_to_try, ocachefile, staledeps)
1941+ restored = _include_from_serialized (pkg, path_to_try, ocachefile, staledeps; register = stalecheck )
19221942 end
1923- isa (restored, Module) && stalecheck && register_root_module (restored)
19241943 isa (restored, Module) && return restored
19251944 @debug " Deserialization checks failed while attempting to load cache from $path_to_try " exception= restored
19261945 @label check_next_path
0 commit comments