|  | 
| 1 | 1 | module Precompilation | 
| 2 | 2 | 
 | 
| 3 |  | -using Base: PkgId, UUID, SHA1, parsed_toml, project_file_name_uuid, project_names, | 
|  | 3 | +using Base: CoreLogging, PkgId, UUID, SHA1, parsed_toml, project_file_name_uuid, project_names, | 
| 4 | 4 |             project_file_manifest_path, get_deps, preferences_names, isaccessibledir, isfile_casesensitive, | 
| 5 | 5 |             base_project, isdefined | 
| 6 | 6 | 
 | 
| @@ -532,9 +532,16 @@ function _precompilepkgs(pkgs::Union{Vector{String}, Vector{PkgId}}, | 
| 532 | 532 |     num_tasks = parse(Int, get(ENV, "JULIA_NUM_PRECOMPILE_TASKS", string(default_num_tasks))) | 
| 533 | 533 |     parallel_limiter = Base.Semaphore(num_tasks) | 
| 534 | 534 | 
 | 
| 535 |  | -    # suppress passive loading printing in julia test suite. `JULIA_TESTS` is set in Base.runtests | 
| 536 |  | -    io = (_from_loading && !Sys.isinteractive() && Base.get_bool_env("JULIA_TESTS", false)) ? IOContext{IO}(devnull) : _io | 
| 537 |  | - | 
|  | 535 | +    # suppress precompilation progress messages when precompiling for loading packages, except during interactive sessions | 
|  | 536 | +    # or when specified by logging heuristics that explicitly require it | 
|  | 537 | +    # since the complicated IO implemented here can have somewhat disastrous consequences when happening in the background (e.g. #59599) | 
|  | 538 | +    io = _io | 
|  | 539 | +    logcalls = nothing | 
|  | 540 | +    if _from_loading && !isinteractive() | 
|  | 541 | +        io = IOContext{IO}(devnull) | 
|  | 542 | +        fancyprint = false | 
|  | 543 | +        logcalls = isinteractive() ? CoreLogging.Info : CoreLogging.Debug # sync with Base.compilecache | 
|  | 544 | +    end | 
| 538 | 545 | 
 | 
| 539 | 546 |     nconfigs = length(configs) | 
| 540 | 547 |     hascolor = get(io, :color, false)::Bool | 
| @@ -608,8 +615,6 @@ function _precompilepkgs(pkgs::Union{Vector{String}, Vector{PkgId}}, | 
| 608 | 615 |     # consider exts of project deps to be project deps so that errors are reported | 
| 609 | 616 |     append!(project_deps, keys(filter(d->last(d).name in keys(env.project_deps), ext_to_parent))) | 
| 610 | 617 | 
 | 
| 611 |  | -    @debug "precompile: deps collected" | 
| 612 |  | - | 
| 613 | 618 |     # An extension effectively depends on another extension if it has a strict superset of its triggers | 
| 614 | 619 |     for ext_a in keys(ext_to_parent) | 
| 615 | 620 |         for ext_b in keys(ext_to_parent) | 
| @@ -664,7 +669,6 @@ function _precompilepkgs(pkgs::Union{Vector{String}, Vector{PkgId}}, | 
| 664 | 669 |             end | 
| 665 | 670 |         end | 
| 666 | 671 |     end | 
| 667 |  | -    @debug "precompile: extensions collected" | 
| 668 | 672 | 
 | 
| 669 | 673 |     serial_deps = Base.PkgId[] # packages that are being precompiled in serial | 
| 670 | 674 | 
 | 
| @@ -704,7 +708,6 @@ function _precompilepkgs(pkgs::Union{Vector{String}, Vector{PkgId}}, | 
| 704 | 708 |             was_recompiled[pkg_config] = false | 
| 705 | 709 |         end | 
| 706 | 710 |     end | 
| 707 |  | -    @debug "precompile: signalling initialized" | 
| 708 | 711 | 
 | 
| 709 | 712 |     # find and guard against circular deps | 
| 710 | 713 |     cycles = Vector{Base.PkgId}[] | 
| @@ -732,7 +735,6 @@ function _precompilepkgs(pkgs::Union{Vector{String}, Vector{PkgId}}, | 
| 732 | 735 |     if !isempty(circular_deps) | 
| 733 | 736 |         @warn excluded_circular_deps_explanation(io, ext_to_parent, circular_deps, cycles) | 
| 734 | 737 |     end | 
| 735 |  | -    @debug "precompile: circular dep check done" | 
| 736 | 738 | 
 | 
| 737 | 739 |     # If you have a workspace and want to precompile all projects in it, look through all packages in the manifest | 
| 738 | 740 |     # instead of collecting from a project i.e. not filter out packages that are in the current project. | 
| @@ -785,7 +787,6 @@ function _precompilepkgs(pkgs::Union{Vector{String}, Vector{PkgId}}, | 
| 785 | 787 |     else | 
| 786 | 788 |         target[] = "for $nconfigs compilation configurations..." | 
| 787 | 789 |     end | 
| 788 |  | -    @debug "precompile: packages filtered" | 
| 789 | 790 | 
 | 
| 790 | 791 |     pkg_queue = PkgConfig[] | 
| 791 | 792 |     failed_deps = Dict{PkgConfig, String}() | 
| @@ -1013,16 +1014,23 @@ function _precompilepkgs(pkgs::Union{Vector{String}, Vector{PkgId}}, | 
| 1013 | 1014 |                             return | 
| 1014 | 1015 |                         end | 
| 1015 | 1016 |                         try | 
| 1016 |  | -                            # allows processes to wait if another process is precompiling a given package to | 
| 1017 |  | -                            # a functionally identical package cache (except for preferences, which may differ) | 
| 1018 |  | -                            t = @elapsed ret = precompile_pkgs_maybe_cachefile_lock(io, print_lock, fancyprint, pkg_config, pkgspidlocked, hascolor, parallel_limiter, ignore_loaded) do | 
| 1019 |  | -                                Base.with_logger(Base.NullLogger()) do | 
| 1020 |  | -                                    # whether to respect already loaded dependency versions | 
| 1021 |  | -                                    keep_loaded_modules = !ignore_loaded | 
| 1022 |  | -                                    # for extensions, any extension in our direct dependencies is one we have a right to load | 
| 1023 |  | -                                    # for packages, we may load any extension (all possible triggers are accounted for above) | 
| 1024 |  | -                                    loadable_exts = haskey(ext_to_parent, pkg) ? filter((dep)->haskey(ext_to_parent, dep), direct_deps[pkg]) : nothing | 
| 1025 |  | -                                    Base.compilecache(pkg, sourcepath, std_pipe, std_pipe, keep_loaded_modules; | 
|  | 1017 | +                            # for extensions, any extension in our direct dependencies is one we have a right to load | 
|  | 1018 | +                            # for packages, we may load any extension (all possible triggers are accounted for above) | 
|  | 1019 | +                            loadable_exts = haskey(ext_to_parent, pkg) ? filter((dep)->haskey(ext_to_parent, dep), direct_deps[pkg]) : nothing | 
|  | 1020 | +                            if _from_loading && pkg in requested_pkgids | 
|  | 1021 | +                                # loading already took the cachefile_lock and printed logmsg for its explicit requests | 
|  | 1022 | +                                t = @elapsed ret = begin | 
|  | 1023 | +                                    Base.compilecache(pkg, sourcepath, std_pipe, std_pipe, !ignore_loaded; | 
|  | 1024 | +                                                      flags, cacheflags, loadable_exts) | 
|  | 1025 | +                                end | 
|  | 1026 | +                            else | 
|  | 1027 | +                                # allows processes to wait if another process is precompiling a given package to | 
|  | 1028 | +                                # a functionally identical package cache (except for preferences, which may differ) | 
|  | 1029 | +                                t = @elapsed ret = precompile_pkgs_maybe_cachefile_lock(io, print_lock, fancyprint, pkg_config, pkgspidlocked, hascolor, parallel_limiter, ignore_loaded) do | 
|  | 1030 | +                                    logcalls === nothing || @lock print_lock begin | 
|  | 1031 | +                                        Base.@logmsg logcalls "Precompiling $(repr("text/plain", pkg))" | 
|  | 1032 | +                                    end | 
|  | 1033 | +                                    Base.compilecache(pkg, sourcepath, std_pipe, std_pipe, !ignore_loaded; | 
| 1026 | 1034 |                                                       flags, cacheflags, loadable_exts) | 
| 1027 | 1035 |                                 end | 
| 1028 | 1036 |                             end | 
|  | 
0 commit comments