Skip to content

Commit 4472015

Browse files
add nested precompile worker debug
1 parent 3dadada commit 4472015

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

base/loading.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2508,6 +2508,7 @@ function create_expr_cache(pkg::PkgId, input::String, output::String, output_o::
25082508
# write data over stdin to avoid the (unlikely) case of exceeding max command line size
25092509
write(io.in, """
25102510
empty!(Base.EXT_DORMITORY) # If we have a custom sysimage with `EXT_DORMITORY` prepopulated
2511+
Base.track_nested_precomp($(vcat(Base.precompilation_stack, pkg)))
25112512
Base.precompiling_extension = $(loading_extension)
25122513
Base.include_package_for_output($(pkg_str(pkg)), $(repr(abspath(input))), $(repr(depot_path)), $(repr(dl_load_path)),
25132514
$(repr(load_path)), $deps, $(repr(source_path(nothing))))
@@ -2516,6 +2517,18 @@ function create_expr_cache(pkg::PkgId, input::String, output::String, output_o::
25162517
return io
25172518
end
25182519

2520+
const precompilation_stack = Vector{PkgId}()
2521+
# Helpful for debugging when precompilation is unexpectedly nested.
2522+
# Enable with `JULIA_DEBUG=nested_precomp`. Note that it expected to be nested in classical code-load precompilation
2523+
# TODO: Add detection if extension precompilation is nested and error / return early?
2524+
function track_nested_precomp(pkgs::Vector{PkgId})
2525+
append!(precompilation_stack, pkgs)
2526+
if length(precompilation_stack) > 1
2527+
list() = join(map(p->p.name, precompilation_stack), " > ")
2528+
@debug "Nested precompilation: $(list())" _group=:nested_precomp
2529+
end
2530+
end
2531+
25192532
function compilecache_dir(pkg::PkgId)
25202533
entrypath, entryfile = cache_file_entry(pkg)
25212534
return joinpath(DEPOT_PATH[1], entrypath)

pkgimage.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ cache-debug-$1: $$(BUILDDIR)/stdlib/$1.debug.image
6969
.SECONDARY: $$(BUILDDIR)/stdlib/$1.release.image $$(BUILDDIR)/stdlib/$1.debug.image
7070
endef
7171

72+
# Note: you can check for the correctness of this tree by running `JULIA_DEBUG=nested_precomp make` and looking
73+
# out for `Debug: Nested precompilation` logs.
74+
7275
# no dependencies
7376
$(eval $(call stdlib_builder,MozillaCACerts_jll,))
7477
$(eval $(call stdlib_builder,ArgTools,))

0 commit comments

Comments
 (0)