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

Add nested precomp highlight debug #53111

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 13 additions & 0 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2508,6 +2508,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($(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 @@ -2516,6 +2517,18 @@ function create_expr_cache(pkg::PkgId, input::String, output::String, output_o::
return io
end

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(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

function compilecache_dir(pkg::PkgId)
entrypath, entryfile = cache_file_entry(pkg)
return joinpath(DEPOT_PATH[1], entrypath)
Expand Down
3 changes: 3 additions & 0 deletions pkgimage.mk
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ cache-debug-$1: $$(BUILDDIR)/stdlib/$1.debug.image
.SECONDARY: $$(BUILDDIR)/stdlib/$1.release.image $$(BUILDDIR)/stdlib/$1.debug.image
endef

# Note: you can check for the correctness of this tree by running `JULIA_DEBUG=nested_precomp make` and looking
# out for `Debug: Nested precompilation` logs.

# no dependencies
$(eval $(call stdlib_builder,MozillaCACerts_jll,))
$(eval $(call stdlib_builder,ArgTools,))
Expand Down