diff --git a/Makefile b/Makefile index 94df626014059..2c6524be3a58a 100644 --- a/Makefile +++ b/Makefile @@ -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` @@ -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 diff --git a/base/docs/Docs.jl b/base/docs/Docs.jl index b84b3ee8d55f4..e7ecfd3bf3959 100644 --- a/base/docs/Docs.jl +++ b/base/docs/Docs.jl @@ -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 @@ -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) diff --git a/base/regex.jl b/base/regex.jl index ad26c18d4c581..6ae1415728ac6 100644 --- a/base/regex.jl +++ b/base/regex.jl @@ -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 diff --git a/deps/Versions.make b/deps/Versions.make index f507b3c9fba32..d24450cd01336 100644 --- a/deps/Versions.make +++ b/deps/Versions.make @@ -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 diff --git a/deps/llvm-ver.make b/deps/llvm-ver.make index c2c7f2bc56da7..3c498be6c2363 100644 --- a/deps/llvm-ver.make +++ b/deps/llvm-ver.make @@ -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 @@ -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) diff --git a/deps/llvm.mk b/deps/llvm.mk index 7c4c2d60dfd9a..61210728e6ffb 100644 --- a/deps/llvm.mk +++ b/deps/llvm.mk @@ -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)" @@ -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 diff --git a/deps/llvm.version b/deps/llvm.version index e55705dc61da4..c196e6f6028b6 100644 --- a/deps/llvm.version +++ b/deps/llvm.version @@ -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 diff --git a/deps/p7zip.mk b/deps/p7zip.mk index 8c0d11d74a061..13f0dd55c332d 100644 --- a/deps/p7zip.mk +++ b/deps/p7zip.mk @@ -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) $< diff --git a/doc/src/manual/control-flow.md b/doc/src/manual/control-flow.md index 63832cc4c90c9..72d57a761f155 100644 --- a/doc/src/manual/control-flow.md +++ b/doc/src/manual/control-flow.md @@ -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 diff --git a/doc/src/manual/variables-and-scoping.md b/doc/src/manual/variables-and-scoping.md index 6e94037f3e564..8c073bf84c88f 100644 --- a/doc/src/manual/variables-and-scoping.md +++ b/doc/src/manual/variables-and-scoping.md @@ -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 diff --git a/src/Makefile b/src/Makefile index 8ef266c8e42d3..424d4a9941ed8 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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) diff --git a/src/gf.c b/src/gf.c index 855a138186b93..6840545fee52c 100644 --- a/src/gf.c +++ b/src/gf.c @@ -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); diff --git a/stdlib/CompilerSupportLibraries_jll/src/CompilerSupportLibraries_jll.jl b/stdlib/CompilerSupportLibraries_jll/src/CompilerSupportLibraries_jll.jl index 0068414f942e8..097659e01b396 100644 --- a/stdlib/CompilerSupportLibraries_jll/src/CompilerSupportLibraries_jll.jl +++ b/stdlib/CompilerSupportLibraries_jll/src/CompilerSupportLibraries_jll.jl @@ -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" @@ -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) diff --git a/stdlib/CompilerSupportLibraries_jll/test/runtests.jl b/stdlib/CompilerSupportLibraries_jll/test/runtests.jl index 840a36bdd8d49..85cf132c3a5bd 100644 --- a/stdlib/CompilerSupportLibraries_jll/test/runtests.jl +++ b/stdlib/CompilerSupportLibraries_jll/test/runtests.jl @@ -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 diff --git a/stdlib/LinearAlgebra/src/adjtrans.jl b/stdlib/LinearAlgebra/src/adjtrans.jl index fdca270e28aee..97e5998f684db 100644 --- a/stdlib/LinearAlgebra/src/adjtrans.jl +++ b/stdlib/LinearAlgebra/src/adjtrans.jl @@ -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)...)) diff --git a/stdlib/REPL/src/docview.jl b/stdlib/REPL/src/docview.jl index 66f2aba86384d..c9bba03941292 100644 --- a/stdlib/REPL/src/docview.jl +++ b/stdlib/REPL/src/docview.jl @@ -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) @@ -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{}) @@ -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