Skip to content

Commit

Permalink
Allow hiding stderr during compilecache (#37596)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth authored Sep 21, 2020
1 parent b18647e commit 03ec50d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ end
@assert precompile(include_package_for_output, (PkgId,String,Vector{String},Vector{String},Vector{String},typeof(_concrete_dependencies),Nothing))
@assert precompile(include_package_for_output, (PkgId,String,Vector{String},Vector{String},Vector{String},typeof(_concrete_dependencies),String))

function create_expr_cache(pkg::PkgId, input::String, output::String, concrete_deps::typeof(_concrete_dependencies))
function create_expr_cache(pkg::PkgId, input::String, output::String, concrete_deps::typeof(_concrete_dependencies), show_errors::Bool = true)
rm(output, force=true) # Remove file if it exists
depot_path = map(abspath, DEPOT_PATH)
dl_load_path = map(abspath, DL_LOAD_PATH)
Expand All @@ -1178,7 +1178,7 @@ function create_expr_cache(pkg::PkgId, input::String, output::String, concrete_d
--output-ji $output --output-incremental=yes
--startup-file=no --history-file=no --warn-overwrite=yes
--color=$(have_color === nothing ? "auto" : have_color ? "yes" : "no")
--eval 'eval(Meta.parse(read(stdin,String)))'`, stderr=stderr),
--eval 'eval(Meta.parse(read(stdin,String)))'`, stderr=show_errors ? stderr : devnull),
"w", stdout)
# write data over stdin to avoid the (unlikely) case of exceeding max command line size
write(io.in, """
Expand All @@ -1189,8 +1189,8 @@ function create_expr_cache(pkg::PkgId, input::String, output::String, concrete_d
return io
end

@assert precompile(create_expr_cache, (PkgId, String, String, typeof(_concrete_dependencies)))
@assert precompile(create_expr_cache, (PkgId, String, String, typeof(_concrete_dependencies)))
@assert precompile(create_expr_cache, (PkgId, String, String, typeof(_concrete_dependencies), Bool))
@assert precompile(create_expr_cache, (PkgId, String, String, typeof(_concrete_dependencies), Bool))

function compilecache_path(pkg::PkgId)::String
entrypath, entryfile = cache_file_entry(pkg)
Expand Down Expand Up @@ -1223,7 +1223,8 @@ end

const MAX_NUM_PRECOMPILE_FILES = 10

function compilecache(pkg::PkgId, path::String)
# `show_errors` is an "internal" interface for Pkg.precompile
function compilecache(pkg::PkgId, path::String, show_errors::Bool = true)
# decide where to put the resulting cache file
cachefile = compilecache_path(pkg)
cachepath = dirname(cachefile)
Expand Down Expand Up @@ -1253,7 +1254,7 @@ function compilecache(pkg::PkgId, path::String)
local p
try
close(tmpio)
p = create_expr_cache(pkg, path, tmppath, concrete_deps)
p = create_expr_cache(pkg, path, tmppath, concrete_deps, show_errors)
if success(p)
# append checksum to the end of the .ji file:
open(tmppath, "a+") do f
Expand Down

0 comments on commit 03ec50d

Please sign in to comment.