@@ -1080,6 +1080,7 @@ function register_restored_modules(sv::SimpleVector, pkg::PkgId, path::String)
10801080end
10811081
10821082function run_package_callbacks (modkey:: PkgId )
1083+ run_extension_callbacks (modkey)
10831084 assert_havelock (require_lock)
10841085 unlock (require_lock)
10851086 try
@@ -1204,57 +1205,53 @@ function run_extension_callbacks(extid::ExtensionId)
12041205 return succeeded
12051206end
12061207
1207- function run_extension_callbacks ()
1208+ function run_extension_callbacks (pkgid :: PkgId )
12081209 assert_havelock (require_lock)
1209- loaded_triggers = collect (intersect (keys (Base. loaded_modules), keys (Base. EXT_DORMITORY)))
1210- sort! (loaded_triggers; by= x-> x. uuid)
1211- for pkgid in loaded_triggers
1212- # take ownership of extids that depend on this pkgid
1213- extids = pop! (EXT_DORMITORY, pkgid, nothing )
1214- extids === nothing && continue
1215- for extid in extids
1216- if extid. ntriggers > 0
1217- # It is possible that pkgid was loaded in an environment
1218- # below the one of the parent. This will cause a load failure when the
1219- # pkg ext tries to load the triggers. Therefore, check this first
1220- # before loading the pkg ext.
1221- pkgenv = Base. identify_package_env (extid. id, pkgid. name)
1222- ext_not_allowed_load = false
1223- if pkgenv === nothing
1210+ # take ownership of extids that depend on this pkgid
1211+ extids = pop! (EXT_DORMITORY, pkgid, nothing )
1212+ extids === nothing && return
1213+ for extid in extids
1214+ if extid. ntriggers > 0
1215+ # It is possible that pkgid was loaded in an environment
1216+ # below the one of the parent. This will cause a load failure when the
1217+ # pkg ext tries to load the triggers. Therefore, check this first
1218+ # before loading the pkg ext.
1219+ pkgenv = identify_package_env (extid. id, pkgid. name)
1220+ ext_not_allowed_load = false
1221+ if pkgenv === nothing
1222+ ext_not_allowed_load = true
1223+ else
1224+ pkg, env = pkgenv
1225+ path = locate_package (pkg, env)
1226+ if path === nothing
12241227 ext_not_allowed_load = true
1225- else
1226- pkg, env = pkgenv
1227- path = Base. locate_package (pkg, env)
1228- if path === nothing
1229- ext_not_allowed_load = true
1230- end
1231- end
1232- if ext_not_allowed_load
1233- @debug " Extension $(extid. id. name) of $(extid. parentid. name) will not be loaded \
1234- since $(pkgid. name) loaded in environment lower in load path"
1235- # indicate extid is expected to fail
1236- extid. ntriggers *= - 1
1237- else
1238- # indicate pkgid is loaded
1239- extid. ntriggers -= 1
12401228 end
12411229 end
1242- if extid. ntriggers < 0
1243- # indicate pkgid is loaded
1244- extid. ntriggers += 1
1245- succeeded = false
1230+ if ext_not_allowed_load
1231+ @debug " Extension $(extid. id. name) of $(extid. parentid. name) will not be loaded \
1232+ since $(pkgid. name) loaded in environment lower in load path"
1233+ # indicate extid is expected to fail
1234+ extid. ntriggers *= - 1
12461235 else
1247- succeeded = true
1248- end
1249- if extid. ntriggers == 0
1250- # actually load extid, now that all dependencies are met,
1251- # and record the result
1252- succeeded = succeeded && run_extension_callbacks (extid)
1253- succeeded || push! (EXT_DORMITORY_FAILED, extid)
1236+ # indicate pkgid is loaded
1237+ extid. ntriggers -= 1
12541238 end
12551239 end
1240+ if extid. ntriggers < 0
1241+ # indicate pkgid is loaded
1242+ extid. ntriggers += 1
1243+ succeeded = false
1244+ else
1245+ succeeded = true
1246+ end
1247+ if extid. ntriggers == 0
1248+ # actually load extid, now that all dependencies are met,
1249+ # and record the result
1250+ succeeded = succeeded && run_extension_callbacks (extid)
1251+ succeeded || push! (EXT_DORMITORY_FAILED, extid)
1252+ end
12561253 end
1257- return
1254+ nothing
12581255end
12591256
12601257"""
@@ -1669,10 +1666,6 @@ function _require_prelocked(uuidkey::PkgId, env=nothing)
16691666 else
16701667 newm = root_module (uuidkey)
16711668 end
1672- # Load extensions when not precompiling and not in a nested package load
1673- if JLOptions (). incremental == 0 && isempty (package_locks)
1674- run_extension_callbacks ()
1675- end
16761669 return newm
16771670end
16781671
@@ -2262,6 +2255,7 @@ function compilecache(pkg::PkgId, path::String, internal_stderr::IO = stderr, in
22622255 rm (ocachefile_from_cachefile (evicted_cachefile) * " .dSYM" ; force= true , recursive= true )
22632256 end
22642257 catch
2258+ e isa IOError || rethrow ()
22652259 end
22662260 end
22672261 end
0 commit comments