Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cut short extension load cycles during precompilation #53112

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
shortcut if cycle detected in extension precompilation
  • Loading branch information
IanButterworth committed Feb 15, 2024
commit 1f6c479f806cf74573b3235bd87c9e1ecaefcd88
11 changes: 9 additions & 2 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,13 @@ function run_extension_callbacks(pkgid::PkgId)
extids = pop!(EXT_DORMITORY, pkgid, nothing)
extids === nothing && return
for extid in extids
if in(extid.id, precompilation_stack) && !isprecompiled(extid.id)
IanButterworth marked this conversation as resolved.
Show resolved Hide resolved
@debug """
Dependency cycle detected in extension precompilation: $(precompilation_stack_list()) > $(extid.id.name)
$(extid.id.name) will not be loaded here.
"""
continue
end
if extid.ntriggers > 0
# indicate pkgid is loaded
extid.ntriggers -= 1
Expand Down Expand Up @@ -2569,14 +2576,14 @@ function create_expr_cache(pkg::PkgId, input::String, output::String, output_o::
end

const precompilation_stack = Vector{PkgId}()
precompilation_stack_list() = join(map(p->p.name, precompilation_stack), " > ")
# Helpful for debugging when precompilation is unexpectedly nested.
# Enable with `JULIA_DEBUG=nested_precomp`. Note that it expected to be nested in classical code-load precompilation
# TODO: Add detection if extension precompilation is nested and error / return early?
function track_nested_precomp(pkgs::Vector{PkgId})
append!(precompilation_stack, pkgs)
if length(precompilation_stack) > 1
list() = join(map(p->p.name, precompilation_stack), " > ")
@debug "Nested precompilation: $(list())" _group=:nested_precomp
@debug "Nested precompilation: $(precompilation_stack_list())" _group=:nested_precomp
end
end

Expand Down