@@ -2508,6 +2508,7 @@ function create_expr_cache(pkg::PkgId, input::String, output::String, output_o::
2508
2508
# write data over stdin to avoid the (unlikely) case of exceeding max command line size
2509
2509
write (io. in, """
2510
2510
empty!(Base.EXT_DORMITORY) # If we have a custom sysimage with `EXT_DORMITORY` prepopulated
2511
+ Base.track_nested_precomp($(vcat (Base. precompilation_stack, pkg)) )
2511
2512
Base.precompiling_extension = $(loading_extension)
2512
2513
Base.include_package_for_output($(pkg_str (pkg)) , $(repr (abspath (input))) , $(repr (depot_path)) , $(repr (dl_load_path)) ,
2513
2514
$(repr (load_path)) , $deps , $(repr (source_path (nothing ))) )
@@ -2516,6 +2517,18 @@ function create_expr_cache(pkg::PkgId, input::String, output::String, output_o::
2516
2517
return io
2517
2518
end
2518
2519
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
+
2519
2532
function compilecache_dir (pkg:: PkgId )
2520
2533
entrypath, entryfile = cache_file_entry (pkg)
2521
2534
return joinpath (DEPOT_PATH [1 ], entrypath)
0 commit comments