Skip to content

Commit 03ec50d

Browse files
Allow hiding stderr during compilecache (#37596)
1 parent b18647e commit 03ec50d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

base/loading.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ end
11521152
@assert precompile(include_package_for_output, (PkgId,String,Vector{String},Vector{String},Vector{String},typeof(_concrete_dependencies),Nothing))
11531153
@assert precompile(include_package_for_output, (PkgId,String,Vector{String},Vector{String},Vector{String},typeof(_concrete_dependencies),String))
11541154

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

1192-
@assert precompile(create_expr_cache, (PkgId, String, String, typeof(_concrete_dependencies)))
1193-
@assert precompile(create_expr_cache, (PkgId, String, String, typeof(_concrete_dependencies)))
1192+
@assert precompile(create_expr_cache, (PkgId, String, String, typeof(_concrete_dependencies), Bool))
1193+
@assert precompile(create_expr_cache, (PkgId, String, String, typeof(_concrete_dependencies), Bool))
11941194

11951195
function compilecache_path(pkg::PkgId)::String
11961196
entrypath, entryfile = cache_file_entry(pkg)
@@ -1223,7 +1223,8 @@ end
12231223

12241224
const MAX_NUM_PRECOMPILE_FILES = 10
12251225

1226-
function compilecache(pkg::PkgId, path::String)
1226+
# `show_errors` is an "internal" interface for Pkg.precompile
1227+
function compilecache(pkg::PkgId, path::String, show_errors::Bool = true)
12271228
# decide where to put the resulting cache file
12281229
cachefile = compilecache_path(pkg)
12291230
cachepath = dirname(cachefile)
@@ -1253,7 +1254,7 @@ function compilecache(pkg::PkgId, path::String)
12531254
local p
12541255
try
12551256
close(tmpio)
1256-
p = create_expr_cache(pkg, path, tmppath, concrete_deps)
1257+
p = create_expr_cache(pkg, path, tmppath, concrete_deps, show_errors)
12571258
if success(p)
12581259
# append checksum to the end of the .ji file:
12591260
open(tmppath, "a+") do f

0 commit comments

Comments
 (0)