Skip to content

Commit 3ed1ee7

Browse files
add nested precompile worker debug
1 parent f05f93d commit 3ed1ee7

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

base/loading.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2501,6 +2501,7 @@ function create_expr_cache(pkg::PkgId, input::String, output::String, output_o::
25012501
# write data over stdin to avoid the (unlikely) case of exceeding max command line size
25022502
write(io.in, """
25032503
empty!(Base.EXT_DORMITORY) # If we have a custom sysimage with `EXT_DORMITORY` prepopulated
2504+
Base.track_nested_precomp($(repr(vcat(Base.precompilation_stack, pkg.name))))
25042505
Base.precompiling_extension = $(loading_extension)
25052506
Base.include_package_for_output($(pkg_str(pkg)), $(repr(abspath(input))), $(repr(depot_path)), $(repr(dl_load_path)),
25062507
$(repr(load_path)), $deps, $(repr(source_path(nothing))))
@@ -2509,6 +2510,17 @@ function create_expr_cache(pkg::PkgId, input::String, output::String, output_o::
25092510
return io
25102511
end
25112512

2513+
const precompilation_stack = Vector{String}()
2514+
# Helpful for debugging when precompilation is unexpectedly nested.
2515+
# Enable with `JULIA_DEBUG=nested_precomp`. Note that it expected to be nested in classical code-load precompilation
2516+
# TODO: Add detection if extension precompilation is nested and error / return early?
2517+
function track_nested_precomp(pkg_names::Vector{String})
2518+
append!(Base.precompilation_stack, pkg_names)
2519+
if length(Base.precompilation_stack) > 1
2520+
@debug "Nested precompilation: $(join(Base.precompilation_stack, " > "))" _group=:nested_precomp
2521+
end
2522+
end
2523+
25122524
function compilecache_dir(pkg::PkgId)
25132525
entrypath, entryfile = cache_file_entry(pkg)
25142526
return joinpath(DEPOT_PATH[1], entrypath)

pkgimage.mk

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

59+
# Note: you can check for the correctness of this tree by running `JULIA_DEBUG=nested_precomp make` and looking
60+
# out for `Debug: Nested precompilation` logs.
61+
5962
# no dependencies
6063
$(eval $(call stdlib_builder,MozillaCACerts_jll,))
6164
$(eval $(call stdlib_builder,ArgTools,))

0 commit comments

Comments
 (0)