Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backports for Julia 1.8.6 #48556

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
JULIAHOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
include $(JULIAHOME)/Make.inc
# import LLVM_SHARED_LIB_NAME
include $(JULIAHOME)/deps/llvm-ver.make

VERSDIR := v`cut -d. -f1-2 < $(JULIAHOME)/VERSION`

Expand Down Expand Up @@ -190,7 +192,7 @@ else
JL_PRIVATE_LIBS-$(USE_SYSTEM_ZLIB) += libz
endif
ifeq ($(USE_LLVM_SHLIB),1)
JL_PRIVATE_LIBS-$(USE_SYSTEM_LLVM) += libLLVM libLLVM-13jl
JL_PRIVATE_LIBS-$(USE_SYSTEM_LLVM) += libLLVM $(LLVM_SHARED_LIB_NAME)
endif
JL_PRIVATE_LIBS-$(USE_SYSTEM_LIBUNWIND) += libunwind

Expand Down
7 changes: 4 additions & 3 deletions base/docs/Docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ const modules = Module[]
const META = gensym(:meta)
const METAType = IdDict{Any,Any}

function meta(m::Module)
function meta(m::Module; autoinit::Bool=true)
if !isdefined(m, META) || getfield(m, META) === nothing
initmeta(m)
autoinit ? initmeta(m) : return nothing
end
return getfield(m, META)::METAType
end
Expand Down Expand Up @@ -161,7 +161,8 @@ end
function docstr(binding::Binding, typesig = Union{})
@nospecialize typesig
for m in modules
dict = meta(m)
dict = meta(m; autoinit=false)
isnothing(dict) && continue
if haskey(dict, binding)
docs = dict[binding].docs
if haskey(docs, typesig)
Expand Down
4 changes: 2 additions & 2 deletions base/regex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ That is, `idx` will be in the return value even if `m[idx] == nothing`.
Unnamed capture groups will have integer keys corresponding to their index.
Named capture groups will have string keys.

!!! compat "Julia 1.6"
This method was added in Julia 1.6
!!! compat "Julia 1.7"
This method was added in Julia 1.7

# Examples
```jldoctest
Expand Down
1 change: 0 additions & 1 deletion deps/Versions.make
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ LIBUV_VER := 2
LIBUV_JLL_NAME := LibUV

# LLVM
LLVM_VER := 13.0.1
LLVM_ASSERT_JLL_VER := 13.0.1+3
LLVM_JLL_NAME := libLLVM

Expand Down
7 changes: 7 additions & 0 deletions deps/llvm-ver.make
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include $(JULIAHOME)/deps/llvm.version

LLVM_VER_MAJ:=$(word 1, $(subst ., ,$(LLVM_VER)))
LLVM_VER_MIN:=$(word 2, $(subst ., ,$(LLVM_VER)))
# define a "short" LLVM version for easy comparisons
Expand All @@ -10,3 +12,8 @@ LLVM_VER_PATCH:=$(word 3, $(subst ., ,$(LLVM_VER)))
ifeq ($(LLVM_VER_PATCH),)
LLVM_VER_PATCH := 0
endif

LLVM_SHARED_LIB_VER_SUFFIX := $(LLVM_VER_MAJ)jl
# e.g.: "libLLVM-14jl"
LLVM_SHARED_LIB_NAME := libLLVM-$(LLVM_SHARED_LIB_VER_SUFFIX)
LLVM_SHARED_LINK_FLAG := -lLLVM-$(LLVM_SHARED_LIB_VER_SUFFIX)
8 changes: 4 additions & 4 deletions deps/llvm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ LLVM_CMAKE += -DCMAKE_EXE_LINKER_FLAGS="$(LLVM_LDFLAGS)" \
-DCMAKE_SHARED_LINKER_FLAGS="$(LLVM_LDFLAGS)"

# change the SONAME of Julia's private LLVM
# i.e. libLLVM-6.0jl.so
# i.e. libLLVM-14jl.so
# see #32462
LLVM_CMAKE += -DLLVM_VERSION_SUFFIX:STRING="jl"
LLVM_CMAKE += -DLLVM_SHLIB_SYMBOL_VERSION:STRING="JL_LLVM_$(LLVM_VER_SHORT)"
Expand Down Expand Up @@ -255,10 +255,10 @@ endif

LLVM_INSTALL = \
cd $1 && mkdir -p $2$$(build_depsbindir) && \
cp -r $$(SRCCACHE)/$$(LLVM_SRC_DIR)/llvm/utils/lit $2$$(build_depsbindir)/ && \
$$(CMAKE) -DCMAKE_INSTALL_PREFIX="$2$$(build_prefix)" -P cmake_install.cmake
cp -r $$(SRCCACHE)/$$(LLVM_SRC_DIR)/llvm/utils/lit $2$$(build_depsbindir)/ && \
$$(CMAKE) -DCMAKE_INSTALL_PREFIX="$2$$(build_prefix)" -P cmake_install.cmake
ifeq ($(OS), WINNT)
LLVM_INSTALL += && cp $2$$(build_shlibdir)/libLLVM.dll $2$$(build_depsbindir)
LLVM_INSTALL += && cp $2$$(build_shlibdir)/$(LLVM_SHARED_LIB_NAME).dll $2$$(build_depsbindir)
endif
ifeq ($(OS),Darwin)
# https://github.com/JuliaLang/julia/issues/29981
Expand Down
2 changes: 2 additions & 0 deletions deps/llvm.version
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
## source build
LLVM_VER := 13.0.1
LLVM_BRANCH=julia-13.0.1-3
LLVM_SHA1=julia-13.0.1-3
2 changes: 1 addition & 1 deletion deps/p7zip.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
ifneq ($(USE_BINARYBUILDER_P7ZIP),1)

$(SRCCACHE)/p7zip-$(P7ZIP_VER).tar.gz: | $(SRCCACHE)
$(JLDOWNLOAD) $@ https://github.com/jinfeihan57/p7zip/archive/refs/tags/v$(P7ZIP_VER).tar.gz
$(JLDOWNLOAD) $@ https://github.com/p7zip-project/p7zip/archive/refs/tags/v$(P7ZIP_VER).tar.gz

$(BUILDDIR)/p7zip-$(P7ZIP_VER)/source-extracted: $(SRCCACHE)/p7zip-$(P7ZIP_VER).tar.gz
$(JLCHECKSUM) $<
Expand Down
38 changes: 38 additions & 0 deletions doc/src/manual/control-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,44 @@ no error has occurred, but the ability to unwind the stack and pass a value to a
is desirable. Julia provides the [`rethrow`](@ref), [`backtrace`](@ref), [`catch_backtrace`](@ref)
and [`current_exceptions`](@ref) functions for more advanced error handling.

### `else` Clauses

!!! compat "Julia 1.8"
This functionality requires at least Julia 1.8.

In some cases, one may not only want to appropriately handle the error case, but also want to run
some code only if the `try` block succeeds. For this, an `else` clause can be specified after the
`catch` block that is run whenever no error was thrown previously. The advantage over including
this code in the `try` block instead is that any further errors don't get silently caught by the
`catch` clause.

```julia
local x
try
x = read("file", String)
catch
# handle read errors
else
# do something with x
end
```

!!! note
The `try`, `catch`, `else`, and `finally` clauses each introduce their own scope blocks, so if
a variable is only defined in the `try` block, it can not be accessed by the `else` or `finally`
clause:
```jldoctest
julia> try
foo = 1
catch
else
foo
end
ERROR: UndefVarError: `foo` not defined
```
Use the [`local` keyword](@ref local-scope) outside the `try` block to make the variable
accessible from anywhere within the outer scope.

### `finally` Clauses

In code that performs state changes or uses resources like files, there is typically clean-up
Expand Down
2 changes: 1 addition & 1 deletion doc/src/manual/variables-and-scoping.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ x = 1

Note that the interactive prompt (aka REPL) is in the global scope of the module `Main`.

## Local Scope
## [Local Scope](@id local-scope)

A new local scope is introduced by most code blocks (see above [table](@ref
man-scope-table) for a complete list). If such a block is syntactically nested
Expand Down
15 changes: 10 additions & 5 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,24 +122,29 @@ endif

ifeq ($(JULIACODEGEN),LLVM)
ifneq ($(USE_SYSTEM_LLVM),0)
# USE_SYSTEM_LLVM != 0
CG_LLVMLINK += $(LLVM_LDFLAGS) $(shell $(LLVM_CONFIG_HOST) --libs --system-libs)
# HACK: llvm-config doesn't correctly point to shared libs on all platforms
# https://github.com/JuliaLang/julia/issues/29981
else
# USE_SYSTEM_LLVM == 0
ifneq ($(USE_LLVM_SHLIB),1)
# USE_LLVM_SHLIB != 1
CG_LLVMLINK += $(LLVM_LDFLAGS) $(shell $(LLVM_CONFIG_HOST) --libs $(CG_LLVM_LIBS) --link-static) $($(LLVM_LDFLAGS) $(shell $(LLVM_CONFIG_HOST) --system-libs 2> /dev/null)
else
# USE_LLVM_SHLIB == 1
ifeq ($(OS), Darwin)
CG_LLVMLINK += $(LLVM_LDFLAGS) -lLLVM
else
CG_LLVMLINK += $(LLVM_LDFLAGS) -lLLVM-13jl
endif
endif
endif
CG_LLVMLINK += $(LLVM_LDFLAGS) $(LLVM_SHARED_LINK_FLAG)
endif # OS
endif # USE_LLVM_SHLIB
endif # USE_SYSTEM_LLVM

ifeq ($(USE_LLVM_SHLIB),1)
FLAGS += -DLLVM_SHLIB
endif # USE_LLVM_SHLIB == 1
endif
endif # JULIACODEGEN == LLVM

RT_LLVM_LINK_ARGS := $(shell $(LLVM_CONFIG_HOST) --libs $(RT_LLVM_LIBS) --system-libs --link-static)
RT_LLVMLINK += $(LLVM_LDFLAGS) $(RT_LLVM_LINK_ARGS)
Expand Down
2 changes: 0 additions & 2 deletions src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,6 @@ jl_code_info_t *jl_type_infer(jl_method_instance_t *mi, size_t world, int force)
#ifdef ENABLE_INFERENCE
if (mi->inInference && !force)
return NULL;
if (jl_is_method(mi->def.method) && mi->def.method->unspecialized == mi)
return NULL; // be careful never to infer the unspecialized method, this would not be valid

jl_value_t **fargs;
JL_GC_PUSHARGS(fargs, 3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ libstdcxx_handle = C_NULL
libstdcxx_path = ""
libgomp_handle = C_NULL
libgomp_path = ""
libssp_handle = C_NULL
libssp_path = ""

if Sys.iswindows()
if arch(HostPlatform()) == "x86_64"
Expand Down Expand Up @@ -64,8 +62,7 @@ function __init__()
global libgomp_handle = dlopen(libgomp)
global libgomp_path = dlpath(libgomp_handle)
@static if libc(HostPlatform()) != "musl"
global libssp_handle = dlopen(libssp)
global libssp_path = dlpath(libssp_handle)
dlopen(libssp; throw_error = false)
end
global artifact_dir = dirname(Sys.BINDIR)
LIBPATH[] = dirname(libgcc_s_path)
Expand Down
5 changes: 1 addition & 4 deletions stdlib/CompilerSupportLibraries_jll/test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

using Test, CompilerSupportLibraries_jll, Base.BinaryPlatforms
using Test, CompilerSupportLibraries_jll

@testset "CompilerSupportLibraries_jll" begin
@test isfile(CompilerSupportLibraries_jll.libgcc_s_path)
@test isfile(CompilerSupportLibraries_jll.libgfortran_path)
@test isfile(CompilerSupportLibraries_jll.libstdcxx_path)
@test isfile(CompilerSupportLibraries_jll.libgomp_path)
if libc(HostPlatform()) != "musl"
@test isfile(CompilerSupportLibraries_jll.libssp_path)
end
end
1 change: 1 addition & 0 deletions stdlib/LinearAlgebra/src/adjtrans.jl
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ Base.mapreducedim!(f::typeof(identity), op::Union{typeof(*),typeof(Base.mul_prod
(Base.mapreducedim!(f∘adjoint, op, switch_dim12(B), parent(A)); B)

switch_dim12(B::AbstractVector) = permutedims(B)
switch_dim12(B::AbstractVector{<:Number}) = transpose(B) # avoid allocs due to permutedims
switch_dim12(B::AbstractArray{<:Any,0}) = B
switch_dim12(B::AbstractArray) = PermutedDimsArray(B, (2, 1, ntuple(Base.Fix1(+,2), ndims(B) - 2)...))

Expand Down
10 changes: 7 additions & 3 deletions stdlib/REPL/src/docview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ function doc(binding::Binding, sig::Type = Union{})
results, groups = DocStr[], MultiDoc[]
# Lookup `binding` and `sig` for matches in all modules of the docsystem.
for mod in modules
dict = meta(mod)
dict = meta(mod; autoinit=false)
isnothing(dict) && continue
if haskey(dict, binding)
multidoc = dict[binding]
push!(groups, multidoc)
Expand Down Expand Up @@ -558,7 +559,8 @@ Return documentation for a particular `field` of a type if it exists.
"""
function fielddoc(binding::Binding, field::Symbol)
for mod in modules
dict = meta(mod)
dict = meta(mod; autoinit=false)
isnothing(dict) && continue
if haskey(dict, binding)
multidoc = dict[binding]
if haskey(multidoc.docs, Union{})
Expand Down Expand Up @@ -813,7 +815,9 @@ function apropos(io::IO, needle::Regex)
for mod in modules
# Module doc might be in README.md instead of the META dict
docsearch(doc(mod), needle) && println(io, mod)
for (k, v) in meta(mod)
dict = meta(mod; autoinit=false)
isnothing(dict) && continue
for (k, v) in dict
docsearch(v, needle) && println(io, k)
end
end
Expand Down