Skip to content

Commit fc250c0

Browse files
loading: delete LOAD_CACHE_PATH
1 parent f44c814 commit fc250c0

File tree

8 files changed

+43
-55
lines changed

8 files changed

+43
-55
lines changed

base/initdefs.jl

-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ function and `using` and `import` statements to consider when loading
101101
code.
102102
"""
103103
const LOAD_PATH = Any[]
104-
const LOAD_CACHE_PATH = String[]
105104

106105
function parse_load_path(str::String)
107106
envs = Any[split(str, Sys.iswindows() ? ';' : ':');]

base/loading.jl

+11-13
Original file line numberDiff line numberDiff line change
@@ -638,15 +638,17 @@ function find_source_file(path::AbstractString)
638638
return isfile(base_path) ? base_path : nothing
639639
end
640640

641-
cache_file_entry(pkg::PkgId) =
642-
pkg.uuid === nothing ? "$(pkg.name).ji" :
643-
joinpath(pkg.name, "$(package_slug(pkg.uuid)).ji")
641+
cache_file_entry(pkg::PkgId) = joinpath(
642+
"compiled",
643+
"v$(VERSION.major).$(VERSION.minor)",
644+
pkg.uuid === nothing ? "$(pkg.name).ji" : joinpath(pkg.name, "$(package_slug(pkg.uuid)).ji")
645+
)
644646

645647
function find_all_in_cache_path(pkg::PkgId)
646648
paths = String[]
647-
suffix = cache_file_entry(pkg)
648-
for prefix in LOAD_CACHE_PATH
649-
path = joinpath(prefix, suffix)
649+
entry = cache_file_entry(pkg)
650+
for depot in DEPOT_PATH
651+
path = joinpath(depot, entry)
650652
isfile_casesensitive(path) && push!(paths, path)
651653
end
652654
return paths
@@ -1133,8 +1135,6 @@ function create_expr_cache(input::String, output::String, concrete_deps::typeof(
11331135
append!(Base.LOAD_PATH, $(repr(LOAD_PATH, context=:module=>nothing)))
11341136
empty!(Base.DEPOT_PATH)
11351137
append!(Base.DEPOT_PATH, $(repr(DEPOT_PATH)))
1136-
empty!(Base.LOAD_CACHE_PATH)
1137-
append!(Base.LOAD_CACHE_PATH, $(repr(LOAD_CACHE_PATH)))
11381138
empty!(Base.DL_LOAD_PATH)
11391139
append!(Base.DL_LOAD_PATH, $(repr(DL_LOAD_PATH)))
11401140
Base._track_dependencies[] = true
@@ -1173,11 +1173,9 @@ end
11731173
"""
11741174
Base.compilecache(module::PkgId)
11751175
1176-
Creates a precompiled cache file for
1177-
a module and all of its dependencies.
1176+
Creates a precompiled cache file for a module and all of its dependencies.
11781177
This can be used to reduce package load times. Cache files are stored in
1179-
`LOAD_CACHE_PATH[1]`, which defaults to `~/.julia/lib/VERSION`. See
1180-
[Module initialization and precompilation](@ref)
1178+
`DEPOT_PATH[1]/compiled`. See [Module initialization and precompilation](@ref)
11811179
for important notes.
11821180
"""
11831181
function compilecache(pkg::PkgId)
@@ -1186,7 +1184,7 @@ function compilecache(pkg::PkgId)
11861184
path = locate_package(pkg)
11871185
path === nothing && throw(ArgumentError("$name not found in path"))
11881186
# decide where to put the resulting cache file
1189-
cachefile = abspath(LOAD_CACHE_PATH[1], cache_file_entry(pkg))
1187+
cachefile = abspath(DEPOT_PATH[1], cache_file_entry(pkg))
11901188
cachepath = dirname(cachefile)
11911189
isdir(cachepath) || mkpath(cachepath)
11921190
# build up the list of modules that we want the precompile process to preserve

doc/src/manual/modules.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ versions of modules to reduce this time.
221221
To create an incremental precompiled module file, add `__precompile__()` at the top of your module
222222
file (before the `module` starts). This will cause it to be automatically compiled the first time
223223
it is imported. Alternatively, you can manually call `Base.compilecache(modulename)`. The resulting
224-
cache files will be stored in `Base.LOAD_CACHE_PATH[1]`. Subsequently, the module is automatically
224+
cache files will be stored in `DEPOT_PATH[1]/compiled/`. Subsequently, the module is automatically
225225
recompiled upon `import` whenever any of its dependencies change; dependencies are modules it
226226
imports, the Julia build, files it includes, or explicit dependencies declared by `include_dependency(path)`
227227
in the module file(s).

stdlib/Pkg/src/Pkg.jl

-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ init(meta::AbstractString=DEFAULT_META, branch::AbstractString=META_BRANCH) = Di
8989
function __init__()
9090
vers = "v$(VERSION.major).$(VERSION.minor)"
9191
push!(Base.LOAD_PATH, dir)
92-
pushfirst!(Base.LOAD_CACHE_PATH, abspath(Dir._pkgroot(), "lib", vers))
9392
end
9493

9594
"""

stdlib/Pkg/src/entry.jl

-2
Original file line numberDiff line numberDiff line change
@@ -588,8 +588,6 @@ function build(pkg::AbstractString, build_file::AbstractString, errfile::Abstrac
588588
append!(Base.LOAD_PATH, $(repr(LOAD_PATH, context=:module=>nothing)))
589589
empty!(Base.DEPOT_PATH)
590590
append!(Base.DEPOT_PATH, $(repr(DEPOT_PATH)))
591-
empty!(Base.LOAD_CACHE_PATH)
592-
append!(Base.LOAD_CACHE_PATH, $(repr(Base.LOAD_CACHE_PATH)))
593591
empty!(Base.DL_LOAD_PATH)
594592
append!(Base.DL_LOAD_PATH, $(repr(Base.DL_LOAD_PATH)))
595593
open("$(escape_string(errfile))", "a") do f

stdlib/Pkg3/src/Operations.jl

-4
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,6 @@ function build_versions(ctx::Context, uuids::Vector{UUID})
621621
append!(Base.LOAD_PATH, $(repr(Base.load_path())))
622622
empty!(Base.DEPOT_PATH)
623623
append!(Base.DEPOT_PATH, $(repr(map(abspath, DEPOT_PATH))))
624-
empty!(Base.LOAD_CACHE_PATH)
625-
append!(Base.LOAD_CACHE_PATH, $(repr(map(abspath, Base.LOAD_CACHE_PATH))))
626624
empty!(Base.DL_LOAD_PATH)
627625
append!(Base.DL_LOAD_PATH, $(repr(map(abspath, Base.DL_LOAD_PATH))))
628626
m = Base.require(Base.PkgId(Base.UUID($(repr(string(uuid)))), $(repr(name))))
@@ -878,8 +876,6 @@ function test(ctx::Context, pkgs::Vector{PackageSpec}; coverage=false)
878876
append!(Base.LOAD_PATH, $(repr(Base.load_path())))
879877
empty!(Base.DEPOT_PATH)
880878
append!(Base.DEPOT_PATH, $(repr(map(abspath, DEPOT_PATH))))
881-
empty!(Base.LOAD_CACHE_PATH)
882-
append!(Base.LOAD_CACHE_PATH, $(repr(map(abspath, Base.LOAD_CACHE_PATH))))
883879
empty!(Base.DL_LOAD_PATH)
884880
append!(Base.DL_LOAD_PATH, $(repr(map(abspath, Base.DL_LOAD_PATH))))
885881
m = Base.require(Base.PkgId(Base.UUID($(repr(string(pkg.uuid)))), $(repr(pkg.name))))

test/compile.jl

+31-29
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ using .ConflictingBindings
1616
dir = mktempdir()
1717
dir2 = mktempdir()
1818
insert!(LOAD_PATH, 1, dir)
19-
insert!(Base.LOAD_CACHE_PATH, 1, dir)
19+
insert!(DEPOT_PATH, 1, dir)
2020
try
2121
Foo_file = joinpath(dir, "$Foo_module.jl")
2222
Foo2_file = joinpath(dir, "$Foo2_module.jl")
@@ -166,7 +166,9 @@ try
166166
@test Foo.override(UInt(1)) == 2
167167
end
168168

169-
cachefile = joinpath(dir, "$Foo_module.ji")
169+
cachedir = joinpath(dir, "compiled", "v$(VERSION.major).$(VERSION.minor)")
170+
cachedir2 = joinpath(dir2, "compiled", "v$(VERSION.major).$(VERSION.minor)")
171+
cachefile = joinpath(cachedir, "$Foo_module.ji")
170172
# use _require_from_serialized to ensure that the test fails if
171173
# the module doesn't reload from the image:
172174
@test_logs (:warn, "Replacing module `$Foo_module`") begin
@@ -293,36 +295,36 @@ try
293295
""")
294296

295297
Base.compilecache(Base.PkgId("FooBar"))
296-
@test isfile(joinpath(dir, "FooBar.ji"))
297-
@test Base.stale_cachefile(FooBar_file, joinpath(dir, "FooBar.ji")) isa Vector
298+
@test isfile(joinpath(cachedir, "FooBar.ji"))
299+
@test Base.stale_cachefile(FooBar_file, joinpath(cachedir, "FooBar.ji")) isa Vector
298300
@test !isdefined(Main, :FooBar)
299301
@test !isdefined(Main, :FooBar1)
300302

301303
relFooBar_file = joinpath(dir, "subfolder", "..", "FooBar.jl")
302-
@test Base.stale_cachefile(relFooBar_file, joinpath(dir, "FooBar.ji")) isa (Sys.iswindows() ? Vector : Bool) # `..` is not a symlink on Windows
304+
@test Base.stale_cachefile(relFooBar_file, joinpath(cachedir, "FooBar.ji")) isa (Sys.iswindows() ? Vector : Bool) # `..` is not a symlink on Windows
303305
mkdir(joinpath(dir, "subfolder"))
304-
@test Base.stale_cachefile(relFooBar_file, joinpath(dir, "FooBar.ji")) isa Vector
306+
@test Base.stale_cachefile(relFooBar_file, joinpath(cachedir, "FooBar.ji")) isa Vector
305307

306308
@eval using FooBar
307309
fb_uuid = Base.module_build_id(FooBar)
308310
sleep(2); touch(FooBar_file)
309-
insert!(Base.LOAD_CACHE_PATH, 1, dir2)
310-
@test Base.stale_cachefile(FooBar_file, joinpath(dir, "FooBar.ji")) === true
311+
insert!(DEPOT_PATH, 1, dir2)
312+
@test Base.stale_cachefile(FooBar_file, joinpath(cachedir, "FooBar.ji")) === true
311313
@eval using FooBar1
312-
@test !isfile(joinpath(dir2, "FooBar.ji"))
313-
@test !isfile(joinpath(dir, "FooBar1.ji"))
314-
@test isfile(joinpath(dir2, "FooBar1.ji"))
315-
@test Base.stale_cachefile(FooBar_file, joinpath(dir, "FooBar.ji")) === true
316-
@test Base.stale_cachefile(FooBar1_file, joinpath(dir2, "FooBar1.ji")) isa Vector
314+
@test !isfile(joinpath(cachedir2, "FooBar.ji"))
315+
@test !isfile(joinpath(cachedir, "FooBar1.ji"))
316+
@test isfile(joinpath(cachedir2, "FooBar1.ji"))
317+
@test Base.stale_cachefile(FooBar_file, joinpath(cachedir, "FooBar.ji")) === true
318+
@test Base.stale_cachefile(FooBar1_file, joinpath(cachedir2, "FooBar1.ji")) isa Vector
317319
@test fb_uuid == Base.module_build_id(FooBar)
318320
fb_uuid1 = Base.module_build_id(FooBar1)
319321
@test fb_uuid != fb_uuid1
320322

321323
# test checksum
322-
open(joinpath(dir2, "FooBar1.ji"), "a") do f
324+
open(joinpath(cachedir2, "FooBar1.ji"), "a") do f
323325
write(f, 0x076cac96) # append 4 random bytes
324326
end
325-
@test Base.stale_cachefile(FooBar1_file, joinpath(dir2, "FooBar1.ji")) === true
327+
@test Base.stale_cachefile(FooBar1_file, joinpath(cachedir2, "FooBar1.ji")) === true
326328

327329
# test behavior of precompile modules that throw errors
328330
FooBar2_file = joinpath(dir, "FooBar2.jl")
@@ -373,10 +375,10 @@ try
373375
end
374376
""")
375377
rm(FooBarT_file)
376-
@test Base.stale_cachefile(FooBarT2_file, joinpath(dir2, "FooBarT2.ji")) === true
378+
@test Base.stale_cachefile(FooBarT2_file, joinpath(cachedir2, "FooBarT2.ji")) === true
377379
@test Base.require(Main, :FooBarT2) isa Module
378380
finally
379-
splice!(Base.LOAD_CACHE_PATH, 1:2)
381+
splice!(DEPOT_PATH, 1:2)
380382
splice!(LOAD_PATH, 1)
381383
rm(dir, recursive=true)
382384
rm(dir2, recursive=true)
@@ -398,15 +400,15 @@ let dir = mktempdir(),
398400

399401
eval(quote
400402
insert!(LOAD_PATH, 1, $(dir))
401-
insert!(Base.LOAD_CACHE_PATH, 1, $(dir))
403+
insert!(DEPOT_PATH, 1, $(dir))
402404
Base.compilecache(Base.PkgId("Time4b3a94a1a081a8cb"))
403405
end)
404406

405407
exename = `$(Base.julia_cmd()) --compiled-modules=yes --startup-file=no`
406408

407409
testcode = """
408410
insert!(LOAD_PATH, 1, $(repr(dir)))
409-
insert!(Base.LOAD_CACHE_PATH, 1, $(repr(dir)))
411+
insert!(DEPOT_PATH, 1, $(repr(dir)))
410412
using $Time_module
411413
getfield($Time_module, :time)
412414
"""
@@ -421,7 +423,7 @@ let dir = mktempdir(),
421423
@test parse(Float64, t1_no) < parse(Float64, t2_no)
422424

423425
finally
424-
splice!(Base.LOAD_CACHE_PATH, 1)
426+
splice!(DEPOT_PATH, 1)
425427
splice!(LOAD_PATH, 1)
426428
rm(dir, recursive=true)
427429
end
@@ -448,7 +450,7 @@ let dir = mktempdir()
448450

449451
testcode = """
450452
insert!(LOAD_PATH, 1, $(repr(dir)))
451-
insert!(Base.LOAD_CACHE_PATH, 1, $(repr(dir)))
453+
insert!(DEPOT_PATH, 1, $(repr(dir)))
452454
using $Test_module
453455
"""
454456

@@ -481,7 +483,7 @@ end
481483
let dir = mktempdir()
482484
try
483485
insert!(LOAD_PATH, 1, dir)
484-
insert!(Base.LOAD_CACHE_PATH, 1, dir)
486+
insert!(DEPOT_PATH, 1, dir)
485487

486488
loaded_modules = Channel{Symbol}(32)
487489
callback = (mod::Base.PkgId) -> put!(loaded_modules, Symbol(mod.name))
@@ -521,7 +523,7 @@ let dir = mktempdir()
521523
@test take!(loaded_modules) == Test3_module
522524
finally
523525
pop!(Base.package_callbacks)
524-
splice!(Base.LOAD_CACHE_PATH, 1)
526+
splice!(DEPOT_PATH, 1)
525527
splice!(LOAD_PATH, 1)
526528
rm(dir, recursive=true)
527529
end
@@ -563,7 +565,7 @@ end
563565

564566
@everywhere test_workers begin
565567
pushfirst!(LOAD_PATH, $load_path)
566-
pushfirst!(Base.LOAD_CACHE_PATH, $load_cache_path)
568+
pushfirst!(DEPOT_PATH, $load_cache_path)
567569
end
568570
try
569571
@eval using $ModuleB
@@ -579,7 +581,7 @@ end
579581
finally
580582
@everywhere test_workers begin
581583
popfirst!(LOAD_PATH)
582-
popfirst!(Base.LOAD_CACHE_PATH)
584+
popfirst!(DEPOT_PATH)
583585
end
584586
end
585587
finally
@@ -594,7 +596,7 @@ end
594596
(f -> f())() do # wrap in function scope, so we can test world errors
595597
dir = mktempdir()
596598
insert!(LOAD_PATH, 1, dir)
597-
insert!(Base.LOAD_CACHE_PATH, 1, dir)
599+
insert!(DEPOT_PATH, 1, dir)
598600
try
599601
A_module = :Aedb164bd3a126418
600602
B_module = :Bedb164bd3a126418
@@ -642,7 +644,7 @@ try
642644
@test Base.invokelatest(B.bnopc, 1) == Base.invokelatest(B.bnopc, 1.0) == 2
643645
finally
644646
popfirst!(LOAD_PATH)
645-
popfirst!(Base.LOAD_CACHE_PATH)
647+
popfirst!(DEPOT_PATH)
646648
rm(dir, recursive=true)
647649
end
648650

@@ -662,7 +664,7 @@ let
662664
""")
663665

664666
pushfirst!(LOAD_PATH, load_path)
665-
pushfirst!(Base.LOAD_CACHE_PATH, load_cache_path)
667+
pushfirst!(DEPOT_PATH, load_cache_path)
666668

667669
l0 = length(Base.package_callbacks)
668670
@eval using $ModuleA
@@ -700,7 +702,7 @@ let
700702
""")
701703

702704
pushfirst!(LOAD_PATH, load_path)
703-
pushfirst!(Base.LOAD_CACHE_PATH, load_cache_path)
705+
pushfirst!(DEPOT_PATH, load_cache_path)
704706

705707
Base.compilecache(Base.PkgId("A25604"))
706708
@test_nowarn @eval using A25604

test/embedding/embedding.c

-4
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,6 @@ int main()
163163
// locate files relative to the "embedding" executable
164164
" stdlib = filter(env -> startswith(Base.find_package(Base, \"Distributed\"), env), Base.load_path())[end]\n"
165165
" push!(empty!(LOAD_PATH), dir, stdlib)\n"
166-
// this directory needs to be writable for the example,
167-
// although in real code it usually wouldn't necessarily be used that way
168-
" empty!(Base.LOAD_CACHE_PATH)\n"
169-
" push!(Base.LOAD_CACHE_PATH, tempdir())\n"
170166
"end"
171167
);
172168
checked_eval_string("import LocalModule");

0 commit comments

Comments
 (0)