Skip to content

Commit 75c1e04

Browse files
authored
Merge pull request #43667 from JuliaLang/backports-release-1.7
release-1.7: Backports for 1.7.2
2 parents 3f024fd + 5e045a1 commit 75c1e04

29 files changed

+289
-76
lines changed

base/broadcast.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ function Broadcasted{Style}(f::F, args::Args, axes=nothing) where {Style, F, Arg
180180
end
181181

182182
struct AndAnd end
183-
andand = AndAnd()
183+
const andand = AndAnd()
184184
broadcasted(::AndAnd, a, b) = broadcasted((a, b) -> a && b, a, b)
185185
function broadcasted(::AndAnd, a, bc::Broadcasted)
186186
bcf = flatten(bc)

base/cmd.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ byteenv(env::Union{AbstractVector{Pair{T,V}}, Tuple{Vararg{Pair{T,V}}}}) where {
230230
String[cstr(k*"="*string(v)) for (k,v) in env]
231231

232232
"""
233-
setenv(command::Cmd, env; dir="")
233+
setenv(command::Cmd, env; dir)
234234
235235
Set environment variables to use when running the given `command`. `env` is either a
236236
dictionary mapping strings to strings, an array of strings of the form `"var=val"`, or
@@ -239,13 +239,15 @@ existing environment, create `env` through `copy(ENV)` and then setting `env["va
239239
as desired, or use [`addenv`](@ref).
240240
241241
The `dir` keyword argument can be used to specify a working directory for the command.
242+
`dir` defaults to the currently set `dir` for `command` (which is the current working
243+
directory if not specified already).
242244
243245
See also [`Cmd`](@ref), [`addenv`](@ref), [`ENV`](@ref), [`pwd`](@ref).
244246
"""
245-
setenv(cmd::Cmd, env; dir="") = Cmd(cmd; env=byteenv(env), dir=dir)
246-
setenv(cmd::Cmd, env::Pair{<:AbstractString}...; dir="") =
247+
setenv(cmd::Cmd, env; dir=cmd.dir) = Cmd(cmd; env=byteenv(env), dir=dir)
248+
setenv(cmd::Cmd, env::Pair{<:AbstractString}...; dir=cmd.dir) =
247249
setenv(cmd, env; dir=dir)
248-
setenv(cmd::Cmd; dir="") = Cmd(cmd; dir=dir)
250+
setenv(cmd::Cmd; dir=cmd.dir) = Cmd(cmd; dir=dir)
249251

250252
"""
251253
addenv(command::Cmd, env...; inherit::Bool = true)

base/error.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ struct ExceptionStack <: AbstractArray{Any,1}
128128
end
129129

130130
"""
131-
current_exceptions(task=current_task(); [inclue_bt=true])
131+
current_exceptions(task::Task=current_task(); [backtrace::Bool=true])
132132
133133
Get the stack of exceptions currently being handled. For nested catch blocks
134134
there may be more than one current exception in which case the most recently
@@ -145,7 +145,7 @@ uncaught exceptions.
145145
This function went by the experimental name `catch_stack()` in Julia
146146
1.1–1.6, and had a plain Vector-of-tuples as a return type.
147147
"""
148-
function current_exceptions(task=current_task(); backtrace=true)
148+
function current_exceptions(task::Task=current_task(); backtrace::Bool=true)
149149
raw = ccall(:jl_get_excstack, Any, (Any,Cint,Cint), task, backtrace, typemax(Cint))::Vector{Any}
150150
formatted = Any[]
151151
stride = backtrace ? 3 : 1

base/expr.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,12 +441,16 @@ macro generated(f)
441441
if isa(f, Expr) && (f.head === :function || is_short_function_def(f))
442442
body = f.args[2]
443443
lno = body.args[1]
444+
tmp = gensym("tmp")
444445
return Expr(:escape,
445446
Expr(f.head, f.args[1],
446447
Expr(:block,
447448
lno,
448449
Expr(:if, Expr(:generated),
449-
body,
450+
# https://github.com/JuliaLang/julia/issues/25678
451+
Expr(:block,
452+
:(local $tmp = $body),
453+
:(if $tmp isa $(GlobalRef(Core, :CodeInfo)); return $tmp; else $tmp; end)),
450454
Expr(:block,
451455
Expr(:meta, :generated_only),
452456
Expr(:return, nothing))))))
@@ -464,7 +468,7 @@ Mark `var` or `ex` as being performed atomically, if `ex` is a supported express
464468
465469
@atomic a.b.x = new
466470
@atomic a.b.x += addend
467-
@atomic :acquire_release a.b.x = new
471+
@atomic :release a.b.x = new
468472
@atomic :acquire_release a.b.x += addend
469473
470474
Perform the store operation expressed on the right atomically and return the

base/reducedim.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ for (f1, f2, initval, typeextreme) in ((:min, :max, :Inf, :typemax), (:max, :min
139139

140140
if isempty(A1)
141141
# If the slice is empty just return non-view version as the initial array
142-
return copy(A1)
142+
return map(f, A1)
143143
else
144144
# otherwise use the min/max of the first slice as initial value
145145
v0 = mapreduce(f, $f2, A1)
@@ -148,9 +148,9 @@ for (f1, f2, initval, typeextreme) in ((:min, :max, :Inf, :typemax), (:max, :min
148148
Tr = v0 isa T ? T : typeof(v0)
149149

150150
# but NaNs and missing need to be avoided as initial values
151-
if (v0 == v0) === false
151+
if v0 isa Number && isnan(v0)
152152
# v0 is NaN
153-
v0 = $initval
153+
v0 = oftype(v0, $initval)
154154
elseif isunordered(v0)
155155
# v0 is missing or a third-party unordered value
156156
Tnm = nonmissingtype(Tr)

base/util.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,9 @@ function runtests(tests = ["all"]; ncores::Int = ceil(Int, Sys.CPU_THREADS::Int
622622
seed !== nothing && push!(tests, "--seed=0x$(string(seed % UInt128, base=16))") # cast to UInt128 to avoid a minus sign
623623
ENV2 = copy(ENV)
624624
ENV2["JULIA_CPU_THREADS"] = "$ncores"
625+
ENV2["JULIA_DEPOT_PATH"] = mktempdir(; cleanup = true)
626+
delete!(ENV2, "JULIA_LOAD_PATH")
627+
delete!(ENV2, "JULIA_PROJECT")
625628
try
626629
run(setenv(`$(julia_cmd()) $(joinpath(Sys.BINDIR::String,
627630
Base.DATAROOTDIR, "julia", "test", "runtests.jl")) $tests`, ENV2))

cli/loader_lib.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,18 @@ __attribute__((constructor)) void jl_load_libjulia_internal(void) {
182182
}
183183
(*jl_exported_func_addrs[symbol_idx]) = addr;
184184
}
185+
// Next, if we're on Linux/FreeBSD, set up fast TLS.
186+
#if !defined(_OS_WINDOWS_) && !defined(_OS_DARWIN_)
187+
void (*jl_pgcstack_setkey)(void*, void*(*)(void)) = lookup_symbol(libjulia_internal, "jl_pgcstack_setkey");
188+
if (jl_pgcstack_setkey == NULL) {
189+
jl_loader_print_stderr("ERROR: Cannot find jl_pgcstack_setkey() function within libjulia-internal!\n");
190+
exit(1);
191+
}
192+
void *fptr = lookup_symbol(RTLD_DEFAULT, "jl_get_pgcstack_static");
193+
void *(*key)(void) = lookup_symbol(RTLD_DEFAULT, "jl_pgcstack_addr_static");
194+
if (fptr != NULL && key != NULL)
195+
jl_pgcstack_setkey(fptr, key);
196+
#endif
185197

186198
// jl_options must be initialized very early, in case an embedder sets some
187199
// values there before calling jl_init
@@ -199,22 +211,6 @@ JL_DLLEXPORT int jl_load_repl(int argc, char * argv[]) {
199211
exit(1);
200212
}
201213
}
202-
// Next, if we're on Linux/FreeBSD, set up fast TLS.
203-
#if !defined(_OS_WINDOWS_) && !defined(_OS_DARWIN_)
204-
void (*jl_pgcstack_setkey)(void*, void*(*)(void)) = lookup_symbol(libjulia_internal, "jl_pgcstack_setkey");
205-
if (jl_pgcstack_setkey == NULL) {
206-
jl_loader_print_stderr("ERROR: Cannot find jl_pgcstack_setkey() function within libjulia-internal!\n");
207-
exit(1);
208-
}
209-
void *fptr = lookup_symbol(RTLD_DEFAULT, "jl_get_pgcstack_static");
210-
void *(*key)(void) = lookup_symbol(RTLD_DEFAULT, "jl_pgcstack_addr_static");
211-
if (fptr == NULL || key == NULL) {
212-
jl_loader_print_stderr("ERROR: Cannot find jl_get_pgcstack_static(), must define this symbol within calling executable!\n");
213-
exit(1);
214-
}
215-
jl_pgcstack_setkey(fptr, key);
216-
#endif
217-
218214
// Load the repl entrypoint symbol and jump into it!
219215
int (*entrypoint)(int, char **) = (int (*)(int, char **))lookup_symbol(libjulia_internal, "jl_repl_entrypoint");
220216
if (entrypoint == NULL) {

contrib/generate_precompile.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ generate_precompile_statements()
417417

418418
# As a last step in system image generation,
419419
# remove some references to build time environment for a more reproducible build.
420+
Base.Filesystem.temp_cleanup_purge(force=true)
420421
@eval Base PROGRAM_FILE = ""
421422
@eval Sys begin
422423
BINDIR = ""

src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ endif
119119
CLANG_LDFLAGS := $(LLVM_LDFLAGS)
120120
ifeq ($(OS), Darwin)
121121
CLANG_LDFLAGS += -Wl,-undefined,dynamic_lookup
122+
OSLIBS += $(SRCDIR)/mach_dyld_atfork.tbd
122123
endif
123124

124125
COMMON_LIBPATHS := -L$(build_libdir) -L$(build_shlibdir)

src/builtins.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -861,9 +861,9 @@ JL_CALLABLE(jl_f_getfield)
861861
enum jl_memory_order order = jl_memory_order_unspecified;
862862
JL_NARGS(getfield, 2, 4);
863863
if (nargs == 4) {
864-
JL_TYPECHK(getfield, symbol, args[3]);
865-
JL_TYPECHK(getfield, bool, args[4]);
866-
order = jl_get_atomic_order_checked((jl_sym_t*)args[3], 1, 0);
864+
JL_TYPECHK(getfield, symbol, args[2]);
865+
JL_TYPECHK(getfield, bool, args[3]);
866+
order = jl_get_atomic_order_checked((jl_sym_t*)args[2], 1, 0);
867867
}
868868
else if (nargs == 3) {
869869
if (!jl_is_bool(args[2])) {

0 commit comments

Comments
 (0)