Skip to content

Commit a7348b7

Browse files
authored
Merge pull request #49680 from JuliaLang/backports-release-1.9
Backports for julia 1.9.1
2 parents 8e63055 + 295b503 commit a7348b7

File tree

46 files changed

+424
-188
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+424
-188
lines changed

base/binaryplatforms.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,19 +1015,19 @@ function platforms_match(a::AbstractPlatform, b::AbstractPlatform)
10151015

10161016
# Throw an error if `a` and `b` have both set non-default comparison strategies for `k`
10171017
# and they're not the same strategy.
1018-
if a_comp != compare_default && b_comp != compare_default && a_comp != b_comp
1018+
if a_comp !== compare_default && b_comp !== compare_default && a_comp !== b_comp
10191019
throw(ArgumentError("Cannot compare Platform objects with two different non-default comparison strategies for the same key \"$(k)\""))
10201020
end
10211021

10221022
# Select the custom comparator, if we have one.
10231023
comparator = a_comp
1024-
if b_comp != compare_default
1024+
if b_comp !== compare_default
10251025
comparator = b_comp
10261026
end
10271027

10281028
# Call the comparator, passing in which objects requested this comparison (one, the other, or both)
10291029
# For some comparators this doesn't matter, but for non-symmetrical comparisons, it does.
1030-
if !(comparator(ak, bk, a_comp == comparator, b_comp == comparator)::Bool)
1030+
if !(comparator(ak, bk, a_comp === comparator, b_comp === comparator)::Bool)
10311031
return false
10321032
end
10331033
end
@@ -1073,7 +1073,9 @@ function select_platform(download_info::Dict, platform::AbstractPlatform = HostP
10731073
# of generally choosing the latest release (e.g. a `libgfortran5` tarball
10741074
# rather than a `libgfortran3` tarball)
10751075
p = last(sort(ps, by = p -> triplet(p)))
1076-
return download_info[p]
1076+
1077+
# @invokelatest here to not get invalidated by new defs of `==(::Function, ::Function)`
1078+
return @invokelatest getindex(download_info, p)
10771079
end
10781080

10791081
# precompiles to reduce latency (see https://github.com/JuliaLang/julia/pull/43990#issuecomment-1025692379)

base/channels.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ Close a channel. An exception (optionally given by `excp`), is thrown by:
183183
* [`put!`](@ref) on a closed channel.
184184
* [`take!`](@ref) and [`fetch`](@ref) on an empty, closed channel.
185185
"""
186-
function close(c::Channel, excp::Exception=closed_exception())
186+
close(c::Channel) = close(c, closed_exception()) # nospecialize on default arg seems to confuse makedocs
187+
function close(c::Channel, @nospecialize(excp::Exception))
187188
lock(c)
188189
try
189190
c.excp = excp

base/initdefs.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ end
353353
const atexit_hooks = Callable[
354354
() -> Filesystem.temp_cleanup_purge(force=true)
355355
]
356+
const _atexit_hooks_lock = ReentrantLock()
356357

357358
"""
358359
atexit(f)
@@ -374,7 +375,7 @@ calls `exit(n)`, then Julia will exit with the exit code corresponding to the
374375
last called exit hook that calls `exit(n)`. (Because exit hooks are called in
375376
LIFO order, "last called" is equivalent to "first registered".)
376377
"""
377-
atexit(f::Function) = (pushfirst!(atexit_hooks, f); nothing)
378+
atexit(f::Function) = Base.@lock _atexit_hooks_lock (pushfirst!(atexit_hooks, f); nothing)
378379

379380
function _atexit(exitcode::Cint)
380381
while !isempty(atexit_hooks)

base/loading.jl

Lines changed: 70 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,9 @@ function locate_package_env(pkg::PkgId, stopenv::Union{String, Nothing}=nothing)
413413
@goto done
414414
end
415415
end
416-
stopenv == env && @goto done
416+
if !(loading_extension || precompiling_extension)
417+
stopenv == env && @goto done
418+
end
417419
end
418420
else
419421
for env in load_path()
@@ -428,7 +430,9 @@ function locate_package_env(pkg::PkgId, stopenv::Union{String, Nothing}=nothing)
428430
path = entry_path(path, pkg.name)
429431
@goto done
430432
end
431-
stopenv == env && break
433+
if !(loading_extension || precompiling_extension)
434+
stopenv == env && break
435+
end
432436
end
433437
# Allow loading of stdlibs if the name/uuid are given
434438
# e.g. if they have been explicitly added to the project/manifest
@@ -619,6 +623,24 @@ function manifest_deps_get(env::String, where::PkgId, name::String)::Union{Nothi
619623
pkg_uuid = explicit_project_deps_get(project_file, name)
620624
return PkgId(pkg_uuid, name)
621625
end
626+
d = parsed_toml(project_file)
627+
exts = get(d, "extensions", nothing)::Union{Dict{String, Any}, Nothing}
628+
if exts !== nothing
629+
# Check if `where` is an extension of the project
630+
if where.name in keys(exts) && where.uuid == uuid5(proj.uuid::UUID, where.name)
631+
# Extensions can load weak deps...
632+
weakdeps = get(d, "weakdeps", nothing)::Union{Dict{String, Any}, Nothing}
633+
if weakdeps !== nothing
634+
wuuid = get(weakdeps, name, nothing)::Union{String, Nothing}
635+
if wuuid !== nothing
636+
return PkgId(UUID(wuuid), name)
637+
end
638+
end
639+
# ... and they can load same deps as the project itself
640+
mby_uuid = explicit_project_deps_get(project_file, name)
641+
mby_uuid === nothing || return PkgId(mby_uuid, name)
642+
end
643+
end
622644
# look for manifest file and `where` stanza
623645
return explicit_manifest_deps_get(project_file, where, name)
624646
elseif project_file
@@ -636,6 +658,8 @@ function manifest_uuid_path(env::String, pkg::PkgId)::Union{Nothing,String,Missi
636658
# if `pkg` matches the project, return the project itself
637659
return project_file_path(project_file)
638660
end
661+
mby_ext = project_file_ext_path(project_file, pkg.name)
662+
mby_ext === nothing || return mby_ext
639663
# look for manifest file and `where` stanza
640664
return explicit_manifest_uuid_path(project_file, pkg)
641665
elseif project_file
@@ -645,6 +669,25 @@ function manifest_uuid_path(env::String, pkg::PkgId)::Union{Nothing,String,Missi
645669
return nothing
646670
end
647671

672+
673+
function find_ext_path(project_path::String, extname::String)
674+
extfiledir = joinpath(project_path, "ext", extname, extname * ".jl")
675+
isfile(extfiledir) && return extfiledir
676+
return joinpath(project_path, "ext", extname * ".jl")
677+
end
678+
679+
function project_file_ext_path(project_file::String, name::String)
680+
d = parsed_toml(project_file)
681+
p = project_file_path(project_file)
682+
exts = get(d, "extensions", nothing)::Union{Dict{String, Any}, Nothing}
683+
if exts !== nothing
684+
if name in keys(exts)
685+
return find_ext_path(p, name)
686+
end
687+
end
688+
return nothing
689+
end
690+
648691
# find project file's top-level UUID entry (or nothing)
649692
function project_file_name_uuid(project_file::String, name::String)::PkgId
650693
d = parsed_toml(project_file)
@@ -747,10 +790,10 @@ function explicit_project_deps_get(project_file::String, name::String)::Union{No
747790
return nothing
748791
end
749792

750-
function is_v1_format_manifest(raw_manifest::Dict)
793+
function is_v1_format_manifest(raw_manifest::Dict{String})
751794
if haskey(raw_manifest, "manifest_format")
752795
mf = raw_manifest["manifest_format"]
753-
if mf isa Dict && haskey(mf, "uuid")
796+
if mf isa Dict{String} && haskey(mf, "uuid")
754797
# the off-chance where an old format manifest has a dep called "manifest_format"
755798
return true
756799
end
@@ -876,9 +919,7 @@ function explicit_manifest_uuid_path(project_file::String, pkg::PkgId)::Union{No
876919
error("failed to find source of parent package: \"$name\"")
877920
end
878921
p = normpath(dirname(parent_path), "..")
879-
extfiledir = joinpath(p, "ext", pkg.name, pkg.name * ".jl")
880-
isfile(extfiledir) && return extfiledir
881-
return joinpath(p, "ext", pkg.name * ".jl")
922+
return find_ext_path(p, pkg.name)
882923
end
883924
end
884925
end
@@ -1126,6 +1167,20 @@ end
11261167
function insert_extension_triggers(env::String, pkg::PkgId)::Union{Nothing,Missing}
11271168
project_file = env_project_file(env)
11281169
if project_file isa String
1170+
# Look in project for extensions to insert
1171+
proj_pkg = project_file_name_uuid(project_file, pkg.name)
1172+
if pkg == proj_pkg
1173+
d_proj = parsed_toml(project_file)
1174+
weakdeps = get(d_proj, "weakdeps", nothing)::Union{Nothing, Vector{String}, Dict{String,Any}}
1175+
extensions = get(d_proj, "extensions", nothing)::Union{Nothing, Dict{String, Any}}
1176+
extensions === nothing && return
1177+
weakdeps === nothing && return
1178+
if weakdeps isa Dict{String, Any}
1179+
return _insert_extension_triggers(pkg, extensions, weakdeps)
1180+
end
1181+
end
1182+
1183+
# Now look in manifest
11291184
manifest_file = project_file_manifest_path(project_file)
11301185
manifest_file === nothing && return
11311186
d = get_deps(parsed_toml(manifest_file))
@@ -1144,7 +1199,7 @@ function insert_extension_triggers(env::String, pkg::PkgId)::Union{Nothing,Missi
11441199
return _insert_extension_triggers(pkg, extensions, weakdeps)
11451200
end
11461201

1147-
d_weakdeps = Dict{String, String}()
1202+
d_weakdeps = Dict{String, Any}()
11481203
for (dep_name, entries) in d
11491204
dep_name in weakdeps || continue
11501205
entries::Vector{Any}
@@ -1164,8 +1219,9 @@ function insert_extension_triggers(env::String, pkg::PkgId)::Union{Nothing,Missi
11641219
return nothing
11651220
end
11661221

1167-
function _insert_extension_triggers(parent::PkgId, extensions::Dict{String, <:Any}, weakdeps::Dict{String, <:Any})
1168-
for (ext::String, triggers::Union{String, Vector{String}}) in extensions
1222+
function _insert_extension_triggers(parent::PkgId, extensions::Dict{String, Any}, weakdeps::Dict{String, Any})
1223+
for (ext, triggers) in extensions
1224+
triggers = triggers::Union{String, Vector{String}}
11691225
triggers isa String && (triggers = [triggers])
11701226
id = PkgId(uuid5(parent.uuid, ext), ext)
11711227
if id in keys(EXT_PRIMED) || haskey(Base.loaded_modules, id)
@@ -1190,6 +1246,7 @@ function _insert_extension_triggers(parent::PkgId, extensions::Dict{String, <:An
11901246
end
11911247

11921248
loading_extension::Bool = false
1249+
precompiling_extension::Bool = false
11931250
function run_extension_callbacks(extid::ExtensionId)
11941251
assert_havelock(require_lock)
11951252
succeeded = try
@@ -1217,30 +1274,8 @@ function run_extension_callbacks(pkgid::PkgId)
12171274
extids === nothing && return
12181275
for extid in extids
12191276
if extid.ntriggers > 0
1220-
# It is possible that pkgid was loaded in an environment
1221-
# below the one of the parent. This will cause a load failure when the
1222-
# pkg ext tries to load the triggers. Therefore, check this first
1223-
# before loading the pkg ext.
1224-
pkgenv = identify_package_env(extid.id, pkgid.name)
1225-
ext_not_allowed_load = false
1226-
if pkgenv === nothing
1227-
ext_not_allowed_load = true
1228-
else
1229-
pkg, env = pkgenv
1230-
path = locate_package(pkg, env)
1231-
if path === nothing
1232-
ext_not_allowed_load = true
1233-
end
1234-
end
1235-
if ext_not_allowed_load
1236-
@debug "Extension $(extid.id.name) of $(extid.parentid.name) will not be loaded \
1237-
since $(pkgid.name) loaded in environment lower in load path"
1238-
# indicate extid is expected to fail
1239-
extid.ntriggers *= -1
1240-
else
1241-
# indicate pkgid is loaded
1242-
extid.ntriggers -= 1
1243-
end
1277+
# indicate pkgid is loaded
1278+
extid.ntriggers -= 1
12441279
end
12451280
if extid.ntriggers < 0
12461281
# indicate pkgid is loaded
@@ -2066,6 +2101,7 @@ function create_expr_cache(pkg::PkgId, input::String, output::String, output_o::
20662101
# write data over stdin to avoid the (unlikely) case of exceeding max command line size
20672102
write(io.in, """
20682103
empty!(Base.EXT_DORMITORY) # If we have a custom sysimage with `EXT_DORMITORY` prepopulated
2104+
Base.precompiling_extension = $(loading_extension)
20692105
Base.include_package_for_output($(pkg_str(pkg)), $(repr(abspath(input))), $(repr(depot_path)), $(repr(dl_load_path)),
20702106
$(repr(load_path)), $deps, $(repr(source_path(nothing))))
20712107
""")

base/mpfr.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ function _string(x::BigFloat, fmt::String)::String
10281028
isfinite(x) || return string(Float64(x))
10291029
_prettify_bigfloat(string_mpfr(x, fmt))
10301030
end
1031-
_string(x::BigFloat) = _string(x, "%.Re")
1031+
_string(x::BigFloat) = _string(x, "%Re")
10321032
_string(x::BigFloat, k::Integer) = _string(x, "%.$(k)Re")
10331033

10341034
string(b::BigFloat) = _string(b)

base/range.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ show(io::IO, r::AbstractRange) = print(io, repr(first(r)), ':', repr(step(r)), '
10931093
show(io::IO, r::UnitRange) = print(io, repr(first(r)), ':', repr(last(r)))
10941094
show(io::IO, r::OneTo) = print(io, "Base.OneTo(", r.stop, ")")
10951095
function show(io::IO, r::StepRangeLen)
1096-
if step(r) != 0
1096+
if !iszero(step(r))
10971097
print(io, repr(first(r)), ':', repr(step(r)), ':', repr(last(r)))
10981098
else
10991099
# ugly temporary printing, to avoid 0:0:0 etc.

base/reinterpretarray.jl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -725,11 +725,18 @@ end
725725
@assume_effects :total function array_subpadding(S, T)
726726
lcm_size = lcm(sizeof(S), sizeof(T))
727727
s, t = CyclePadding(S), CyclePadding(T)
728-
isempty(t) && return true
729-
isempty(s) && return false
730728
checked_size = 0
731-
ps, sstate = iterate(s) # use of Stateful harms inference and makes this vulnerable to invalidation
732-
pad, tstate = iterate(t)
729+
# use of Stateful harms inference and makes this vulnerable to invalidation
730+
(pad, tstate) = let
731+
it = iterate(t)
732+
it === nothing && return true
733+
it
734+
end
735+
(ps, sstate) = let
736+
it = iterate(s)
737+
it === nothing && return false
738+
it
739+
end
733740
while checked_size < lcm_size
734741
while true
735742
# See if there's corresponding padding in S

cli/loader_lib.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ static char *libstdcxxprobe(void)
329329
free(path);
330330
return NULL;
331331
}
332+
// Ensure that `path` is zero-terminated.
333+
path[pathlen] = '\0';
332334
return path;
333335
}
334336
}

contrib/generate_precompile.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ precompile(Tuple{typeof(push!), Vector{Function}, Function})
3434
# miscellaneous
3535
precompile(Tuple{typeof(Base.require), Base.PkgId})
3636
precompile(Tuple{typeof(Base.recursive_prefs_merge), Base.Dict{String, Any}})
37+
precompile(Tuple{typeof(Base.hashindex), Tuple{Base.PkgId, Nothing}, Int64})
38+
precompile(Tuple{typeof(Base.hashindex), Tuple{Base.PkgId, String}, Int64})
3739
precompile(Tuple{typeof(isassigned), Core.SimpleVector, Int})
3840
precompile(Tuple{typeof(getindex), Core.SimpleVector, Int})
3941
precompile(Tuple{typeof(Base.Experimental.register_error_hint), Any, Type})

deps/blastrampoline.version

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
BLASTRAMPOLINE_JLL_NAME := libblastrampoline
33

44
## source build
5-
BLASTRAMPOLINE_VER := 5.7.0
6-
BLASTRAMPOLINE_BRANCH=v5.7.0
7-
BLASTRAMPOLINE_SHA1=2272604bfb10b9e8a3ae5f1a4569899b99251a65
5+
BLASTRAMPOLINE_VER := 5.8.0
6+
BLASTRAMPOLINE_BRANCH=v5.8.0
7+
BLASTRAMPOLINE_SHA1=81316155d4838392e8462a92bcac3eebe9acd0c7

0 commit comments

Comments
 (0)