Skip to content

Commit 3417484

Browse files
committed
make precompile work in Base
1 parent c9e44e3 commit 3417484

File tree

4 files changed

+160
-150
lines changed

4 files changed

+160
-150
lines changed

base/Base.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,6 @@ include("pkgid.jl")
523523
include("toml_parser.jl")
524524
include("linking.jl")
525525
include("loading.jl")
526-
include("precompile.jl")
527526

528527
# misc useful functions & macros
529528
include("timing.jl")
@@ -544,6 +543,8 @@ if isdefined(Core, :Compiler) && is_primary_base_module
544543
Docs.loaddocs(Core.Compiler.CoreDocs.DOCS)
545544
end
546545

546+
include("precompile.jl")
547+
547548
# finally, now make `include` point to the full version
548549
for m in methods(include)
549550
delete_method(m)

base/loading.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,8 +2147,6 @@ end
21472147

21482148
require(uuidkey::PkgId) = @lock require_lock _require_prelocked(uuidkey)
21492149

2150-
const REPL_PKGID = PkgId(UUID("3fa0cd96-eef1-5676-8a61-b3b8758bbffb"), "REPL")
2151-
21522150
function _require_prelocked(uuidkey::PkgId, env=nothing)
21532151
if _require_world_age[] != typemax(UInt)
21542152
Base.invoke_in_world(_require_world_age[], __require_prelocked, uuidkey, env)
@@ -2262,8 +2260,9 @@ function set_pkgorigin_version_path(pkg::PkgId, path::String)
22622260
nothing
22632261
end
22642262

2265-
# A hook to allow code load to use Pkg.precompile
2263+
# Unused
22662264
const PKG_PRECOMPILE_HOOK = Ref{Function}()
2265+
disable_parallel_precompile::Bool = false
22672266

22682267
# Returns `nothing` or the new(ish) module
22692268
function _require(pkg::PkgId, env=nothing)
@@ -2284,7 +2283,7 @@ function _require(pkg::PkgId, env=nothing)
22842283
end
22852284
set_pkgorigin_version_path(pkg, path)
22862285

2287-
pkg_precompile_attempted = false # being safe to avoid getting stuck in a Pkg.precompile loop
2286+
parallel_precompile_attempted = false # being safe to avoid getting stuck in a precompilepkgs loop
22882287
reasons = Dict{String,Int}()
22892288
# attempt to load the module file via the precompile cache locations
22902289
if JLOptions().use_compiled_modules != 0
@@ -2314,11 +2313,13 @@ function _require(pkg::PkgId, env=nothing)
23142313

23152314
if JLOptions().use_compiled_modules == 1
23162315
if !generating_output(#=incremental=#false)
2317-
if !pkg_precompile_attempted && isinteractive() && isassigned(PKG_PRECOMPILE_HOOK)
2318-
pkg_precompile_attempted = true
2316+
project = active_project()
2317+
if !generating_output() && !parallel_precompile_attempted && !disable_parallel_precompile && @isdefined(PrecompilePkgs) && project !== nothing &&
2318+
isfile(project) && project_file_manifest_path(project) !== nothing
2319+
parallel_precompile_attempted = true
23192320
unlock(require_lock)
23202321
try
2321-
@invokelatest PKG_PRECOMPILE_HOOK[](pkg.name, _from_loading = true)
2322+
PrecompilePkgs.precompilepkgs([pkg.name]; _from_loading=true)
23222323
finally
23232324
lock(require_lock)
23242325
end

0 commit comments

Comments
 (0)