Skip to content

Commit 1666dc0

Browse files
committed
make precompile work in Base
1 parent f906e95 commit 1666dc0

File tree

3 files changed

+158
-143
lines changed

3 files changed

+158
-143
lines changed

base/Base.jl

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

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

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

base/loading.jl

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

21382138
require(uuidkey::PkgId) = @lock require_lock _require_prelocked(uuidkey)
21392139

2140-
const REPL_PKGID = PkgId(UUID("3fa0cd96-eef1-5676-8a61-b3b8758bbffb"), "REPL")
2141-
21422140
function _require_prelocked(uuidkey::PkgId, env=nothing)
21432141
if _require_world_age[] != typemax(UInt)
21442142
Base.invoke_in_world(_require_world_age[], __require_prelocked, uuidkey, env)
@@ -2254,7 +2252,7 @@ function set_pkgorigin_version_path(pkg::PkgId, path::Union{String,Nothing})
22542252
nothing
22552253
end
22562254

2257-
# A hook to allow code load to use Pkg.precompile
2255+
# Unused
22582256
const PKG_PRECOMPILE_HOOK = Ref{Function}()
22592257

22602258
# Returns `nothing` or the new(ish) module
@@ -2276,7 +2274,7 @@ function _require(pkg::PkgId, env=nothing)
22762274
end
22772275
set_pkgorigin_version_path(pkg, path)
22782276

2279-
pkg_precompile_attempted = false # being safe to avoid getting stuck in a Pkg.precompile loop
2277+
parallel_precompile_attempted = false # being safe to avoid getting stuck in a precompilepkgs loop
22802278
reasons = Dict{String,Int}()
22812279
# attempt to load the module file via the precompile cache locations
22822280
if JLOptions().use_compiled_modules != 0
@@ -2306,11 +2304,12 @@ function _require(pkg::PkgId, env=nothing)
23062304

23072305
if JLOptions().use_compiled_modules == 1
23082306
if !generating_output(#=incremental=#false)
2309-
if !pkg_precompile_attempted && isinteractive() && isassigned(PKG_PRECOMPILE_HOOK)
2310-
pkg_precompile_attempted = true
2307+
project = active_project()
2308+
if !parallel_precompile_attempted && @isdefined(PrecompilePkgs) && project !== nothing && isfile(project)
2309+
parallel_precompile_attempted = true
23112310
unlock(require_lock)
23122311
try
2313-
@invokelatest PKG_PRECOMPILE_HOOK[](pkg.name, _from_loading = true)
2312+
PrecompilePkgs.precompilepkgs([pkg.name]; _from_loading=true)
23142313
finally
23152314
lock(require_lock)
23162315
end

0 commit comments

Comments
 (0)