@@ -1387,9 +1387,7 @@ function run_module_init(mod::Module, i::Int=1)
13871387end
13881388
13891389function run_package_callbacks (modkey:: PkgId )
1390- if ! precompiling_extension
1391- run_extension_callbacks (modkey)
1392- end
1390+ run_extension_callbacks (modkey)
13931391 assert_havelock (require_lock)
13941392 unlock (require_lock)
13951393 try
@@ -1528,6 +1526,7 @@ function _insert_extension_triggers(parent::PkgId, extensions::Dict{String, Any}
15281526end
15291527
15301528loading_extension:: Bool = false
1529+ loadable_extensions:: Union{Nothing,Vector{PkgId}} = nothing
15311530precompiling_extension:: Bool = false
15321531function run_extension_callbacks (extid:: ExtensionId )
15331532 assert_havelock (require_lock)
@@ -1558,7 +1557,7 @@ function run_extension_callbacks(pkgid::PkgId)
15581557 for extid in extids
15591558 @assert extid. ntriggers > 0
15601559 extid. ntriggers -= 1
1561- if extid. ntriggers == 0
1560+ if extid. ntriggers == 0 && (loadable_extensions === nothing || extid . id in loadable_extensions)
15621561 push! (extids_to_load, extid)
15631562 end
15641563 end
@@ -2868,7 +2867,7 @@ end
28682867const PRECOMPILE_TRACE_COMPILE = Ref {String} ()
28692868function create_expr_cache (pkg:: PkgId , input:: String , output:: String , output_o:: Union{Nothing, String} ,
28702869 concrete_deps:: typeof (_concrete_dependencies), flags:: Cmd = ` ` , cacheflags:: CacheFlags = CacheFlags (),
2871- internal_stderr:: IO = stderr , internal_stdout:: IO = stdout , isext :: Bool = false )
2870+ internal_stderr:: IO = stderr , internal_stdout:: IO = stdout , loadable_exts :: Union{Vector{PkgId},Nothing} = nothing )
28722871 @nospecialize internal_stderr internal_stdout
28732872 rm (output, force= true ) # Remove file if it exists
28742873 output_o === nothing || rm (output_o, force= true )
@@ -2942,7 +2941,8 @@ function create_expr_cache(pkg::PkgId, input::String, output::String, output_o::
29422941 write (io. in, """
29432942 empty!(Base.EXT_DORMITORY) # If we have a custom sysimage with `EXT_DORMITORY` prepopulated
29442943 Base.track_nested_precomp($precomp_stack )
2945- Base.precompiling_extension = $(loading_extension | isext)
2944+ Base.loadable_extensions = $(loadable_exts)
2945+ Base.precompiling_extension = $(loading_extension)
29462946 Base.include_package_for_output($(pkg_str (pkg)) , $(repr (abspath (input))) , $(repr (depot_path)) , $(repr (dl_load_path)) ,
29472947 $(repr (load_path)) , $deps , $(repr (source_path (nothing ))) )
29482948 """ )
@@ -2999,18 +2999,18 @@ This can be used to reduce package load times. Cache files are stored in
29992999`DEPOT_PATH[1]/compiled`. See [Module initialization and precompilation](@ref)
30003000for important notes.
30013001"""
3002- function compilecache (pkg:: PkgId , internal_stderr:: IO = stderr , internal_stdout:: IO = stdout ; flags:: Cmd = ` ` , reasons:: Union{Dict{String,Int},Nothing} = Dict {String,Int} (), isext :: Bool = false )
3002+ function compilecache (pkg:: PkgId , internal_stderr:: IO = stderr , internal_stdout:: IO = stdout ; flags:: Cmd = ` ` , reasons:: Union{Dict{String,Int},Nothing} = Dict {String,Int} (), loadable_exts :: Union{Vector{PkgId},Nothing} = nothing )
30033003 @nospecialize internal_stderr internal_stdout
30043004 path = locate_package (pkg)
30053005 path === nothing && throw (ArgumentError (" $(repr (" text/plain" , pkg)) not found during precompilation" ))
3006- return compilecache (pkg, path, internal_stderr, internal_stdout; flags, reasons, isext )
3006+ return compilecache (pkg, path, internal_stderr, internal_stdout; flags, reasons, loadable_exts )
30073007end
30083008
30093009const MAX_NUM_PRECOMPILE_FILES = Ref (10 )
30103010
30113011function compilecache (pkg:: PkgId , path:: String , internal_stderr:: IO = stderr , internal_stdout:: IO = stdout ,
30123012 keep_loaded_modules:: Bool = true ; flags:: Cmd = ` ` , cacheflags:: CacheFlags = CacheFlags (),
3013- reasons:: Union{Dict{String,Int},Nothing} = Dict {String,Int} (), isext :: Bool = false )
3013+ reasons:: Union{Dict{String,Int},Nothing} = Dict {String,Int} (), loadable_exts :: Union{Vector{PkgId},Nothing} = nothing )
30143014
30153015 @nospecialize internal_stderr internal_stdout
30163016 # decide where to put the resulting cache file
@@ -3050,7 +3050,7 @@ function compilecache(pkg::PkgId, path::String, internal_stderr::IO = stderr, in
30503050 close (tmpio_o)
30513051 close (tmpio_so)
30523052 end
3053- p = create_expr_cache (pkg, path, tmppath, tmppath_o, concrete_deps, flags, cacheflags, internal_stderr, internal_stdout, isext )
3053+ p = create_expr_cache (pkg, path, tmppath, tmppath_o, concrete_deps, flags, cacheflags, internal_stderr, internal_stdout, loadable_exts )
30543054
30553055 if success (p)
30563056 if cache_objects
0 commit comments