Skip to content

Commit

Permalink
use Vector{PkgId}
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Jan 30, 2024
1 parent 3ed1ee7 commit 99191f1
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2501,7 +2501,7 @@ function create_expr_cache(pkg::PkgId, input::String, output::String, output_o::
# write data over stdin to avoid the (unlikely) case of exceeding max command line size
write(io.in, """
empty!(Base.EXT_DORMITORY) # If we have a custom sysimage with `EXT_DORMITORY` prepopulated
Base.track_nested_precomp($(repr(vcat(Base.precompilation_stack, pkg.name))))
Base.track_nested_precomp($(repr_pkgid_vec(vcat(Base.precompilation_stack, pkg))))
Base.precompiling_extension = $(loading_extension)
Base.include_package_for_output($(pkg_str(pkg)), $(repr(abspath(input))), $(repr(depot_path)), $(repr(dl_load_path)),
$(repr(load_path)), $deps, $(repr(source_path(nothing))))
Expand All @@ -2510,14 +2510,25 @@ function create_expr_cache(pkg::PkgId, input::String, output::String, output_o::
return io
end

const precompilation_stack = Vector{String}()
# TODO: remove once https://github.com/JuliaLang/julia/pull/52795 is figured out
function repr_pkgid(pkg::PkgId)
if pkg.uuid === nothing
return "$(PkgId)($(repr(pkg.name)))"
else
return "$(PkgId)($(repr(pkg.uuid)), $(repr(pkg.name)))"
end
end
repr_pkgid_vec(pkgs::Vector{PkgId}) = "$(PkgId)[" * join(repr_pkgid.(pkgs), ",") * "]"

const precompilation_stack = Vector{PkgId}()
# 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(pkg_names::Vector{String})
append!(Base.precompilation_stack, pkg_names)
if length(Base.precompilation_stack) > 1
@debug "Nested precompilation: $(join(Base.precompilation_stack, " > "))" _group=:nested_precomp
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
end
end

Expand Down

0 comments on commit 99191f1

Please sign in to comment.