Skip to content

Commit 50a7a55

Browse files
authored
Merge pull request #44189 from JuliaLang/backports-release-1.7
Backports for 1.7.3
2 parents 857b62d + 86e06d3 commit 50a7a55

Some content is hidden

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

64 files changed

+697
-325
lines changed

Make.inc

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# -*- mode: makefile-gmake -*-
1+
# -*- mode: makefile -*-
22
# vi:syntax=make
33

44
## Note:
@@ -1172,7 +1172,7 @@ endif
11721172

11731173
# Auto-detect triplet once, create different versions that we use as defaults below for each BB install target
11741174
FC_VERSION := $(shell $(FC) --version 2>/dev/null | head -1)
1175-
FC_OR_CC_VERISON := $(or $(FC_VERSION),$(shell $(CC) --version 2>/dev/null | head -1))
1175+
FC_OR_CC_VERSION := $(or $(FC_VERSION),$(shell $(CC) --version 2>/dev/null | head -1))
11761176
BB_TRIPLET_LIBGFORTRAN_CXXABI := $(shell $(call invoke_python,$(JULIAHOME)/contrib/normalize_triplet.py) $(or $(XC_HOST),$(XC_HOST),$(BUILD_MACHINE)) "$(FC_OR_CC_VERSION)" "$(or $(shell echo '\#include <string>' | $(CXX) $(CXXFLAGS) -x c++ -dM -E - | grep _GLIBCXX_USE_CXX11_ABI | awk '{ print $$3 }' ),1)")
11771177
BB_TRIPLET_LIBGFORTRAN := $(subst $(SPACE),-,$(filter-out cxx%,$(subst -,$(SPACE),$(BB_TRIPLET_LIBGFORTRAN_CXXABI))))
11781178
BB_TRIPLET_CXXABI := $(subst $(SPACE),-,$(filter-out libgfortran%,$(subst -,$(SPACE),$(BB_TRIPLET_LIBGFORTRAN_CXXABI))))
@@ -1507,7 +1507,7 @@ endif
15071507
endif
15081508
ifeq ($(OS),Darwin)
15091509
ifeq ($(ARCH),aarch64)
1510-
LIBGCC_NAME := libgcc_s.2.$(SHLIB_EXT)
1510+
LIBGCC_NAME := libgcc_s.1.1.$(SHLIB_EXT)
15111511
else
15121512
LIBGCC_NAME := libgcc_s.1.$(SHLIB_EXT)
15131513
endif

Makefile

+13-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ $(BUILDROOT)/doc/_build/html/en/index.html: $(shell find $(BUILDROOT)/base $(BUI
4848

4949
julia-symlink: julia-cli-$(JULIA_BUILD_MODE)
5050
ifeq ($(OS),WINNT)
51-
@echo '@"%~dp0\'"$$(echo $(call rel_path,$(BUILDROOT),$(JULIA_EXECUTABLE)) | tr / '\\')"\" '%*' > $(BUILDROOT)/julia.bat
51+
echo '@"%~dp0/'"$$(echo '$(call rel_path,$(BUILDROOT),$(JULIA_EXECUTABLE))')"'" %*' | tr / '\\' > $(BUILDROOT)/julia.bat
5252
chmod a+x $(BUILDROOT)/julia.bat
5353
else
5454
ifndef JULIA_VAGRANT_BUILD
@@ -433,9 +433,21 @@ ifeq ($(OS), Linux)
433433
endif
434434
ifeq ($(OS), WINNT)
435435
cd $(BUILDROOT)/julia-$(JULIA_COMMIT)/bin && rm -f llvm* llc.exe lli.exe opt.exe LTO.dll bugpoint.exe macho-dump.exe
436+
endif
437+
# If we're on macOS, and we have a codesigning identity, then codesign the binary-dist tarball!
438+
ifeq ($(OS),Darwin)
439+
ifneq ($(MACOS_CODESIGN_IDENTITY),)
440+
echo "Codesigning with identity $(MACOS_CODESIGN_IDENTITY)"; \
441+
MACHO_FILES=$$(find "$(BUILDROOT)/julia-$(JULIA_COMMIT)" -type f -perm -0111 | cut -d: -f1); \
442+
for f in $${MACHO_FILES}; do \
443+
echo "Codesigning $${f}..."; \
444+
codesign -s "$(MACOS_CODESIGN_IDENTITY)" --option=runtime --entitlements $(JULIAHOME)/contrib/mac/app/Entitlements.plist -vvv --timestamp --deep --force "$${f}"; \
445+
done
446+
endif
436447
endif
437448
cd $(BUILDROOT) && $(TAR) zcvf $(JULIA_BINARYDIST_FILENAME).tar.gz julia-$(JULIA_COMMIT)
438449

450+
439451
exe:
440452
# run Inno Setup to compile installer
441453
$(call spawn,$(JULIAHOME)/dist-extras/inno/iscc.exe /DAppVersion=$(JULIA_VERSION) /DSourceDir="$(call cygpath_w,$(BUILDROOT)/julia-$(JULIA_COMMIT))" /DRepoDir="$(call cygpath_w,$(JULIAHOME))" /F"$(JULIA_BINARYDIST_FILENAME)" /O"$(call cygpath_w,$(BUILDROOT))" $(INNO_ARGS) $(call cygpath_w,$(JULIAHOME)/contrib/windows/build-installer.iss))

base/Base.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,6 @@ include("weakkeydict.jl")
275275

276276
include("env.jl")
277277

278-
# BinaryPlatforms, used by Artifacts
279-
include("binaryplatforms.jl")
280-
281278
# functions defined in Random
282279
function rand end
283280
function randn end
@@ -332,6 +329,9 @@ using .Order
332329
include("sort.jl")
333330
using .Sort
334331

332+
# BinaryPlatforms, used by Artifacts. Needs `Sort`.
333+
include("binaryplatforms.jl")
334+
335335
# Fast math
336336
include("fastmath.jl")
337337
using .FastMath

base/Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,11 @@ else ifneq ($(USE_SYSTEM_OPENLIBM),0)
206206
$(eval $(call symlink_system_library,OPENLIBM,$(LIBMNAME)))
207207
endif
208208

209+
ifeq ($(APPLE_ARCH),arm64)
210+
$(eval $(call symlink_system_library,CSL,libgcc_s,1.1))
211+
else
209212
$(eval $(call symlink_system_library,CSL,libgcc_s,1))
213+
endif
210214
ifneq (,$(LIBGFORTRAN_VERSION))
211215
$(eval $(call symlink_system_library,CSL,libgfortran,$(LIBGFORTRAN_VERSION)))
212216
endif

base/abstractarray.jl

+18
Original file line numberDiff line numberDiff line change
@@ -2315,6 +2315,24 @@ function _typed_hvncat_dims(::Type{T}, dims::NTuple{N, Int}, row_first::Bool, as
23152315

23162316
outdims = zeros(Int, N)
23172317

2318+
# validate shapes for lowest level of concatenation
2319+
d = findfirst(>(1), dims)
2320+
if d !== nothing # all dims are 1
2321+
nblocks = length(as) ÷ dims[d]
2322+
for b 1:nblocks
2323+
offset = ((b - 1) * dims[d])
2324+
startelementi = offset + 1
2325+
for i offset .+ (2:dims[d])
2326+
for dd 1:N
2327+
dd == d && continue
2328+
if size(as[startelementi], dd) != size(as[i], dd)
2329+
throw(ArgumentError("incompatible shape in element $i"))
2330+
end
2331+
end
2332+
end
2333+
end
2334+
end
2335+
23182336
# discover number of rows or columns
23192337
for i 1:dims[d1]
23202338
outdims[d1] += cat_size(as[i], d1)

base/abstractdict.jl

+4-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,10 @@ empty(a::AbstractDict) = empty(a, keytype(a), valtype(a))
155155
empty(a::AbstractDict, ::Type{V}) where {V} = empty(a, keytype(a), V) # Note: this is the form which makes sense for `Vector`.
156156

157157
copy(a::AbstractDict) = merge!(empty(a), a)
158-
copy!(dst::AbstractDict, src::AbstractDict) = merge!(empty!(dst), src)
158+
function copy!(dst::AbstractDict, src::AbstractDict)
159+
dst === src && return dst
160+
merge!(empty!(dst), src)
161+
end
159162

160163
"""
161164
merge!(d::AbstractDict, others::AbstractDict...)

base/abstractset.jl

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
eltype(::Type{<:AbstractSet{T}}) where {T} = @isdefined(T) ? T : Any
44
sizehint!(s::AbstractSet, n) = nothing
55

6-
copy!(dst::AbstractSet, src::AbstractSet) = union!(empty!(dst), src)
6+
function copy!(dst::AbstractSet, src::AbstractSet)
7+
dst === src && return dst
8+
union!(empty!(dst), src)
9+
end
710

811
## set operations (union, intersection, symmetric difference)
912

base/asyncevent.jl

+46-26
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,22 @@ the async condition object itself.
4343
"""
4444
function AsyncCondition(cb::Function)
4545
async = AsyncCondition()
46-
t = @task while _trywait(async)
47-
cb(async)
48-
isopen(async) || return
46+
t = @task begin
47+
unpreserve_handle(async)
48+
while _trywait(async)
49+
cb(async)
50+
isopen(async) || return
51+
end
52+
end
53+
# here we are mimicking parts of _trywait, in coordination with task `t`
54+
preserve_handle(async)
55+
@lock async.cond begin
56+
if async.set
57+
schedule(t)
58+
else
59+
_wait2(async.cond, t)
60+
end
4961
end
50-
lock(async.cond)
51-
_wait2(async.cond, t)
52-
unlock(async.cond)
5362
return async
5463
end
5564

@@ -103,7 +112,11 @@ unsafe_convert(::Type{Ptr{Cvoid}}, async::AsyncCondition) = async.handle
103112

104113
function _trywait(t::Union{Timer, AsyncCondition})
105114
set = t.set
106-
if !set
115+
if set
116+
# full barrier now for AsyncCondition
117+
t isa Timer || Core.Intrinsics.atomic_fence(:acquire_release)
118+
else
119+
t.isopen || return false
107120
t.handle == C_NULL && return false
108121
iolock_begin()
109122
set = t.set
@@ -112,14 +125,12 @@ function _trywait(t::Union{Timer, AsyncCondition})
112125
lock(t.cond)
113126
try
114127
set = t.set
115-
if !set
116-
if t.handle != C_NULL
117-
iolock_end()
118-
set = wait(t.cond)
119-
unlock(t.cond)
120-
iolock_begin()
121-
lock(t.cond)
122-
end
128+
if !set && t.isopen && t.handle != C_NULL
129+
iolock_end()
130+
set = wait(t.cond)
131+
unlock(t.cond)
132+
iolock_begin()
133+
lock(t.cond)
123134
end
124135
finally
125136
unlock(t.cond)
@@ -255,19 +266,28 @@ julia> begin
255266
"""
256267
function Timer(cb::Function, timeout::Real; interval::Real=0.0)
257268
timer = Timer(timeout, interval=interval)
258-
t = @task while _trywait(timer)
259-
try
260-
cb(timer)
261-
catch err
262-
write(stderr, "Error in Timer:\n")
263-
showerror(stderr, err, catch_backtrace())
264-
return
269+
t = @task begin
270+
unpreserve_handle(timer)
271+
while _trywait(timer)
272+
try
273+
cb(timer)
274+
catch err
275+
write(stderr, "Error in Timer:\n")
276+
showerror(stderr, err, catch_backtrace())
277+
return
278+
end
279+
isopen(timer) || return
280+
end
281+
end
282+
# here we are mimicking parts of _trywait, in coordination with task `t`
283+
preserve_handle(timer)
284+
@lock timer.cond begin
285+
if timer.set
286+
schedule(t)
287+
else
288+
_wait2(timer.cond, t)
265289
end
266-
isopen(timer) || return
267290
end
268-
lock(timer.cond)
269-
_wait2(timer.cond, t)
270-
unlock(timer.cond)
271291
return timer
272292
end
273293

base/asyncmap.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ up to 100 tasks will be used for concurrent mapping.
1515
1616
`ntasks` can also be specified as a zero-arg function. In this case, the
1717
number of tasks to run in parallel is checked before processing every element and a new
18-
task started if the value of `ntasks_func` is less than the current number
18+
task started if the value of `ntasks_func` is greater than the current number
1919
of tasks.
2020
2121
If `batch_size` is specified, the collection is processed in batch mode. `f` must

base/binaryplatforms.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,8 @@ const arch_march_isa_mapping = let
608608
"armv8_0" => get_set("aarch64", "armv8.0-a"),
609609
"armv8_1" => get_set("aarch64", "armv8.1-a"),
610610
"armv8_2_crypto" => get_set("aarch64", "armv8.2-a+crypto"),
611-
"armv8_4_crypto_sve" => get_set("aarch64", "armv8.4-a+crypto+sve"),
611+
"a64fx" => get_set("aarch64", "a64fx"),
612+
"apple_m1" => get_set("aarch64", "apple_m1"),
612613
],
613614
"powerpc64le" => [
614615
"power8" => get_set("powerpc64le", "power8"),

base/cmd.jl

+11-2
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,15 @@ setenv(cmd::Cmd, env::Pair{<:AbstractString}...; dir=cmd.dir) =
249249
setenv(cmd, env; dir=dir)
250250
setenv(cmd::Cmd; dir=cmd.dir) = Cmd(cmd; dir=dir)
251251

252+
# split environment entry string into before and after first `=` (key and value)
253+
function splitenv(e::String)
254+
i = findnext('=', e, 2)
255+
if i === nothing
256+
throw(ArgumentError("malformed environment entry"))
257+
end
258+
e[1:prevind(e, i)], e[nextind(e, i):end]
259+
end
260+
252261
"""
253262
addenv(command::Cmd, env...; inherit::Bool = true)
254263
@@ -268,7 +277,7 @@ function addenv(cmd::Cmd, env::Dict; inherit::Bool = true)
268277
merge!(new_env, ENV)
269278
end
270279
else
271-
for (k, v) in split.(cmd.env, "=")
280+
for (k, v) in splitenv.(cmd.env)
272281
new_env[string(k)::String] = string(v)::String
273282
end
274283
end
@@ -283,7 +292,7 @@ function addenv(cmd::Cmd, pairs::Pair{<:AbstractString}...; inherit::Bool = true
283292
end
284293

285294
function addenv(cmd::Cmd, env::Vector{<:AbstractString}; inherit::Bool = true)
286-
return addenv(cmd, Dict(k => v for (k, v) in split.(env, "=")); inherit)
295+
return addenv(cmd, Dict(k => v for (k, v) in splitenv.(env)); inherit)
287296
end
288297

289298
(&)(left::AbstractCmd, right::AbstractCmd) = AndCmds(left, right)

base/cpuid.jl

+21-7
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ const ISAs_by_family = Dict(
5656
"aarch64" => [
5757
# Implicit in all sets, because always required: fp, asimd
5858
"armv8.0-a" => ISA(Set{UInt32}()),
59-
"armv8.1-a" => ISA(Set((JL_AArch64_lse, JL_AArch64_crc, JL_AArch64_rdm))),
60-
"armv8.2-a+crypto" => ISA(Set((JL_AArch64_lse, JL_AArch64_crc, JL_AArch64_rdm, JL_AArch64_aes, JL_AArch64_sha2))),
61-
"armv8.4-a+crypto+sve" => ISA(Set((JL_AArch64_lse, JL_AArch64_crc, JL_AArch64_rdm, JL_AArch64_fp16fml, JL_AArch64_aes, JL_AArch64_sha2, JL_AArch64_dotprod, JL_AArch64_sve))),
59+
"armv8.1-a" => ISA(Set((JL_AArch64_v8_1a, JL_AArch64_lse, JL_AArch64_crc, JL_AArch64_rdm))),
60+
"armv8.2-a+crypto" => ISA(Set((JL_AArch64_v8_2a, JL_AArch64_lse, JL_AArch64_crc, JL_AArch64_rdm, JL_AArch64_aes, JL_AArch64_sha2))),
61+
"a64fx" => ISA(Set((JL_AArch64_v8_2a, JL_AArch64_lse, JL_AArch64_crc, JL_AArch64_rdm, JL_AArch64_sha2, JL_AArch64_ccpp, JL_AArch64_complxnum, JL_AArch64_fullfp16, JL_AArch64_sve))),
62+
"apple_m1" => ISA(Set((JL_AArch64_v8_5a, JL_AArch64_lse, JL_AArch64_crc, JL_AArch64_rdm, JL_AArch64_aes, JL_AArch64_sha2, JL_AArch64_sha3, JL_AArch64_ccpp, JL_AArch64_complxnum, JL_AArch64_fp16fml, JL_AArch64_fullfp16, JL_AArch64_dotprod, JL_AArch64_rcpc, JL_AArch64_altnzcv))),
6263
],
6364
"powerpc64le" => [
6465
# We have no way to test powerpc64le features yet, so we're only going to declare the lowest ISA:
@@ -88,14 +89,27 @@ function normalize_arch(arch::String)
8889
return arch
8990
end
9091

92+
let
93+
# Collect all relevant features for the current architecture, if any.
94+
FEATURES = UInt32[]
95+
arch = normalize_arch(String(Sys.ARCH))
96+
if arch in keys(ISAs_by_family)
97+
for isa in ISAs_by_family[arch]
98+
unique!(append!(FEATURES, last(isa).features))
99+
end
100+
end
101+
102+
# Use `@eval` to inline the list of features.
103+
@eval function cpu_isa()
104+
return ISA(Set{UInt32}(feat for feat in $(FEATURES) if test_cpu_feature(feat)))
105+
end
106+
end
107+
91108
"""
92109
cpu_isa()
93110
94111
Return the [`ISA`](@ref) (instruction set architecture) of the current CPU.
95112
"""
96-
function cpu_isa()
97-
all_features = last(last(get(ISAs_by_family, normalize_arch(String(Sys.ARCH)), "" => [ISA(Set{UInt32}())]))).features
98-
return ISA(Set{UInt32}(feat for feat in all_features if test_cpu_feature(feat)))
99-
end
113+
cpu_isa
100114

101115
end # module CPUID

base/io.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct SystemError <: Exception
2020
extrainfo
2121
SystemError(p::AbstractString, e::Integer, extrainfo) = new(p, e, extrainfo)
2222
SystemError(p::AbstractString, e::Integer) = new(p, e, nothing)
23-
SystemError(p::AbstractString) = new(p, Libc.errno())
23+
SystemError(p::AbstractString) = new(p, Libc.errno(), nothing)
2424
end
2525

2626
lock(::IO) = nothing

base/mpfr.jl

+8-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,14 @@ function round(::Type{T}, x::BigFloat, r::Union{RoundingMode, MPFRRoundingMode})
294294
end
295295
return unsafe_trunc(T, res)
296296
end
297-
round(::Type{BigInt}, x::BigFloat, r::Union{RoundingMode, MPFRRoundingMode}) = _unchecked_cast(BigInt, x, r)
297+
298+
function round(::Type{BigInt}, x::BigFloat, r::Union{RoundingMode, MPFRRoundingMode})
299+
clear_flags()
300+
res = _unchecked_cast(BigInt, x, r)
301+
had_range_exception() && throw(InexactError(:round, BigInt, x))
302+
return res
303+
end
304+
298305
round(::Type{T}, x::BigFloat, r::RoundingMode) where T<:Union{Signed, Unsigned} =
299306
invoke(round, Tuple{Type{<:Union{Signed, Unsigned}}, BigFloat, Union{RoundingMode, MPFRRoundingMode}}, T, x, r)
300307
round(::Type{BigInt}, x::BigFloat, r::RoundingMode) =

base/process.jl

+12-3
Original file line numberDiff line numberDiff line change
@@ -391,16 +391,25 @@ process failed, or if the process attempts to print anything to stdout.
391391
"""
392392
function open(f::Function, cmds::AbstractCmd, args...; kwargs...)
393393
P = open(cmds, args...; kwargs...)
394+
function waitkill(P::Process)
395+
close(P)
396+
# 0.1 seconds after we hope it dies (from closing stdio),
397+
# we kill the process with SIGTERM (15)
398+
local t = Timer(0.1) do t
399+
process_running(P) && kill(P)
400+
end
401+
wait(P)
402+
close(t)
403+
end
394404
ret = try
395405
f(P)
396406
catch
397-
kill(P)
398-
close(P)
407+
waitkill(P)
399408
rethrow()
400409
end
401410
close(P.in)
402411
if !eof(P.out)
403-
close(P.out)
412+
waitkill(P)
404413
throw(_UVError("open(do)", UV_EPIPE))
405414
end
406415
success(P) || pipeline_error(P)

0 commit comments

Comments
 (0)