Skip to content

Commit

Permalink
allow compiling the full manifest if requested
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Mar 19, 2024
1 parent 9f22f65 commit 7dabb21
Showing 1 changed file with 45 additions and 41 deletions.
86 changes: 45 additions & 41 deletions base/precompilation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ function precompilepkgs(pkgs::Vector{String}=String[];
configs::Union{Config,Vector{Config}}=(``=>Base.CacheFlags()),
io::IO=stderr,
# asking for timing disables fancy mode, as timing is shown in non-fancy mode
fancyprint::Bool = can_fancyprint(io) && !timing
)
fancyprint::Bool = can_fancyprint(io) && !timing,
manifest::Bool=false,)

configs = configs isa Config ? [configs] : configs

Expand Down Expand Up @@ -529,53 +529,57 @@ function precompilepkgs(pkgs::Vector{String}=String[];
end
@debug "precompile: circular dep check done"

if isempty(pkgs)
pkgs = [pkg.name for pkg in direct_deps]
target = "all packages"
if !manifest
if isempty(pkgs)
pkgs = [pkg.name for pkg in direct_deps]
target = "all packages"
else
target = join(pkgs, ", ")
end
# restrict to dependencies of given packages
function collect_all_deps(depsmap, dep, alldeps=Set{Base.PkgId}())
for _dep in depsmap[dep]
if !(_dep in alldeps)
push!(alldeps, _dep)
collect_all_deps(depsmap, _dep, alldeps)
end
end
return alldeps
end
keep = Set{Base.PkgId}()
for dep in depsmap
dep_pkgid = first(dep)
if dep_pkgid.name in pkgs
push!(keep, dep_pkgid)
collect_all_deps(depsmap, dep_pkgid, keep)
end
end
for ext in keys(exts)
if issubset(collect_all_deps(depsmap, ext), keep) # if all extension deps are kept
push!(keep, ext)
end
end
filter!(d->in(first(d), keep), depsmap)
if isempty(depsmap)
if _from_loading
# if called from loading precompilation it may be a package from another environment stack so
# don't error and allow serial precompilation to try
# TODO: actually handle packages from other envs in the stack
return
else
return
end
end
else
target = join(pkgs, ", ")
target = "manifest"
end

nconfig = length(configs)
if nconfig > 1
target *= " for $nconfig compilation configurations..."
else
target *= "..."
end

# restrict to dependencies of given packages
function collect_all_deps(depsmap, dep, alldeps=Set{Base.PkgId}())
for _dep in depsmap[dep]
if !(_dep in alldeps)
push!(alldeps, _dep)
collect_all_deps(depsmap, _dep, alldeps)
end
end
return alldeps
end
keep = Set{Base.PkgId}()
for dep in depsmap
dep_pkgid = first(dep)
if dep_pkgid.name in pkgs
push!(keep, dep_pkgid)
collect_all_deps(depsmap, dep_pkgid, keep)
end
end
for ext in keys(exts)
if issubset(collect_all_deps(depsmap, ext), keep) # if all extension deps are kept
push!(keep, ext)
end
end
filter!(d->in(first(d), keep), depsmap)
if isempty(depsmap)
if _from_loading
# if called from loading precompilation it may be a package from another environment stack so
# don't error and allow serial precompilation to try
# TODO: actually handle packages from other envs in the stack
return
else
error("No direct dependencies outside of the sysimage found matching $(repr(pkgs))")
end
end
@debug "precompile: packages filtered"

pkg_queue = PkgConfig[]
Expand Down

0 comments on commit 7dabb21

Please sign in to comment.