Skip to content

Commit

Permalink
precompile: collect and show any stderr output as warnings (JuliaLang…
Browse files Browse the repository at this point in the history
…#3319)

(cherry picked from commit 6ad1e79)
  • Loading branch information
IanButterworth committed Feb 1, 2023
1 parent cf68139 commit 87af102
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 @@ -1052,7 +1052,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 @@ -1339,6 +1339,7 @@ function precompile(ctx::Context, pkgs::Vector{PackageSpec}; internal_call::Bool
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 @@ -1422,6 +1423,12 @@ function precompile(ctx::Context, pkgs::Vector{PackageSpec}; internal_call::Bool
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 @@ -1487,6 +1494,16 @@ function precompile(ctx::Context, pkgs::Vector{PackageSpec}; internal_call::Bool
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 87af102

Please sign in to comment.