Skip to content

Commit

Permalink
precompile: collect and show any stderr output as warnings (#3319)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth authored Jan 18, 2023
1 parent 3e70f83 commit 6ad1e79
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ function _is_stale!(stale_cache::Dict, paths::Vector{String}, sourcepath::String
modpaths = Base.find_all_in_cache_path(modkey)
modfound = false
for modpath_to_try in modpaths::Vector{String}
modstaledeps = get!(() -> Base.stale_cachefile(modkey, modbuild_id, modpath, modpath_to_try),
modstaledeps = get!(() -> Base.stale_cachefile(modkey, modbuild_id, modpath, modpath_to_try),
stale_cache, (modkey, modbuild_id, modpath, modpath_to_try))
if modstaledeps === true
continue
Expand Down Expand Up @@ -1336,6 +1336,7 @@ function precompile(ctx::Context, pkgs::Vector{String}=String[]; internal_call::
fancyprint && print(io, ansi_enablecursor)
end
end
stderr_outputs = Dict{Base.PkgId,String}()
tasks = Task[]
Base.LOADING_CACHE[] = Base.LoadingCache()
## precompilation loop
Expand Down Expand Up @@ -1418,6 +1419,12 @@ function precompile(ctx::Context, pkgs::Vector{String}=String[]; internal_call::
else
rethrow(err)
end
else
# otherwise capture any stderr output as warnings
out = strip(String(take!(iob)))
if !isempty(out)
stderr_outputs[pkg] = out
end
finally
Base.release(parallel_limiter)
end
Expand Down Expand Up @@ -1483,6 +1490,16 @@ function precompile(ctx::Context, pkgs::Vector{String}=String[]; internal_call::
print(iostr, "\n ", color_string("$(length(failed_deps))", Base.error_color()), " dependenc$(plural1) errored. ")
print(iostr, "To see a full report either run `import Pkg; Pkg.precompile()` or load the package$(plural2)")
end
if !isempty(stderr_outputs)
plural1 = length(stderr_outputs) == 1 ? "y" : "ies"
plural2 = length(stderr_outputs) == 1 ? "" : "s"
print(iostr, "\n ", color_string("$(length(stderr_outputs))", Base.warn_color()), " dependenc$(plural1) had warnings during precompilation:")
for (pkgid, err) in stderr_outputs
err = join(split(err, "\n"), color_string("\n", Base.warn_color()))
print(iostr, color_string("\n", Base.warn_color()), pkgid, color_string("\n", Base.warn_color()), err)
end
print(iostr, color_string("\n", Base.warn_color()))
end
end
let str=str
lock(print_lock) do
Expand Down

0 comments on commit 6ad1e79

Please sign in to comment.