@@ -1080,7 +1080,6 @@ function register_restored_modules(sv::SimpleVector, pkg::PkgId, path::String)
1080
1080
end
1081
1081
1082
1082
function run_package_callbacks (modkey:: PkgId )
1083
- run_extension_callbacks (modkey)
1084
1083
assert_havelock (require_lock)
1085
1084
unlock (require_lock)
1086
1085
try
@@ -1204,53 +1203,57 @@ function run_extension_callbacks(extid::ExtensionId)
1204
1203
return succeeded
1205
1204
end
1206
1205
1207
- function run_extension_callbacks (pkgid :: PkgId )
1206
+ function run_extension_callbacks ()
1208
1207
assert_havelock (require_lock)
1209
- # take ownership of extids that depend on this pkgid
1210
- extids = pop! (EXT_DORMITORY, pkgid, nothing )
1211
- extids === nothing && return
1212
- for extid in extids
1213
- if extid. ntriggers > 0
1214
- # It is possible that pkgid was loaded in an environment
1215
- # below the one of the parent. This will cause a load failure when the
1216
- # pkg ext tries to load the triggers. Therefore, check this first
1217
- # before loading the pkg ext.
1218
- pkgenv = Base. identify_package_env (extid. id, pkgid. name)
1219
- ext_not_allowed_load = false
1220
- if pkgenv === nothing
1221
- ext_not_allowed_load = true
1222
- else
1223
- pkg, env = pkgenv
1224
- path = Base. locate_package (pkg, env)
1225
- if path === nothing
1208
+ loaded_triggers = collect (intersect (keys (Base. loaded_modules), keys (Base. EXT_DORMITORY)))
1209
+ sort! (loaded_triggers; by= x-> x. uuid)
1210
+ for pkgid in loaded_triggers
1211
+ # take ownership of extids that depend on this pkgid
1212
+ extids = pop! (EXT_DORMITORY, pkgid, nothing )
1213
+ extids === nothing && continue
1214
+ for extid in extids
1215
+ if extid. ntriggers > 0
1216
+ # It is possible that pkgid was loaded in an environment
1217
+ # below the one of the parent. This will cause a load failure when the
1218
+ # pkg ext tries to load the triggers. Therefore, check this first
1219
+ # before loading the pkg ext.
1220
+ pkgenv = Base. identify_package_env (extid. id, pkgid. name)
1221
+ ext_not_allowed_load = false
1222
+ if pkgenv === nothing
1226
1223
ext_not_allowed_load = true
1224
+ else
1225
+ pkg, env = pkgenv
1226
+ path = Base. locate_package (pkg, env)
1227
+ if path === nothing
1228
+ ext_not_allowed_load = true
1229
+ end
1230
+ end
1231
+ if ext_not_allowed_load
1232
+ @debug " Extension $(extid. id. name) of $(extid. parentid. name) will not be loaded \
1233
+ since $(pkgid. name) loaded in environment lower in load path"
1234
+ # indicate extid is expected to fail
1235
+ extid. ntriggers *= - 1
1236
+ else
1237
+ # indicate pkgid is loaded
1238
+ extid. ntriggers -= 1
1227
1239
end
1228
1240
end
1229
- if ext_not_allowed_load
1230
- @debug " Extension $(extid. id. name) of $(extid. parentid. name) will not be loaded \
1231
- since $(pkgid. name) loaded in environment lower in load path"
1232
- # indicate extid is expected to fail
1233
- extid. ntriggers *= - 1
1234
- else
1241
+ if extid. ntriggers < 0
1235
1242
# indicate pkgid is loaded
1236
- extid. ntriggers -= 1
1243
+ extid. ntriggers += 1
1244
+ succeeded = false
1245
+ else
1246
+ succeeded = true
1247
+ end
1248
+ if extid. ntriggers == 0
1249
+ # actually load extid, now that all dependencies are met,
1250
+ # and record the result
1251
+ succeeded = succeeded && run_extension_callbacks (extid)
1252
+ succeeded || push! (EXT_DORMITORY_FAILED, extid)
1237
1253
end
1238
- end
1239
- if extid. ntriggers < 0
1240
- # indicate pkgid is loaded
1241
- extid. ntriggers += 1
1242
- succeeded = false
1243
- else
1244
- succeeded = true
1245
- end
1246
- if extid. ntriggers == 0
1247
- # actually load extid, now that all dependencies are met,
1248
- # and record the result
1249
- succeeded = succeeded && run_extension_callbacks (extid)
1250
- succeeded || push! (EXT_DORMITORY_FAILED, extid)
1251
1254
end
1252
1255
end
1253
- nothing
1256
+ return
1254
1257
end
1255
1258
1256
1259
"""
@@ -1665,6 +1668,10 @@ function _require_prelocked(uuidkey::PkgId, env=nothing)
1665
1668
else
1666
1669
newm = root_module (uuidkey)
1667
1670
end
1671
+ # Load extensions when not precompiling and not in a nested package load
1672
+ if JLOptions (). incremental == 0 && isempty (package_locks)
1673
+ run_extension_callbacks ()
1674
+ end
1668
1675
return newm
1669
1676
end
1670
1677
0 commit comments