Skip to content

Commit a7a5453

Browse files
authored
Merge pull request #47602 from JuliaLang/backports-release-1.9
release-1.9: Backports for julia 1.9.0-beta1
2 parents 0540f9d + 6adc428 commit a7a5453

File tree

173 files changed

+8146
-6129
lines changed

Some content is hidden

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

173 files changed

+8146
-6129
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
.DS_Store
3434
.idea/*
3535
.vscode/*
36-
36+
*.heapsnapshot
3737
# Buildkite: Ignore the entire .buildkite directory
3838
/.buildkite
3939

Make.inc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ JULIA_THREADS := 1
7777
# Set to 1 to enable profiling with OProfile
7878
USE_OPROFILE_JITEVENTS ?= 0
7979

80-
# USE_PERF_JITEVENTS defined below since default is OS specific
80+
# USE_PERF_JITEVENTS, and USE_INTEL_JITEVENTS defined below since default is OS specific
8181

8282
# assume we don't have LIBSSP support in our compiler, will enable later if likely true
8383
HAVE_SSP := 0
@@ -442,8 +442,10 @@ endif
442442
# Set to 1 to enable profiling with perf
443443
ifeq ("$(OS)", "Linux")
444444
USE_PERF_JITEVENTS ?= 1
445+
USE_INTEL_JITEVENTS ?= 1
445446
else
446447
USE_PERF_JITEVENTS ?= 0
448+
USE_INTEL_JITEVENTS ?= 0
447449
endif
448450

449451
JULIACODEGEN := LLVM

Makefile

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ all: debug release
1111
# sort is used to remove potential duplicates
1212
DIRS := $(sort $(build_bindir) $(build_depsbindir) $(build_libdir) $(build_private_libdir) $(build_libexecdir) $(build_includedir) $(build_includedir)/julia $(build_sysconfdir)/julia $(build_datarootdir)/julia $(build_datarootdir)/julia/stdlib $(build_man1dir))
1313
ifneq ($(BUILDROOT),$(JULIAHOME))
14-
BUILDDIRS := $(BUILDROOT) $(addprefix $(BUILDROOT)/,base src src/flisp src/support src/clangsa cli doc deps stdlib test test/clangsa test/embedding test/llvmpasses)
14+
BUILDDIRS := $(BUILDROOT) $(addprefix $(BUILDROOT)/,base src src/flisp src/support src/clangsa cli doc deps stdlib test test/clangsa test/embedding test/gcext test/llvmpasses)
1515
BUILDDIRMAKE := $(addsuffix /Makefile,$(BUILDDIRS)) $(BUILDROOT)/sysimage.mk
1616
DIRS := $(DIRS) $(BUILDDIRS)
1717
$(BUILDDIRMAKE): | $(BUILDDIRS)
@@ -247,13 +247,21 @@ ifeq ($(OS),WINNT)
247247
-$(INSTALL_M) $(wildcard $(build_bindir)/*.dll) $(DESTDIR)$(bindir)/
248248
ifeq ($(JULIA_BUILD_MODE),release)
249249
-$(INSTALL_M) $(build_libdir)/libjulia.dll.a $(DESTDIR)$(libdir)/
250+
-$(INSTALL_M) $(build_libdir)/libjulia-internal.dll.a $(DESTDIR)$(libdir)/
250251
else ifeq ($(JULIA_BUILD_MODE),debug)
251252
-$(INSTALL_M) $(build_libdir)/libjulia-debug.dll.a $(DESTDIR)$(libdir)/
253+
-$(INSTALL_M) $(build_libdir)/libjulia-internal-debug.dll.a $(DESTDIR)$(libdir)/
252254
endif
253255

254256
# We have a single exception; we want 7z.dll to live in libexec, not bin, so that 7z.exe can find it.
255257
-mv $(DESTDIR)$(bindir)/7z.dll $(DESTDIR)$(libexecdir)/
256258
-$(INSTALL_M) $(build_bindir)/libopenlibm.dll.a $(DESTDIR)$(libdir)/
259+
-$(INSTALL_M) $(build_libdir)/libssp.dll.a $(DESTDIR)$(libdir)/
260+
# The rest are compiler dependencies, as an example memcpy is exported by msvcrt
261+
# These are files from mingw32 and required for creating shared libraries like our caches.
262+
-$(INSTALL_M) $(build_libdir)/libgcc_s.a $(DESTDIR)$(libdir)/
263+
-$(INSTALL_M) $(build_libdir)/libgcc.a $(DESTDIR)$(libdir)/
264+
-$(INSTALL_M) $(build_libdir)/libmsvcrt.a $(DESTDIR)$(libdir)/
257265
else
258266

259267
# Copy over .dSYM directories directly for Darwin
@@ -318,6 +326,11 @@ else ifeq ($(JULIA_BUILD_MODE),debug)
318326
$(INSTALL_M) $(build_private_libdir)/sys-debug.$(SHLIB_EXT) $(DESTDIR)$(private_libdir)
319327
endif
320328

329+
# Cache stdlibs
330+
@$(call PRINT_JULIA, $(call spawn,$(JULIA_EXECUTABLE)) --startup-file=no $(JULIAHOME)/contrib/cache_stdlibs.jl)
331+
# CI uses `--check-bounds=yes` which impacts the cache flags
332+
@$(call PRINT_JULIA, $(call spawn,$(JULIA_EXECUTABLE)) --startup-file=no --check-bounds=yes $(JULIAHOME)/contrib/cache_stdlibs.jl)
333+
321334
# Copy in all .jl sources as well
322335
mkdir -p $(DESTDIR)$(datarootdir)/julia/base $(DESTDIR)$(datarootdir)/julia/test
323336
cp -R -L $(JULIAHOME)/base/* $(DESTDIR)$(datarootdir)/julia/base
@@ -371,8 +384,18 @@ endif
371384
fi;
372385
endif
373386

374-
# Set rpath for libjulia-internal, which is moving from `../lib` to `../lib/julia`. We only need to do this for Linux/FreeBSD
375-
ifneq (,$(findstring $(OS),Linux FreeBSD))
387+
# Set rpath for libjulia-internal, which is moving from `../lib` to `../lib/julia`.
388+
ifeq ($(OS), Darwin)
389+
ifneq ($(DARWIN_FRAMEWORK),1)
390+
ifeq ($(JULIA_BUILD_MODE),release)
391+
install_name_tool -add_rpath @loader_path/$(reverse_private_libdir_rel)/ $(DESTDIR)$(private_libdir)/libjulia-internal.$(SHLIB_EXT)
392+
install_name_tool -add_rpath @loader_path/$(reverse_private_libdir_rel)/ $(DESTDIR)$(private_libdir)/libjulia-codegen.$(SHLIB_EXT)
393+
else ifeq ($(JULIA_BUILD_MODE),debug)
394+
install_name_tool -add_rpath @loader_path/$(reverse_private_libdir_rel)/ $(DESTDIR)$(private_libdir)/libjulia-internal-debug.$(SHLIB_EXT)
395+
install_name_tool -add_rpath @loader_path/$(reverse_private_libdir_rel)/ $(DESTDIR)$(private_libdir)/libjulia-codegen-debug.$(SHLIB_EXT)
396+
endif
397+
endif
398+
else ifneq (,$(findstring $(OS),Linux FreeBSD))
376399
ifeq ($(JULIA_BUILD_MODE),release)
377400
$(PATCHELF) --set-rpath '$$ORIGIN:$$ORIGIN/$(reverse_private_libdir_rel)' $(DESTDIR)$(private_libdir)/libjulia-internal.$(SHLIB_EXT)
378401
$(PATCHELF) --set-rpath '$$ORIGIN:$$ORIGIN/$(reverse_private_libdir_rel)' $(DESTDIR)$(private_libdir)/libjulia-codegen.$(SHLIB_EXT)

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ Standard library changes
9898

9999
#### Package Manager
100100

101+
- "Package Extensions": support for loading a piece of code based on other
102+
packages being loaded in the Julia session.
103+
This has similar applications as the Requires.jl package but also
104+
supports precompilation and setting compatibility.
101105
#### LinearAlgebra
102106

103107
* The methods `a / b` and `b \ a` with `a` a scalar and `b` a vector, which were equivalent to `a * pinv(b)`,

base/Base.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ include("idset.jl")
168168
include("iterators.jl")
169169
using .Iterators: zip, enumerate, only
170170
using .Iterators: Flatten, Filter, product # for generators
171+
using .Iterators: Stateful # compat (was formerly used in reinterpretarray.jl)
171172

172173
include("namedtuple.jl")
173174

@@ -417,6 +418,7 @@ include("threadcall.jl")
417418
include("uuid.jl")
418419
include("pkgid.jl")
419420
include("toml_parser.jl")
421+
include("linking.jl")
420422
include("loading.jl")
421423

422424
# misc useful functions & macros

base/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ ifeq ($(DARWIN_FRAMEWORK), 1)
8181
@echo "const DARWIN_FRAMEWORK_NAME = \"$(FRAMEWORK_NAME)\"" >> $@
8282
else
8383
@echo "const DARWIN_FRAMEWORK = false" >> $@
84+
endif
85+
ifeq ($(OS), Darwin)
86+
@echo "const MACOS_PRODUCT_VERSION = \"$(shell sw_vers -productVersion)\"" >> $@
87+
@echo "const MACOS_PLATFORM_VERSION = \"$(shell xcrun --show-sdk-version)\"" >> $@
8488
endif
8589
@echo "const BUILD_TRIPLET = \"$(BB_TRIPLET_LIBGFORTRAN_CXXABI)\"" >> $@
8690

@@ -227,6 +231,8 @@ else
227231
$(eval $(call symlink_system_library,CSL,libgcc_s,1))
228232
endif
229233
endif
234+
else
235+
$(eval $(call symlink_system_library,CSL,libgcc_s,1))
230236
endif
231237
ifneq (,$(LIBGFORTRAN_VERSION))
232238
$(eval $(call symlink_system_library,CSL,libgfortran,$(LIBGFORTRAN_VERSION)))

base/array.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2730,7 +2730,8 @@ keepat!(a::Vector, m::AbstractVector{Bool}) = _keepat!(a, m)
27302730
# set-like operators for vectors
27312731
# These are moderately efficient, preserve order, and remove dupes.
27322732

2733-
_unique_filter!(pred, update!, state) = function (x)
2733+
_unique_filter!(pred::P, update!::U, state) where {P,U} = function (x)
2734+
# P, U force specialization
27342735
if pred(x, state)
27352736
update!(state, x)
27362737
true
@@ -2756,7 +2757,7 @@ union!(v::AbstractVector{T}, itrs...) where {T} =
27562757
symdiff!(v::AbstractVector{T}, itrs...) where {T} =
27572758
_grow!(_shrink_filter!(symdiff!(Set{T}(), v, itrs...)), v, itrs)
27582759

2759-
function _shrink!(shrinker!, v::AbstractVector, itrs)
2760+
function _shrink!(shrinker!::F, v::AbstractVector, itrs) where F
27602761
seen = Set{eltype(v)}()
27612762
filter!(_grow_filter!(seen), v)
27622763
shrinker!(seen, itrs...)
@@ -2768,7 +2769,7 @@ setdiff!( v::AbstractVector, itrs...) = _shrink!(setdiff!, v, itrs)
27682769

27692770
vectorfilter(T::Type, f, v) = T[x for x in v if f(x)]
27702771

2771-
function _shrink(shrinker!, itr, itrs)
2772+
function _shrink(shrinker!::F, itr, itrs) where F
27722773
T = promote_eltype(itr, itrs...)
27732774
keep = shrinker!(Set{T}(itr), itrs...)
27742775
vectorfilter(T, _shrink_filter!(keep), itr)

base/boot.jl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -503,16 +503,19 @@ Array{T}(A::AbstractArray{S,N}) where {T,N,S} = Array{T,N}(A)
503503
AbstractArray{T}(A::AbstractArray{S,N}) where {T,S,N} = AbstractArray{T,N}(A)
504504

505505
# primitive Symbol constructors
506+
507+
## Helper for proper GC rooting without unsafe_convert
508+
eval(Core, quote
509+
_Symbol(ptr::Ptr{UInt8}, sz::Int, root::Any) = $(Expr(:foreigncall, QuoteNode(:jl_symbol_n),
510+
Ref{Symbol}, svec(Ptr{UInt8}, Int), 0, QuoteNode(:ccall), :ptr, :sz, :root))
511+
end)
512+
506513
function Symbol(s::String)
507514
@_foldable_meta
508-
return ccall(:jl_symbol_n, Ref{Symbol}, (Ptr{UInt8}, Int),
509-
ccall(:jl_string_ptr, Ptr{UInt8}, (Any,), s),
510-
sizeof(s))
515+
return _Symbol(ccall(:jl_string_ptr, Ptr{UInt8}, (Any,), s), sizeof(s), s)
511516
end
512517
function Symbol(a::Array{UInt8,1})
513-
return ccall(:jl_symbol_n, Ref{Symbol}, (Ptr{UInt8}, Int),
514-
ccall(:jl_array_ptr, Ptr{UInt8}, (Any,), a),
515-
Intrinsics.arraylen(a))
518+
return _Symbol(ccall(:jl_array_ptr, Ptr{UInt8}, (Any,), a), Intrinsics.arraylen(a), a)
516519
end
517520
Symbol(s::Symbol) = s
518521

@@ -617,8 +620,7 @@ end
617620

618621
NamedTuple() = NamedTuple{(),Tuple{}}(())
619622

620-
eval(Core, :(NamedTuple{names}(args::Tuple) where {names} =
621-
$(Expr(:splatnew, :(NamedTuple{names,typeof(args)}), :args))))
623+
NamedTuple{names}(args::Tuple) where {names} = NamedTuple{names,typeof(args)}(args)
622624

623625
using .Intrinsics: sle_int, add_int
624626

base/compiler/abstractinterpretation.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,16 +2180,16 @@ function abstract_eval_statement_expr(interp::AbstractInterpreter, e::Expr, vtyp
21802180
elseif ehead === :splatnew
21812181
t, isexact = instanceof_tfunc(abstract_eval_value(interp, e.args[1], vtypes, sv))
21822182
nothrow = false # TODO: More precision
2183-
if length(e.args) == 2 && isconcretedispatch(t) && !ismutabletype(t)
2183+
if length(e.args) == 2 && isconcretetype(t) && !ismutabletype(t)
21842184
at = abstract_eval_value(interp, e.args[2], vtypes, sv)
21852185
n = fieldcount(t)
21862186
if isa(at, Const) && isa(at.val, Tuple) && n == length(at.val::Tuple) &&
2187-
let t = t, at = at; all(i::Int->getfield(at.val::Tuple, i) isa fieldtype(t, i), 1:n); end
2188-
nothrow = isexact
2187+
let t = t, at = at; _all(i->getfield(at.val::Tuple, i) isa fieldtype(t, i), 1:n); end
2188+
nothrow = isexact && isconcretedispatch(t)
21892189
t = Const(ccall(:jl_new_structt, Any, (Any, Any), t, at.val))
2190-
elseif isa(at, PartialStruct) && at Tuple && n == length(at.fields::Vector{Any}) &&
2191-
let t = t, at = at; all(i::Int->(at.fields::Vector{Any})[i] fieldtype(t, i), 1:n); end
2192-
nothrow = isexact
2190+
elseif isa(at, PartialStruct) && at Tuple && n == length(at.fields::Vector{Any}) &&
2191+
let t = t, at = at; _all(i->(at.fields::Vector{Any})[i] fieldtype(t, i), 1:n); end
2192+
nothrow = isexact && isconcretedispatch(t)
21932193
t = PartialStruct(t, at.fields::Vector{Any})
21942194
end
21952195
end

base/compiler/ssair/passes.jl

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -401,16 +401,6 @@ function lift_leaves(compact::IncrementalCompact,
401401
end
402402
lift_arg!(compact, leaf, cache_key, def, 1+field, lifted_leaves)
403403
continue
404-
# NOTE we can enable this, but most `:splatnew` expressions are transformed into
405-
# `:new` expressions by the inlinear
406-
# elseif isexpr(def, :splatnew) && length(def.args) == 2 && isa(def.args[2], AnySSAValue)
407-
# tplssa = def.args[2]::AnySSAValue
408-
# tplexpr = compact[tplssa][:inst]
409-
# if is_known_call(tplexpr, tuple, compact) && 1 ≤ field < length(tplexpr.args)
410-
# lift_arg!(compact, tplssa, cache_key, tplexpr, 1+field, lifted_leaves)
411-
# continue
412-
# end
413-
# return nothing
414404
elseif is_getfield_captures(def, compact)
415405
# Walk to new_opaque_closure
416406
ocleaf = def.args[2]
@@ -479,7 +469,7 @@ function lift_arg!(
479469
end
480470
end
481471
lifted_leaves[cache_key] = LiftedValue(lifted)
482-
return nothing
472+
nothing
483473
end
484474

485475
function walk_to_def(compact::IncrementalCompact, @nospecialize(leaf))

0 commit comments

Comments
 (0)