Skip to content

Commit

Permalink
Merge pull request #44189 from JuliaLang/backports-release-1.7
Browse files Browse the repository at this point in the history
Backports for 1.7.3
  • Loading branch information
KristofferC authored Apr 22, 2022
2 parents 857b62d + 86e06d3 commit 50a7a55
Show file tree
Hide file tree
Showing 64 changed files with 697 additions and 325 deletions.
6 changes: 3 additions & 3 deletions Make.inc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- mode: makefile-gmake -*-
# -*- mode: makefile -*-
# vi:syntax=make

## Note:
Expand Down Expand Up @@ -1172,7 +1172,7 @@ endif

# Auto-detect triplet once, create different versions that we use as defaults below for each BB install target
FC_VERSION := $(shell $(FC) --version 2>/dev/null | head -1)
FC_OR_CC_VERISON := $(or $(FC_VERSION),$(shell $(CC) --version 2>/dev/null | head -1))
FC_OR_CC_VERSION := $(or $(FC_VERSION),$(shell $(CC) --version 2>/dev/null | head -1))
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)")
BB_TRIPLET_LIBGFORTRAN := $(subst $(SPACE),-,$(filter-out cxx%,$(subst -,$(SPACE),$(BB_TRIPLET_LIBGFORTRAN_CXXABI))))
BB_TRIPLET_CXXABI := $(subst $(SPACE),-,$(filter-out libgfortran%,$(subst -,$(SPACE),$(BB_TRIPLET_LIBGFORTRAN_CXXABI))))
Expand Down Expand Up @@ -1507,7 +1507,7 @@ endif
endif
ifeq ($(OS),Darwin)
ifeq ($(ARCH),aarch64)
LIBGCC_NAME := libgcc_s.2.$(SHLIB_EXT)
LIBGCC_NAME := libgcc_s.1.1.$(SHLIB_EXT)
else
LIBGCC_NAME := libgcc_s.1.$(SHLIB_EXT)
endif
Expand Down
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ $(BUILDROOT)/doc/_build/html/en/index.html: $(shell find $(BUILDROOT)/base $(BUI

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


exe:
# run Inno Setup to compile installer
$(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))
Expand Down
6 changes: 3 additions & 3 deletions base/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,6 @@ include("weakkeydict.jl")

include("env.jl")

# BinaryPlatforms, used by Artifacts
include("binaryplatforms.jl")

# functions defined in Random
function rand end
function randn end
Expand Down Expand Up @@ -332,6 +329,9 @@ using .Order
include("sort.jl")
using .Sort

# BinaryPlatforms, used by Artifacts. Needs `Sort`.
include("binaryplatforms.jl")

# Fast math
include("fastmath.jl")
using .FastMath
Expand Down
4 changes: 4 additions & 0 deletions base/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,11 @@ else ifneq ($(USE_SYSTEM_OPENLIBM),0)
$(eval $(call symlink_system_library,OPENLIBM,$(LIBMNAME)))
endif

ifeq ($(APPLE_ARCH),arm64)
$(eval $(call symlink_system_library,CSL,libgcc_s,1.1))
else
$(eval $(call symlink_system_library,CSL,libgcc_s,1))
endif
ifneq (,$(LIBGFORTRAN_VERSION))
$(eval $(call symlink_system_library,CSL,libgfortran,$(LIBGFORTRAN_VERSION)))
endif
Expand Down
18 changes: 18 additions & 0 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2315,6 +2315,24 @@ function _typed_hvncat_dims(::Type{T}, dims::NTuple{N, Int}, row_first::Bool, as

outdims = zeros(Int, N)

# validate shapes for lowest level of concatenation
d = findfirst(>(1), dims)
if d !== nothing # all dims are 1
nblocks = length(as) ÷ dims[d]
for b 1:nblocks
offset = ((b - 1) * dims[d])
startelementi = offset + 1
for i offset .+ (2:dims[d])
for dd 1:N
dd == d && continue
if size(as[startelementi], dd) != size(as[i], dd)
throw(ArgumentError("incompatible shape in element $i"))
end
end
end
end
end

# discover number of rows or columns
for i 1:dims[d1]
outdims[d1] += cat_size(as[i], d1)
Expand Down
5 changes: 4 additions & 1 deletion base/abstractdict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ empty(a::AbstractDict) = empty(a, keytype(a), valtype(a))
empty(a::AbstractDict, ::Type{V}) where {V} = empty(a, keytype(a), V) # Note: this is the form which makes sense for `Vector`.

copy(a::AbstractDict) = merge!(empty(a), a)
copy!(dst::AbstractDict, src::AbstractDict) = merge!(empty!(dst), src)
function copy!(dst::AbstractDict, src::AbstractDict)
dst === src && return dst
merge!(empty!(dst), src)
end

"""
merge!(d::AbstractDict, others::AbstractDict...)
Expand Down
5 changes: 4 additions & 1 deletion base/abstractset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
eltype(::Type{<:AbstractSet{T}}) where {T} = @isdefined(T) ? T : Any
sizehint!(s::AbstractSet, n) = nothing

copy!(dst::AbstractSet, src::AbstractSet) = union!(empty!(dst), src)
function copy!(dst::AbstractSet, src::AbstractSet)
dst === src && return dst
union!(empty!(dst), src)
end

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

Expand Down
72 changes: 46 additions & 26 deletions base/asyncevent.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,22 @@ the async condition object itself.
"""
function AsyncCondition(cb::Function)
async = AsyncCondition()
t = @task while _trywait(async)
cb(async)
isopen(async) || return
t = @task begin
unpreserve_handle(async)
while _trywait(async)
cb(async)
isopen(async) || return
end
end
# here we are mimicking parts of _trywait, in coordination with task `t`
preserve_handle(async)
@lock async.cond begin
if async.set
schedule(t)
else
_wait2(async.cond, t)
end
end
lock(async.cond)
_wait2(async.cond, t)
unlock(async.cond)
return async
end

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

function _trywait(t::Union{Timer, AsyncCondition})
set = t.set
if !set
if set
# full barrier now for AsyncCondition
t isa Timer || Core.Intrinsics.atomic_fence(:acquire_release)
else
t.isopen || return false
t.handle == C_NULL && return false
iolock_begin()
set = t.set
Expand All @@ -112,14 +125,12 @@ function _trywait(t::Union{Timer, AsyncCondition})
lock(t.cond)
try
set = t.set
if !set
if t.handle != C_NULL
iolock_end()
set = wait(t.cond)
unlock(t.cond)
iolock_begin()
lock(t.cond)
end
if !set && t.isopen && t.handle != C_NULL
iolock_end()
set = wait(t.cond)
unlock(t.cond)
iolock_begin()
lock(t.cond)
end
finally
unlock(t.cond)
Expand Down Expand Up @@ -255,19 +266,28 @@ julia> begin
"""
function Timer(cb::Function, timeout::Real; interval::Real=0.0)
timer = Timer(timeout, interval=interval)
t = @task while _trywait(timer)
try
cb(timer)
catch err
write(stderr, "Error in Timer:\n")
showerror(stderr, err, catch_backtrace())
return
t = @task begin
unpreserve_handle(timer)
while _trywait(timer)
try
cb(timer)
catch err
write(stderr, "Error in Timer:\n")
showerror(stderr, err, catch_backtrace())
return
end
isopen(timer) || return
end
end
# here we are mimicking parts of _trywait, in coordination with task `t`
preserve_handle(timer)
@lock timer.cond begin
if timer.set
schedule(t)
else
_wait2(timer.cond, t)
end
isopen(timer) || return
end
lock(timer.cond)
_wait2(timer.cond, t)
unlock(timer.cond)
return timer
end

Expand Down
2 changes: 1 addition & 1 deletion base/asyncmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ up to 100 tasks will be used for concurrent mapping.
`ntasks` can also be specified as a zero-arg function. In this case, the
number of tasks to run in parallel is checked before processing every element and a new
task started if the value of `ntasks_func` is less than the current number
task started if the value of `ntasks_func` is greater than the current number
of tasks.
If `batch_size` is specified, the collection is processed in batch mode. `f` must
Expand Down
3 changes: 2 additions & 1 deletion base/binaryplatforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,8 @@ const arch_march_isa_mapping = let
"armv8_0" => get_set("aarch64", "armv8.0-a"),
"armv8_1" => get_set("aarch64", "armv8.1-a"),
"armv8_2_crypto" => get_set("aarch64", "armv8.2-a+crypto"),
"armv8_4_crypto_sve" => get_set("aarch64", "armv8.4-a+crypto+sve"),
"a64fx" => get_set("aarch64", "a64fx"),
"apple_m1" => get_set("aarch64", "apple_m1"),
],
"powerpc64le" => [
"power8" => get_set("powerpc64le", "power8"),
Expand Down
13 changes: 11 additions & 2 deletions base/cmd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,15 @@ setenv(cmd::Cmd, env::Pair{<:AbstractString}...; dir=cmd.dir) =
setenv(cmd, env; dir=dir)
setenv(cmd::Cmd; dir=cmd.dir) = Cmd(cmd; dir=dir)

# split environment entry string into before and after first `=` (key and value)
function splitenv(e::String)
i = findnext('=', e, 2)
if i === nothing
throw(ArgumentError("malformed environment entry"))
end
e[1:prevind(e, i)], e[nextind(e, i):end]
end

"""
addenv(command::Cmd, env...; inherit::Bool = true)
Expand All @@ -268,7 +277,7 @@ function addenv(cmd::Cmd, env::Dict; inherit::Bool = true)
merge!(new_env, ENV)
end
else
for (k, v) in split.(cmd.env, "=")
for (k, v) in splitenv.(cmd.env)
new_env[string(k)::String] = string(v)::String
end
end
Expand All @@ -283,7 +292,7 @@ function addenv(cmd::Cmd, pairs::Pair{<:AbstractString}...; inherit::Bool = true
end

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

(&)(left::AbstractCmd, right::AbstractCmd) = AndCmds(left, right)
Expand Down
28 changes: 21 additions & 7 deletions base/cpuid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ const ISAs_by_family = Dict(
"aarch64" => [
# Implicit in all sets, because always required: fp, asimd
"armv8.0-a" => ISA(Set{UInt32}()),
"armv8.1-a" => ISA(Set((JL_AArch64_lse, JL_AArch64_crc, JL_AArch64_rdm))),
"armv8.2-a+crypto" => ISA(Set((JL_AArch64_lse, JL_AArch64_crc, JL_AArch64_rdm, JL_AArch64_aes, JL_AArch64_sha2))),
"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))),
"armv8.1-a" => ISA(Set((JL_AArch64_v8_1a, JL_AArch64_lse, JL_AArch64_crc, JL_AArch64_rdm))),
"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))),
"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))),
"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))),
],
"powerpc64le" => [
# We have no way to test powerpc64le features yet, so we're only going to declare the lowest ISA:
Expand Down Expand Up @@ -88,14 +89,27 @@ function normalize_arch(arch::String)
return arch
end

let
# Collect all relevant features for the current architecture, if any.
FEATURES = UInt32[]
arch = normalize_arch(String(Sys.ARCH))
if arch in keys(ISAs_by_family)
for isa in ISAs_by_family[arch]
unique!(append!(FEATURES, last(isa).features))
end
end

# Use `@eval` to inline the list of features.
@eval function cpu_isa()
return ISA(Set{UInt32}(feat for feat in $(FEATURES) if test_cpu_feature(feat)))
end
end

"""
cpu_isa()
Return the [`ISA`](@ref) (instruction set architecture) of the current CPU.
"""
function cpu_isa()
all_features = last(last(get(ISAs_by_family, normalize_arch(String(Sys.ARCH)), "" => [ISA(Set{UInt32}())]))).features
return ISA(Set{UInt32}(feat for feat in all_features if test_cpu_feature(feat)))
end
cpu_isa

end # module CPUID
2 changes: 1 addition & 1 deletion base/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct SystemError <: Exception
extrainfo
SystemError(p::AbstractString, e::Integer, extrainfo) = new(p, e, extrainfo)
SystemError(p::AbstractString, e::Integer) = new(p, e, nothing)
SystemError(p::AbstractString) = new(p, Libc.errno())
SystemError(p::AbstractString) = new(p, Libc.errno(), nothing)
end

lock(::IO) = nothing
Expand Down
9 changes: 8 additions & 1 deletion base/mpfr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,14 @@ function round(::Type{T}, x::BigFloat, r::Union{RoundingMode, MPFRRoundingMode})
end
return unsafe_trunc(T, res)
end
round(::Type{BigInt}, x::BigFloat, r::Union{RoundingMode, MPFRRoundingMode}) = _unchecked_cast(BigInt, x, r)

function round(::Type{BigInt}, x::BigFloat, r::Union{RoundingMode, MPFRRoundingMode})
clear_flags()
res = _unchecked_cast(BigInt, x, r)
had_range_exception() && throw(InexactError(:round, BigInt, x))
return res
end

round(::Type{T}, x::BigFloat, r::RoundingMode) where T<:Union{Signed, Unsigned} =
invoke(round, Tuple{Type{<:Union{Signed, Unsigned}}, BigFloat, Union{RoundingMode, MPFRRoundingMode}}, T, x, r)
round(::Type{BigInt}, x::BigFloat, r::RoundingMode) =
Expand Down
15 changes: 12 additions & 3 deletions base/process.jl
Original file line number Diff line number Diff line change
Expand Up @@ -391,16 +391,25 @@ process failed, or if the process attempts to print anything to stdout.
"""
function open(f::Function, cmds::AbstractCmd, args...; kwargs...)
P = open(cmds, args...; kwargs...)
function waitkill(P::Process)
close(P)
# 0.1 seconds after we hope it dies (from closing stdio),
# we kill the process with SIGTERM (15)
local t = Timer(0.1) do t
process_running(P) && kill(P)
end
wait(P)
close(t)
end
ret = try
f(P)
catch
kill(P)
close(P)
waitkill(P)
rethrow()
end
close(P.in)
if !eof(P.out)
close(P.out)
waitkill(P)
throw(_UVError("open(do)", UV_EPIPE))
end
success(P) || pipeline_error(P)
Expand Down
Loading

0 comments on commit 50a7a55

Please sign in to comment.