@@ -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
@@ -1527,6 +1525,7 @@ function _insert_extension_triggers(parent::PkgId, extensions::Dict{String, Any}
15271525end
15281526
15291527loading_extension:: Bool = false
1528+ loadable_extensions:: Union{Nothing,Vector{PkgId}} = nothing
15301529precompiling_extension:: Bool = false
15311530function run_extension_callbacks (extid:: ExtensionId )
15321531 assert_havelock (require_lock)
@@ -1565,7 +1564,7 @@ function run_extension_callbacks(pkgid::PkgId)
15651564 else
15661565 succeeded = true
15671566 end
1568- if extid. ntriggers == 0
1567+ if extid. ntriggers == 0 && (loadable_extensions === nothing || extid . id in loadable_extensions)
15691568 # actually load extid, now that all dependencies are met,
15701569 # and record the result
15711570 succeeded = succeeded && run_extension_callbacks (extid)
@@ -2870,7 +2869,7 @@ end
28702869const PRECOMPILE_TRACE_COMPILE = Ref {String} ()
28712870function create_expr_cache (pkg:: PkgId , input:: String , output:: String , output_o:: Union{Nothing, String} ,
28722871 concrete_deps:: typeof (_concrete_dependencies), flags:: Cmd = ` ` , cacheflags:: CacheFlags = CacheFlags (),
2873- internal_stderr:: IO = stderr , internal_stdout:: IO = stdout , isext :: Bool = false )
2872+ internal_stderr:: IO = stderr , internal_stdout:: IO = stdout , loadable_exts :: Union{Vector{PkgId},Nothing} = nothing )
28742873 @nospecialize internal_stderr internal_stdout
28752874 rm (output, force= true ) # Remove file if it exists
28762875 output_o === nothing || rm (output_o, force= true )
@@ -2944,7 +2943,8 @@ function create_expr_cache(pkg::PkgId, input::String, output::String, output_o::
29442943 write (io. in, """
29452944 empty!(Base.EXT_DORMITORY) # If we have a custom sysimage with `EXT_DORMITORY` prepopulated
29462945 Base.track_nested_precomp($precomp_stack )
2947- Base.precompiling_extension = $(loading_extension | isext)
2946+ Base.loadable_extensions = $(loadable_exts)
2947+ Base.precompiling_extension = $(loading_extension)
29482948 Base.include_package_for_output($(pkg_str (pkg)) , $(repr (abspath (input))) , $(repr (depot_path)) , $(repr (dl_load_path)) ,
29492949 $(repr (load_path)) , $deps , $(repr (source_path (nothing ))) )
29502950 """ )
@@ -3001,18 +3001,18 @@ This can be used to reduce package load times. Cache files are stored in
30013001`DEPOT_PATH[1]/compiled`. See [Module initialization and precompilation](@ref)
30023002for important notes.
30033003"""
3004- 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 )
3004+ 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 )
30053005 @nospecialize internal_stderr internal_stdout
30063006 path = locate_package (pkg)
30073007 path === nothing && throw (ArgumentError (" $(repr (" text/plain" , pkg)) not found during precompilation" ))
3008- return compilecache (pkg, path, internal_stderr, internal_stdout; flags, reasons, isext )
3008+ return compilecache (pkg, path, internal_stderr, internal_stdout; flags, reasons, loadable_exts )
30093009end
30103010
30113011const MAX_NUM_PRECOMPILE_FILES = Ref (10 )
30123012
30133013function compilecache (pkg:: PkgId , path:: String , internal_stderr:: IO = stderr , internal_stdout:: IO = stdout ,
30143014 keep_loaded_modules:: Bool = true ; flags:: Cmd = ` ` , cacheflags:: CacheFlags = CacheFlags (),
3015- reasons:: Union{Dict{String,Int},Nothing} = Dict {String,Int} (), isext :: Bool = false )
3015+ reasons:: Union{Dict{String,Int},Nothing} = Dict {String,Int} (), loadable_exts :: Union{Vector{PkgId},Nothing} = nothing )
30163016
30173017 @nospecialize internal_stderr internal_stdout
30183018 # decide where to put the resulting cache file
@@ -3052,7 +3052,7 @@ function compilecache(pkg::PkgId, path::String, internal_stderr::IO = stderr, in
30523052 close (tmpio_o)
30533053 close (tmpio_so)
30543054 end
3055- p = create_expr_cache (pkg, path, tmppath, tmppath_o, concrete_deps, flags, cacheflags, internal_stderr, internal_stdout, isext )
3055+ p = create_expr_cache (pkg, path, tmppath, tmppath_o, concrete_deps, flags, cacheflags, internal_stderr, internal_stdout, loadable_exts )
30563056
30573057 if success (p)
30583058 if cache_objects
0 commit comments