Skip to content

Commit

Permalink
Merge 21a2c43 into 4688e54
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC authored Dec 21, 2022
2 parents 4688e54 + 21a2c43 commit 8ccf74a
Show file tree
Hide file tree
Showing 59 changed files with 563 additions and 173 deletions.
7 changes: 6 additions & 1 deletion Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,12 @@ USE_BINARYBUILDER ?= 0
endif

# Auto-detect triplet once, create different versions that we use as defaults below for each BB install target
BB_TRIPLET_LIBGFORTRAN_CXXABI := $(shell $(call invoke_python,$(JULIAHOME)/contrib/normalize_triplet.py) $(or $(XC_HOST),$(XC_HOST),$(BUILD_MACHINE)) "$(shell $(FC) --version | head -1)" "$(or $(shell echo '\#include <string>' | $(CXX) $(CXXFLAGS) -x c++ -dM -E - | grep _GLIBCXX_USE_CXX11_ABI | awk '{ print $$3 }' ),1)")
FC_VERSION := $(shell $(FC) -dM -E - < /dev/null | grep __GNUC__ | cut -d' ' -f3)
ifeq ($(USEGCC)$(FC_VERSION),1)
FC_OR_CC_VERSION := $(shell $(CC) -dumpfullversion -dumpversion 2>/dev/null | cut -d'.' -f1)
# n.b. clang's __GNUC__ macro pretends to be gcc 4.2.1, so leave it as the empty string here if the compiler is not certain to be GCC
endif
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))))
BB_TRIPLET := $(subst $(SPACE),-,$(filter-out cxx%,$(filter-out libgfortran%,$(subst -,$(SPACE),$(BB_TRIPLET_LIBGFORTRAN_CXXABI)))))
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ Library changes
* `RegexMatch` objects can now be probed for whether a named capture group exists within it through `haskey()` ([#36717]).
* For consistency `haskey(r::RegexMatch, i::Integer)` has also been added and returns if the capture group
for `i` exists ([#37300]).
* An issue with order of operations in `fld1` is now fixed ([#28973]).

Standard library changes
------------------------
Expand Down
15 changes: 8 additions & 7 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -820,13 +820,12 @@ See also [`copyto!`](@ref).
is available from the `Future` standard library as `Future.copy!`.
"""
function copy!(dst::AbstractVector, src::AbstractVector)
firstindex(dst) == firstindex(src) || throw(ArgumentError(
"vectors must have the same offset for copy! (consider using `copyto!`)"))
if length(dst) != length(src)
resize!(dst, length(src))
end
for i in eachindex(dst, src)
@inbounds dst[i] = src[i]
end
dst
copyto!(dst, src)
end

function copy!(dst::AbstractArray, src::AbstractArray)
Expand Down Expand Up @@ -1014,8 +1013,9 @@ function copyto!(dest::AbstractArray, dstart::Integer,
destinds, srcinds = LinearIndices(dest), LinearIndices(src)
(checkbounds(Bool, destinds, dstart) && checkbounds(Bool, destinds, dstart+n-1)) || throw(BoundsError(dest, dstart:dstart+n-1))
(checkbounds(Bool, srcinds, sstart) && checkbounds(Bool, srcinds, sstart+n-1)) || throw(BoundsError(src, sstart:sstart+n-1))
@inbounds for i = 0:(n-1)
dest[dstart+i] = src[sstart+i]
src′ = unalias(dest, src)
@inbounds for i = 0:n-1
dest[dstart+i] = src′[sstart+i]
end
return dest
end
Expand All @@ -1037,11 +1037,12 @@ function copyto!(B::AbstractVecOrMat{R}, ir_dest::AbstractRange{Int}, jr_dest::A
end
@boundscheck checkbounds(B, ir_dest, jr_dest)
@boundscheck checkbounds(A, ir_src, jr_src)
A′ = unalias(B, A)
jdest = first(jr_dest)
for jsrc in jr_src
idest = first(ir_dest)
for isrc in ir_src
@inbounds B[idest,jdest] = A[isrc,jsrc]
@inbounds B[idest,jdest] = A[isrc,jsrc]
idest += step(ir_dest)
end
jdest += step(jr_dest)
Expand Down
28 changes: 17 additions & 11 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1659,6 +1659,11 @@ function reverseind(a::AbstractVector, i::Integer)
first(li) + last(li) - i
end

# This implementation of `midpoint` is performance-optimized but safe
# only if `lo <= hi`.
midpoint(lo::T, hi::T) where T<:Integer = lo + ((hi - lo) >>> 0x01)
midpoint(lo::Integer, hi::Integer) = midpoint(promote(lo, hi)...)

"""
reverse!(v [, start=1 [, stop=length(v) ]]) -> v
Expand Down Expand Up @@ -1687,17 +1692,18 @@ julia> A
"""
function reverse!(v::AbstractVector, start::Integer, stop::Integer=lastindex(v))
s, n = Int(start), Int(stop)
liv = LinearIndices(v)
if n <= s # empty case; ok
elseif !(first(liv) s last(liv))
throw(BoundsError(v, s))
elseif !(first(liv) n last(liv))
throw(BoundsError(v, n))
end
r = n
@inbounds for i in s:div(s+n-1, 2)
v[i], v[r] = v[r], v[i]
r -= 1
if n > s # non-empty and non-trivial
liv = LinearIndices(v)
if !(first(liv) s last(liv))
throw(BoundsError(v, s))
elseif !(first(liv) n last(liv))
throw(BoundsError(v, n))
end
r = n
@inbounds for i in s:midpoint(s, n-1)
v[i], v[r] = v[r], v[i]
r -= 1
end
end
return v
end
Expand Down
5 changes: 3 additions & 2 deletions base/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,11 @@ function unsafe_copyto!(dest::BitArray, doffs::Integer, src::Union{BitArray,Arra
return dest
end

copyto!(dest::BitArray, doffs::Integer, src::Array, soffs::Integer, n::Integer) =
copyto!(dest::BitArray, doffs::Integer, src::Union{BitArray,Array}, soffs::Integer, n::Integer) =
_copyto_int!(dest, Int(doffs), src, Int(soffs), Int(n))
function _copyto_int!(dest::BitArray, doffs::Int, src::Array, soffs::Int, n::Int)
function _copyto_int!(dest::BitArray, doffs::Int, src::Union{BitArray,Array}, soffs::Int, n::Int)
n == 0 && return dest
n < 0 && throw(ArgumentError("Number of elements to copy must be nonnegative."))
soffs < 1 && throw(BoundsError(src, soffs))
doffs < 1 && throw(BoundsError(dest, doffs))
soffs+n-1 > length(src) && throw(BoundsError(src, length(src)+1))
Expand Down
14 changes: 2 additions & 12 deletions base/bitset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,10 @@ function union!(s::BitSet, r::AbstractUnitRange{<:Integer})

# grow s.bits as necessary
if diffb >= len
_growend!(s.bits, diffb - len + 1)
# we set only some values to CHK0, those which will not be
# fully overwritten (i.e. only or'ed with `|`)
s.bits[end] = CHK0 # end == diffb + 1
if diffa >= len
s.bits[diffa + 1] = CHK0
end
_growend0!(s.bits, diffb - len + 1)
end
if diffa < 0
_growbeg!(s.bits, -diffa)
s.bits[1] = CHK0
if diffb < 0
s.bits[diffb - diffa + 1] = CHK0
end
_growbeg0!(s.bits, -diffa)
s.offset = cidxa # s.offset += diffa
diffb -= diffa
diffa = 0
Expand Down
2 changes: 1 addition & 1 deletion base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ Base.@propagate_inbounds dotview(B::BitArray, i::BitArray) = BitMaskedBitArray(B
Base.show(io::IO, B::BitMaskedBitArray) = foreach(arg->show(io, arg), (typeof(B), (B.parent, B.mask)))
# Override materialize! to prevent the BitMaskedBitArray from escaping to an overrideable method
@inline materialize!(B::BitMaskedBitArray, bc::Broadcasted{<:Any,<:Any,typeof(identity),Tuple{Bool}}) = fill!(B, bc.args[1])
@inline materialize!(B::BitMaskedBitArray, bc::Broadcasted{<:Any}) = materialize!(SubArray(B.parent, to_indices(B.parent, (B.mask,))), bc)
@inline materialize!(B::BitMaskedBitArray, bc::Broadcasted{<:Any}) = materialize!(@inbounds(view(B.parent, B.mask)), bc)
function Base.fill!(B::BitMaskedBitArray, b::Bool)
Bc = B.parent.chunks
Ic = B.mask.chunks
Expand Down
2 changes: 1 addition & 1 deletion base/compiler/ssair/legacy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function replace_code_newstyle!(ci::CodeInfo, ir::IRCode, nargs::Int)
elseif isa(stmt, GotoIfNot)
stmt = GotoIfNot(stmt.cond, first(ir.cfg.blocks[stmt.dest].stmts))
elseif isa(stmt, PhiNode)
stmt = PhiNode(Int32[last(ir.cfg.blocks[edge].stmts) for edge in stmt.edges], stmt.values)
stmt = PhiNode(Int32[edge == 0 ? 0 : last(ir.cfg.blocks[edge].stmts) for edge in stmt.edges], stmt.values)
elseif isa(stmt, Expr) && stmt.head === :enter
stmt.args[1] = first(ir.cfg.blocks[stmt.args[1]::Int].stmts)
end
Expand Down
1 change: 1 addition & 0 deletions base/iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,7 @@ iterate(::ProductIterator{Tuple{}}, state) = nothing
done1 === true || return done1 # false or missing
return _pisdone(tail(iters), tail(states)) # check tail
end
@inline isdone(::ProductIterator{Tuple{}}, states) = true
@inline isdone(P::ProductIterator, states) = _pisdone(P.iterators, states)

@inline _piterate() = ()
Expand Down
11 changes: 7 additions & 4 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1794,11 +1794,14 @@ function stale_cachefile(modpath::String, cachefile::String; ignore_loaded = fal
end
for chi in includes
f, ftime_req = chi.filename, chi.mtime
# Issue #13606: compensate for Docker images rounding mtimes
# Issue #20837: compensate for GlusterFS truncating mtimes to microseconds
# The `ftime != 1.0` condition below provides compatibility with Nix mtime.
ftime = mtime(f)
if ftime != ftime_req && ftime != floor(ftime_req) && ftime != trunc(ftime_req, digits=6) && ftime != 1.0
is_stale = ( ftime != ftime_req ) &&
( ftime != floor(ftime_req) ) && # Issue #13606, PR #13613: compensate for Docker images rounding mtimes
( ftime != ceil(ftime_req) ) && # PR: #47433 Compensate for CirceCI's truncating of timestamps in its caching
( ftime != trunc(ftime_req, digits=6) ) && # Issue #20837, PR #20840: compensate for GlusterFS truncating mtimes to microseconds
( ftime != 1.0 ) && # PR #43090: provide compatibility with Nix mtime.
!( 0 < (ftime_req - ftime) < 1e-6 ) # PR #45552: Compensate for Windows tar giving mtimes that may be incorrect by up to one microsecond
if is_stale
@debug "Rejecting stale cache file $cachefile (mtime $ftime_req) because file $f (mtime $ftime) has changed"
return true
end
Expand Down
8 changes: 8 additions & 0 deletions base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,8 @@ julia> rem2pi(7pi/4, RoundDown)
"""
function rem2pi end
function rem2pi(x::Float64, ::RoundingMode{:Nearest})
isfinite(x) || return NaN

abs(x) < pi && return x

n,y = rem_pio2_kernel(x)
Expand All @@ -1012,6 +1014,8 @@ function rem2pi(x::Float64, ::RoundingMode{:Nearest})
end
end
function rem2pi(x::Float64, ::RoundingMode{:ToZero})
isfinite(x) || return NaN

ax = abs(x)
ax <= 2*Float64(pi,RoundDown) && return x

Expand All @@ -1037,6 +1041,8 @@ function rem2pi(x::Float64, ::RoundingMode{:ToZero})
copysign(z,x)
end
function rem2pi(x::Float64, ::RoundingMode{:Down})
isfinite(x) || return NaN

if x < pi4o2_h
if x >= 0
return x
Expand Down Expand Up @@ -1066,6 +1072,8 @@ function rem2pi(x::Float64, ::RoundingMode{:Down})
end
end
function rem2pi(x::Float64, ::RoundingMode{:Up})
isfinite(x) || return NaN

if x > -pi4o2_h
if x <= 0
return x
Expand Down
2 changes: 1 addition & 1 deletion base/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ julia> x == (fld1(x, y) - 1) * y + mod1(x, y)
true
```
"""
fld1(x::T, y::T) where {T<:Real} = (m = mod1(x, y); fld(x + y - m, y))
fld1(x::T, y::T) where {T<:Real} = (m = mod1(x, y); fld((x - m) + y, y))
function fld1(x::T, y::T) where T<:Integer
d = div(x, y)
return d + (!signbit(x y) & (d * y != x))
Expand Down
2 changes: 1 addition & 1 deletion base/promotion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ xor(x::T, y::T) where {T<:Integer} = no_op_err("xor", T)

(==)(x::T, y::T) where {T<:Number} = x === y
(< )(x::T, y::T) where {T<:Real} = no_op_err("<" , T)
(<=)(x::T, y::T) where {T<:Real} = no_op_err("<=", T)
(<=)(x::T, y::T) where {T<:Real} = (x == y) | (x < y)

rem(x::T, y::T) where {T<:Real} = no_op_err("rem", T)
mod(x::T, y::T) where {T<:Real} = no_op_err("mod", T)
Expand Down
15 changes: 7 additions & 8 deletions base/range.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1073,14 +1073,13 @@ function sum(r::AbstractRange{<:Real})
end

function _in_range(x, r::AbstractRange)
if !isfinite(x)
return false
elseif iszero(step(r))
return !isempty(r) && first(r) == x
else
n = round(Integer, (x - first(r)) / step(r)) + 1
return n >= 1 && n <= length(r) && r[n] == x
end
isempty(r) && return false
f, l = first(r), last(r)
# check for NaN, Inf, and large x that may overflow in the next calculation
f <= x <= l || l <= x <= f || return false
iszero(step(r)) && return true
n = round(Integer, (x - f) / step(r)) + 1
n >= 1 && n <= length(r) && r[n] == x
end
in(x::Real, r::AbstractRange{<:Real}) = _in_range(x, r)
# This method needs to be defined separately since -(::T, ::T) can be implemented
Expand Down
14 changes: 13 additions & 1 deletion base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1084,13 +1084,25 @@ function may_invoke_generator(method::Method, @nospecialize(atypes), sparams::Si
end
end
end
for i = 1:length(at.parameters)
non_va_args = method.isva ? method.nargs - 1 : method.nargs
for i = 1:non_va_args
if !isdispatchelem(at.parameters[i])
if (ast_slotflag(code, 1 + i + nsparams) & SLOT_USED) != 0
return false
end
end
end
if method.isva
# If the va argument is used, we need to ensure that all arguments that
# contribute to the va tuple are dispatchelemes
if (ast_slotflag(code, 1 + method.nargs + nsparams) & SLOT_USED) != 0
for i = (non_va_args+1):length(at.parameters)
if !isdispatchelem(at.parameters[i])
return false
end
end
end
end
return true
end

Expand Down
17 changes: 6 additions & 11 deletions base/sort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using .Base: copymutable, LinearIndices, length, (:),
AbstractVector, @inbounds, AbstractRange, @eval, @inline, Vector, @noinline,
AbstractMatrix, AbstractUnitRange, isless, identity, eltype, >, <, <=, >=, |, +, -, *, !,
extrema, sub_with_overflow, add_with_overflow, oneunit, div, getindex, setindex!,
length, resize!, fill, Missing, require_one_based_indexing, keytype
length, resize!, fill, Missing, require_one_based_indexing, keytype, midpoint

using .Base: >>>, !==

Expand Down Expand Up @@ -165,11 +165,6 @@ same thing as `partialsort!` but leaving `v` unmodified.
partialsort(v::AbstractVector, k::Union{Integer,OrdinalRange}; kws...) =
partialsort!(copymutable(v), k; kws...)

# This implementation of `midpoint` is performance-optimized but safe
# only if `lo <= hi`.
midpoint(lo::T, hi::T) where T<:Integer = lo + ((hi - lo) >>> 0x01)
midpoint(lo::Integer, hi::Integer) = midpoint(promote(lo, hi)...)

# reference on sorted binary search:
# http://www.tbray.org/ongoing/When/200x/2003/03/22/Binary

Expand Down Expand Up @@ -499,12 +494,12 @@ function sort!(v::AbstractVector, lo::Integer, hi::Integer, ::InsertionSortAlg,
j = i
x = v[i]
while j > lo
if lt(o, x, v[j-1])
v[j] = v[j-1]
j -= 1
continue
y = v[j-1]
if !lt(o, x, y)
break
end
break
v[j] = y
j -= 1
end
v[j] = x
end
Expand Down
10 changes: 9 additions & 1 deletion base/version_git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,15 @@ if [ -n "$(git status --porcelain)" ]; then
# append dirty mark '*' if the repository has uncommitted changes
commit_short="$commit_short"*
fi
branch=$(git rev-parse --abbrev-ref HEAD)

# Our CI system checks commits out as a detached head, and so we must
# use the provided branch name, as we cannot autodetect this commit as
# the tip of any such branch.
if [ -n "${BUILDKITE_BRANCH}" ]; then
branch="${BUILDKITE_BRANCH}"
else
branch=$(git rev-parse --abbrev-ref HEAD)
fi

topdir=$(git rev-parse --show-toplevel)
verchanged=$(git blame -L ,1 -sl -- "$topdir/VERSION" | cut -f 1 -d " ")
Expand Down
30 changes: 20 additions & 10 deletions contrib/normalize_triplet.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,26 @@ def p(x):
# not been specified
if libgfortran_version == "blank_libgfortran":
if len(sys.argv) >= 3:
libgfortran_version = {
"4": "libgfortran3",
"5": "libgfortran3",
"6": "libgfortran3",
"7": "libgfortran4",
"8": "libgfortran5",
"9": "libgfortran5",
"10": "libgfortran5",
"11": "libgfortran5",
}[list(filter(lambda x: re.match("\d+\.\d+(\.\d+)?", x), sys.argv[2].split()))[-1].split('.')[0]]
# If there was no gfortran/gcc version passed in, default to the latest libgfortran version
if not sys.argv[2]:
libgfortran_version = "libgfortran5"
else:
# Grab the first number in the last word with a number
# This will be the major version number.
major_ver = -1
words = sys.argv[2].split()
for word in words[::-1]:
major_ver = re.search("[0-9]+", word)
if major_ver:
major_ver = int(major_ver.group())
break

if major_ver <= 6:
libgfortran_version = "libgfortran3"
elif major_ver <= 7:
libgfortran_version = "libgfortran4"
else:
libgfortran_version = "libgfortran5"

if cxx_abi == "blank_cxx_abi":
if len(sys.argv) == 4:
Expand Down
2 changes: 1 addition & 1 deletion deps/Versions.make
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ P7ZIP_VER := 17.04
P7ZIP_JLL_NAME := p7zip

# PCRE
PCRE_VER := 10.40
PCRE_VER := 10.42
PCRE_JLL_NAME := PCRE2

# SuiteSparse
Expand Down
Loading

0 comments on commit 8ccf74a

Please sign in to comment.