Skip to content

Commit

Permalink
always create new cache files in default path when recompiling (fixes J…
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj committed Dec 11, 2015
1 parent afd60fa commit 2841db9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
10 changes: 4 additions & 6 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -538,15 +538,13 @@ function stale_cachefile(modpath, cachefile)
end

function recompile_stale(mod, cachefile)
path = find_in_path(string(mod), nothing)
smod = string(mod)
path = find_in_path(smod, nothing)
if path === nothing
rm(cachefile)
error("module $mod not found in current path; removed orphaned cache file $cachefile")
error("module $mod not found in current path; you should rm(\"$(escape_string(cachefile))\") to remove the orphaned cache file")
end
if stale_cachefile(path, cachefile)
info("Recompiling stale cache file $cachefile for module $mod.")
if !success(create_expr_cache(path, cachefile))
error("Failed to precompile $mod to $cachefile")
end
compilecache(smod)
end
end
14 changes: 13 additions & 1 deletion test/compile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Base.Test

dir = mktempdir()
dir2 = mktempdir()
insert!(LOAD_PATH, 1, dir)
insert!(Base.LOAD_CACHE_PATH, 1, dir)
Foo_module = :Foo4b3a94a1a081a8cb
Expand Down Expand Up @@ -71,6 +72,16 @@ try
end
Base.compilecache("FooBar")
sleep(2)
@test isfile(joinpath(dir, "FooBar.ji"))

touch(FooBar_file)
insert!(Base.LOAD_CACHE_PATH, 1, dir2)
Base.recompile_stale(:FooBar, joinpath(dir, "FooBar.ji"))
sleep(2)
@test isfile(joinpath(dir2, "FooBar.ji"))
@test Base.stale_cachefile(FooBar_file, joinpath(dir, "FooBar.ji"))
@test !Base.stale_cachefile(FooBar_file, joinpath(dir2, "FooBar.ji"))

open(FooBar_file, "w") do f
print(f, """
__precompile__(true)
Expand All @@ -83,9 +94,10 @@ try
@test_throws ErrorException Base.require(:FooBar)

finally
splice!(Base.LOAD_CACHE_PATH, 1)
splice!(Base.LOAD_CACHE_PATH, 1:2)
splice!(LOAD_PATH, 1)
rm(dir, recursive=true)
rm(dir2, recursive=true)
end

# test --compilecache=no command line option
Expand Down

0 comments on commit 2841db9

Please sign in to comment.