Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fail to load modules if precompilation fails #12723

Merged
merged 1 commit into from
Aug 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ end
evalfile(path::AbstractString, args::Vector) = evalfile(path, UTF8String[args...])

function create_expr_cache(input::AbstractString, output::AbstractString)
isfile(output) && rm(output)
code_object = """
while !eof(STDIN)
eval(Main, deserialize(STDIN))
Expand Down Expand Up @@ -402,11 +403,12 @@ function stale_cachefile(cachefile::AbstractString)
end

function recompile_stale(mod, cachefile)
cachestat = stat(cachefile)
if iswritable(cachestat) && stale_cachefile(cachefile)
if stale_cachefile(cachefile)
info("Recompiling stale cache file $cachefile for module $mod.")
path = find_in_path(string(mod))
path === nothing && error("module $mod not found")
create_expr_cache(path, cachefile)
if !success(create_expr_cache(path, cachefile))
error("Failed to precompile $mod to $cachefile")
end
end
end
3 changes: 2 additions & 1 deletion src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,8 @@ static void julia_save()
return;
}
if (jl_options.outputji)
jl_save_incremental(jl_options.outputji, worklist);
if (jl_save_incremental(jl_options.outputji, worklist))
jl_exit(1);
if (jl_options.outputbc)
jl_printf(JL_STDERR, "WARNING: incremental output to a .bc file is not implemented\n");
if (jl_options.outputo)
Expand Down
22 changes: 22 additions & 0 deletions test/compile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,28 @@ try
end
println(STDERR, "\nNOTE: The following 'LoadError: __precompile__(false)' indicates normal operation")
@test_throws ErrorException Base.compilecache("Baz") # from __precompile__(false)

# Issue #12720
FooBar_file = joinpath(dir, "FooBar.jl")
open(FooBar_file, "w") do f
print(f, """
__precompile__(true)
module FooBar
end
""")
end
Base.compilecache("FooBar")
sleep(2)
open(FooBar_file, "w") do f
print(f, """
__precompile__(true)
module FooBar
error("break me")
end
""")
end
println(STDERR, "\nNOTE: The following 'LoadError: break me' indicates normal operation")
@test_throws ErrorException require(:FooBar)
finally
splice!(Base.LOAD_CACHE_PATH, 1)
splice!(LOAD_PATH, 1)
Expand Down