Skip to content

Commit 06f8519

Browse files
committed
Prevent pre-compilation target package from triggering extensions
It is possible for an extension `ExtAB` to be loadable by one of its triggers, e.g. if A loads B. However this loading is only supposed to happen after loading for A is finished, so it shouldn't be included as part of pre-compiling A. Getting this wrong means disagreeing with the scheduled pre-compile jobs (A is not scheduled to depend on or generate a cache file for ExtAB but accidentally does both) and leads to confusing errors about missing cache files. To avoid trying to use / generate a cache file for ExtAB while still pre-compiling A, this change tracks the package being currently pre- compiled so that its extension triggers can be ignored.
1 parent a1dbfd0 commit 06f8519

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

base/loading.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1433,6 +1433,7 @@ function run_module_init(mod::Module, i::Int=1)
14331433
end
14341434

14351435
function run_package_callbacks(modkey::PkgId)
1436+
@assert modkey != precompilation_target
14361437
run_extension_callbacks(modkey)
14371438
assert_havelock(require_lock)
14381439
unlock(require_lock)
@@ -1562,7 +1563,7 @@ function _insert_extension_triggers(parent::PkgId, extensions::Dict{String, Any}
15621563
uuid_trigger = UUID(totaldeps[trigger]::String)
15631564
trigger_id = PkgId(uuid_trigger, trigger)
15641565
push!(trigger_ids, trigger_id)
1565-
if !haskey(Base.loaded_modules, trigger_id) || haskey(package_locks, trigger_id)
1566+
if !haskey(Base.loaded_modules, trigger_id) || haskey(package_locks, trigger_id) || (trigger_id == precompilation_target)
15661567
trigger1 = get!(Vector{ExtensionId}, EXT_DORMITORY, trigger_id)
15671568
push!(trigger1, gid)
15681569
else
@@ -1575,6 +1576,7 @@ end
15751576
loading_extension::Bool = false
15761577
loadable_extensions::Union{Nothing,Vector{PkgId}} = nothing
15771578
precompiling_extension::Bool = false
1579+
precompilation_target::Union{Nothing,PkgId} = nothing
15781580
function run_extension_callbacks(extid::ExtensionId)
15791581
assert_havelock(require_lock)
15801582
succeeded = try
@@ -3081,6 +3083,7 @@ function create_expr_cache(pkg::PkgId, input::String, output::String, output_o::
30813083
Base.track_nested_precomp($(_pkg_str(vcat(Base.precompilation_stack, pkg))))
30823084
Base.loadable_extensions = $(_pkg_str(loadable_exts))
30833085
Base.precompiling_extension = $(loading_extension)
3086+
Base.precompilation_target = $(_pkg_str(pkg))
30843087
Base.include_package_for_output($(_pkg_str(pkg)), $(repr(abspath(input))), $(repr(depot_path)), $(repr(dl_load_path)),
30853088
$(repr(load_path)), $(_pkg_str(concrete_deps)), $(repr(source_path(nothing))))
30863089
""")

0 commit comments

Comments
 (0)