diff --git a/base/exports.jl b/base/exports.jl index bbc505393a62e..0414cce8fd603 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -8,7 +8,6 @@ export StackTraces, Sys, Libc, - Libdl, LinAlg, BLAS, LAPACK, diff --git a/base/linalg/blas.jl b/base/linalg/blas.jl index 02faac2e8b362..1314affb0023b 100644 --- a/base/linalg/blas.jl +++ b/base/linalg/blas.jl @@ -65,6 +65,8 @@ const liblapack = Base.liblapack_name import ..LinAlg: BlasReal, BlasComplex, BlasFloat, BlasInt, DimensionMismatch, checksquare, stride1, chkstride1, axpy! +import Libdl + # utility routines function vendor() lib = Libdl.dlopen_e(Base.libblas_name) diff --git a/base/sysimg.jl b/base/sysimg.jl index e8b57aaa39a50..9cf2699a6f343 100644 --- a/base/sysimg.jl +++ b/base/sysimg.jl @@ -294,8 +294,13 @@ include("version.jl") include("sysinfo.jl") include("libc.jl") using .Libc: getpid, gethostname, time -include("libdl.jl") -using .Libdl: DL_LOAD_PATH + +const DL_LOAD_PATH = String[] +if Sys.isapple() + push!(DL_LOAD_PATH, "@loader_path/julia") + push!(DL_LOAD_PATH, "@loader_path") +end + include("env.jl") # Scheduling @@ -409,12 +414,6 @@ include("client.jl") # misc useful functions & macros include("util.jl") -# dense linear algebra -include("linalg/linalg.jl") -using .LinAlg -const ⋅ = dot -const × = cross - # statistics include("statistics.jl") @@ -427,12 +426,6 @@ include("libgit2/libgit2.jl") # package manager include("pkg/pkg.jl") -# sparse matrices, vectors, and sparse linear algebra -include("sparse/sparse.jl") -using .SparseArrays - -include("asyncmap.jl") - # worker threads include("threadcall.jl") @@ -448,6 +441,18 @@ import Base64 INCLUDE_STATE = 2 +# dense linear algebra +include("linalg/linalg.jl") +using .LinAlg +const ⋅ = dot +const × = cross + +# sparse matrices, vectors, and sparse linear algebra +include("sparse/sparse.jl") +using .SparseArrays + +include("asyncmap.jl") + include("multimedia.jl") using .Multimedia @@ -505,6 +510,7 @@ Base.require(:Unicode) Base.require(:Distributed) Base.require(:Printf) Base.require(:Future) +Base.require(:Libdl) @eval Base begin @deprecate_binding Test root_module(:Test) true ", run `using Test` instead" diff --git a/doc/make.jl b/doc/make.jl index e67f63e768003..f60f5d32fc54e 100644 --- a/doc/make.jl +++ b/doc/make.jl @@ -34,6 +34,7 @@ if Sys.iswindows() cp_q("../stdlib/Unicode/docs/src/index.md", "src/stdlib/unicode.md") cp_q("../stdlib/Distributed/docs/src/index.md", "src/stdlib/distributed.md") cp_q("../stdlib/Printf/docs/src/index.md", "src/stdlib/printf.md") + cp_q("../stdlib/Libdl/docs/src/index.md", "src/stdlib/libdl.md") else symlink_q("../../../stdlib/DelimitedFiles/docs/src/index.md", "src/stdlib/delimitedfiles.md") symlink_q("../../../stdlib/Test/docs/src/index.md", "src/stdlib/test.md") @@ -48,6 +49,7 @@ else symlink_q("../../../stdlib/Unicode/docs/src/index.md", "src/stdlib/unicode.md") symlink_q("../../../stdlib/Distributed/docs/src/index.md", "src/stdlib/distributed.md") symlink_q("../../../stdlib/Printf/docs/src/index.md", "src/stdlib/printf.md") + symlink_q("../../../stdlib/Libdl/docs/src/index.md", "src/stdlib/libdl.md") end const PAGES = [ @@ -128,6 +130,7 @@ const PAGES = [ "stdlib/iterativeeigensolvers.md", "stdlib/unicode.md", "stdlib/printf.md", + "stdlib/libdl.md", ], "Developer Documentation" => [ "devdocs/reflection.md", @@ -163,12 +166,12 @@ const PAGES = [ ] using DelimitedFiles, Test, Mmap, SharedArrays, Profile, Base64, FileWatching, CRC32c, - Dates, IterativeEigensolvers, Unicode, Distributed, Printf + Dates, IterativeEigensolvers, Unicode, Distributed, Printf, Libdl makedocs( build = joinpath(pwd(), "_build/html/en"), modules = [Base, Core, BuildSysImg, DelimitedFiles, Test, Mmap, SharedArrays, Profile, - Base64, FileWatching, Dates, IterativeEigensolvers, Unicode, Distributed, Printf], + Base64, FileWatching, Dates, IterativeEigensolvers, Unicode, Distributed, Printf, Libdl], clean = false, doctest = "doctest" in ARGS, linkcheck = "linkcheck" in ARGS, diff --git a/doc/src/stdlib/base.md b/doc/src/stdlib/base.md index d0ea63d72b38f..5be1b997876a9 100644 --- a/doc/src/stdlib/base.md +++ b/doc/src/stdlib/base.md @@ -92,7 +92,6 @@ Base.Iterators Base.LAPACK Base.LibGit2 Base.Libc -Base.Libdl Base.LinAlg Base.Markdown Base.Meta diff --git a/doc/src/stdlib/constants.md b/doc/src/stdlib/constants.md index bb8af72ab3373..0f4c321d69067 100644 --- a/doc/src/stdlib/constants.md +++ b/doc/src/stdlib/constants.md @@ -25,12 +25,3 @@ See also: * `Libc.MS_ASYNC` * `Libc.MS_INVALIDATE` * `Libc.MS_SYNC` - * [`Libdl.DL_LOAD_PATH`](@ref) - * [`Libdl.RTLD_DEEPBIND`](@ref Base.Libdl.RTLD_NOW) - * [`Libdl.RTLD_LOCAL`](@ref Base.Libdl.RTLD_NOW) - * [`Libdl.RTLD_NOLOAD`](@ref Base.Libdl.RTLD_NOW) - * [`Libdl.RTLD_LAZY`](@ref Base.Libdl.RTLD_NOW) - * [`Libdl.RTLD_NOW`](@ref) - * [`Libdl.RTLD_GLOBAL`](@ref Base.Libdl.RTLD_NOW) - * [`Libdl.RTLD_NODELETE`](@ref Base.Libdl.RTLD_NOW) - * [`Libdl.RTLD_FIRST`](@ref Base.Libdl.RTLD_NOW) diff --git a/doc/src/stdlib/libdl.md b/doc/src/stdlib/libdl.md deleted file mode 100644 index 9956624ad7f95..0000000000000 --- a/doc/src/stdlib/libdl.md +++ /dev/null @@ -1,15 +0,0 @@ -# Dynamic Linker - -The names in `Base.Libdl` are not exported and need to be called e.g. as `Libdl.dlopen`. - -```@docs -Base.Libdl.dlopen -Base.Libdl.dlopen_e -Base.Libdl.RTLD_NOW -Base.Libdl.dlsym -Base.Libdl.dlsym_e -Base.Libdl.dlclose -Base.Libdl.dlext -Base.Libdl.find_library -Base.Libdl.DL_LOAD_PATH -``` diff --git a/stdlib/Libdl/docs/src/index.md b/stdlib/Libdl/docs/src/index.md new file mode 100644 index 0000000000000..c25ad8c44fd21 --- /dev/null +++ b/stdlib/Libdl/docs/src/index.md @@ -0,0 +1,13 @@ +# Dynamic Linker + +```@docs +Libdl.dlopen +Libdl.dlopen_e +Libdl.RTLD_NOW +Libdl.dlsym +Libdl.dlsym_e +Libdl.dlclose +Libdl.dlext +Libdl.find_library +Libdl.DL_LOAD_PATH +``` diff --git a/base/libdl.jl b/stdlib/Libdl/src/Libdl.jl similarity index 98% rename from base/libdl.jl rename to stdlib/Libdl/src/Libdl.jl index ff2d05bfa0a6b..917269a37a64d 100644 --- a/base/libdl.jl +++ b/stdlib/Libdl/src/Libdl.jl @@ -1,10 +1,14 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license +__precompile__(true) + module Libdl @doc """ Interface to libdl. Provides dynamic linking support. """ -> Libdl +import Base.DL_LOAD_PATH + export DL_LOAD_PATH, RTLD_DEEPBIND, RTLD_FIRST, RTLD_GLOBAL, RTLD_LAZY, RTLD_LOCAL, RTLD_NODELETE, RTLD_NOLOAD, RTLD_NOW, dlclose, dlopen, dlopen_e, dlsym, dlsym_e, dlpath, find_library, dlext, dllist @@ -15,11 +19,7 @@ export DL_LOAD_PATH, RTLD_DEEPBIND, RTLD_FIRST, RTLD_GLOBAL, RTLD_LAZY, RTLD_LOC When calling [`dlopen`](@ref), the paths in this list will be searched first, in order, before searching the system locations for a valid library handle. """ -const DL_LOAD_PATH = String[] -if Sys.isapple() - push!(DL_LOAD_PATH, "@loader_path/julia") - push!(DL_LOAD_PATH, "@loader_path") -end +DL_LOAD_PATH # note: constants to match JL_RTLD_* in src/julia.h, translated # to system-specific values by JL_RTLD macro in src/dlload.c @@ -47,7 +47,6 @@ applicable. """ -> (RTLD_DEEPBIND, RTLD_FIRST, RTLD_GLOBAL, RTLD_LAZY, RTLD_LOCAL, RTLD_NODELETE, RTLD_NOLOAD, RTLD_NOW) - """ dlsym(handle, sym) diff --git a/test/libdl.jl b/stdlib/Libdl/test/runtests.jl similarity index 99% rename from test/libdl.jl rename to stdlib/Libdl/test/runtests.jl index af2b396b92421..c2e410f25c86f 100644 --- a/test/libdl.jl +++ b/stdlib/Libdl/test/runtests.jl @@ -1,5 +1,7 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license +import Libdl + # these could fail on an embedded installation # but for now, we don't handle that case dlls = Libdl.dllist() diff --git a/stdlib/SuiteSparse/src/cholmod.jl b/stdlib/SuiteSparse/src/cholmod.jl index b6b47080c7891..c61295719a1b0 100644 --- a/stdlib/SuiteSparse/src/cholmod.jl +++ b/stdlib/SuiteSparse/src/cholmod.jl @@ -13,6 +13,8 @@ import Base.LinAlg: (\), using ..SparseArrays using Base.Printf.@printf +import Libdl + export Dense, Factor, diff --git a/test/ccall.jl b/test/ccall.jl index b6d30cdae817d..855fb0f30eb37 100644 --- a/test/ccall.jl +++ b/test/ccall.jl @@ -2,6 +2,8 @@ import Base.copy, Base.== +import Libdl + const libccalltest = "libccalltest" const verbose = false diff --git a/test/choosetests.jl b/test/choosetests.jl index 21b8585bcbbd2..aa778b21a03f9 100644 --- a/test/choosetests.jl +++ b/test/choosetests.jl @@ -48,7 +48,7 @@ function choosetests(choices = []) "replutil", "sets", "goto", "llvmcall", "llvmcall2", "grisu", "some", "meta", "stacktraces", "libgit2", "docs", "markdown", "serialize", "misc", "threads", - "enums", "cmdlineargs", "i18n", "libdl", "int", + "enums", "cmdlineargs", "i18n", "int", "checked", "bitset", "floatfuncs", "compile", "inline", "boundscheck", "error", "ambiguous", "cartesian", "asmvariant", "osutils", "channels", "iostream", "specificity", "codegen", "codevalidation", diff --git a/test/cmdlineargs.jl b/test/cmdlineargs.jl index 75b0fe401dd13..fb375c242bab0 100644 --- a/test/cmdlineargs.jl +++ b/test/cmdlineargs.jl @@ -1,5 +1,7 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license +import Libdl + catcmd = `cat` if Sys.iswindows() busybox = joinpath(Sys.BINDIR, "busybox.exe") diff --git a/test/compile.jl b/test/compile.jl index 2fc3702c2885e..1175f90f4cba8 100644 --- a/test/compile.jl +++ b/test/compile.jl @@ -220,7 +220,7 @@ try Dict(s => Base.module_uuid(Base.root_module(s)) for s in [:Base64, :CRC32c, :Dates, :DelimitedFiles, :FileWatching, :Future, :IterativeEigensolvers, :Logging, :Mmap, :Printf, :Profile, :SharedArrays, - :SuiteSparse, :Test, :Unicode, :Distributed])) + :SuiteSparse, :Test, :Unicode, :Distributed, :Libdl])) @test discard_module.(deps) == deps1 @test current_task()(0x01, 0x4000, 0x30031234) == 2