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

[RFC] Treat stdlib packages more like normal packages #25248

Closed
wants to merge 4 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
18 changes: 16 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ $(foreach link,base $(JULIAHOME)/test,$(eval $(call symlink_target,$(link),$(bui
build_defaultpkgdir = $(build_datarootdir)/julia/site/$(shell echo $(VERSDIR))
$(eval $(call symlink_target,$(JULIAHOME)/stdlib,$(build_datarootdir)/julia/site,$(shell echo $(VERSDIR))))

build_defaultpkgcachedir = $(build_datarootdir)/julia/lib/$(shell echo $(VERSDIR))
$(build_defaultpkgcachedir): | $(DIRS) $(build_defaultpkgdir)
mkdir -p $@

julia_flisp.boot.inc.phony: julia-deps
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/src julia_flisp.boot.inc.phony

Expand Down Expand Up @@ -103,7 +107,7 @@ julia-sysimg-release : julia-inference julia-ui-release
julia-sysimg-debug : julia-inference julia-ui-debug
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT) $(build_private_libdir)/sys-debug.$(SHLIB_EXT) JULIA_BUILD_MODE=debug

julia-debug julia-release : julia-% : julia-ui-% julia-sysimg-% julia-symlink julia-libccalltest julia-base-cache
julia-debug julia-release : julia-% : julia-ui-% julia-sysimg-% julia-symlink julia-libccalltest julia-base-cache stdlibcache

debug release : % : julia-%

Expand Down Expand Up @@ -209,7 +213,7 @@ $(build_private_libdir)/inference.ji: $(CORE_SRCS) | $(build_private_libdir)
RELBUILDROOT := $(shell $(JULIAHOME)/contrib/relative_path.sh "$(JULIAHOME)/base" "$(BUILDROOT)/base/")
COMMA:=,
define sysimg_builder
$$(build_private_libdir)/sys$1.o: $$(build_private_libdir)/inference.ji $$(JULIAHOME)/VERSION $$(BASE_SRCS) $$(STDLIB_SRCS)
$$(build_private_libdir)/sys$1.o: $$(build_private_libdir)/inference.ji $$(JULIAHOME)/VERSION $$(BASE_SRCS)
@$$(call PRINT_JULIA, cd $$(JULIAHOME)/base && \
if $$(call spawn,$3) $2 -C "$$(JULIA_CPU_TARGET)" --output-o $$(call cygpath_w,$$@).tmp $$(JULIA_SYSIMG_BUILD_FLAGS) \
--startup-file=no --warn-overwrite=yes --sysimage $$(call cygpath_w,$$<) sysimg.jl $$(RELBUILDROOT); then \
Expand All @@ -222,6 +226,16 @@ endef
$(eval $(call sysimg_builder,,-O3,$(JULIA_EXECUTABLE_release)))
$(eval $(call sysimg_builder,-debug,-O0,$(JULIA_EXECUTABLE_debug)))


$(build_defaultpkgcachedir)/cache.compiled: $(build_defaultpkgdir) $(build_defaultpkgcachedir) $(STDLIB_SRCS) julia-sysimg-$(JULIA_BUILD_MODE) | julia-ui-$(JULIA_BUILD_MODE)
env JULIA_SKIP_PKGCACHE=1 $(JULIA_EXECUTABLE) contrib/stdlib_cache.jl $< $(word 2,$^)
echo 1 > $@

stdlibcache: $(build_defaultpkgcachedir)/cache.compiled
CLEAN_TARGETS += clean-stdlibcache
clean-stdlibcache::
@-rm -fr $(build_defaultpkgcachedir)

$(build_depsbindir)/stringreplace: $(JULIAHOME)/contrib/stringreplace.c | $(build_depsbindir)
@$(call PRINT_CC, $(HOSTCC) -o $(build_depsbindir)/stringreplace $(JULIAHOME)/contrib/stringreplace.c)

Expand Down
7 changes: 7 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1255,8 +1255,13 @@ deprecate(Base, :DSP, 2)
using .DSP
export conv, conv2, deconv, filt, filt!, xcorr

@deprecate_binding Test nothing true ", run `using Test` instead"

@deprecate_moved SharedArray "SharedArrays" true true

@deprecate_binding Mmap nothing true ", run `using Mmap` instead"

@deprecate_binding Profile nothing true ", run `using Profile` instead"
@eval @deprecate_moved $(Symbol("@profile")) "Profile" true true

@deprecate_moved base64encode "Base64" true true
Expand All @@ -1277,6 +1282,7 @@ export conv, conv2, deconv, filt, filt!, xcorr
@eval @deprecate_moved $(Symbol("@everywhere")) "Distributed" true true
@eval @deprecate_moved $(Symbol("@parallel")) "Distributed" true true

@deprecate_binding Distributed nothing true ", run `using Distributed` instead"
@deprecate_moved addprocs "Distributed" true true
@deprecate_moved CachingPool "Distributed" true true
@deprecate_moved clear! "Distributed" true true
Expand Down Expand Up @@ -1308,6 +1314,7 @@ export conv, conv2, deconv, filt, filt!, xcorr

@deprecate_moved crc32c "CRC32c" true true

@deprecate_binding Dates nothing true ", run `using Dates` instead"
@deprecate_moved DateTime "Dates" true true
@deprecate_moved DateFormat "Dates" true true
@eval @deprecate_moved $(Symbol("@dateformat_str")) "Dates" true true
Expand Down
2 changes: 1 addition & 1 deletion base/initdefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function init_load_path(BINDIR = Sys.BINDIR)
end
push!(LOAD_PATH, abspath(BINDIR, "..", "local", "share", "julia", "site", vers))
push!(LOAD_PATH, abspath(BINDIR, "..", "share", "julia", "site", vers))
#push!(LOAD_CACHE_PATH, abspath(BINDIR, "..", "lib", "julia")) #TODO: add a builtin location?
push!(LOAD_CACHE_PATH, abspath(BINDIR, "..", "share", "julia", "lib", vers))
end

function early_init()
Expand Down
3 changes: 3 additions & 0 deletions base/pkg/pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ custom METADATA setup.
init(meta::AbstractString=DEFAULT_META, branch::AbstractString=META_BRANCH) = Dir.init(meta,branch)

function __init__()
if haskey(ENV, "JULIA_SKIP_PKGCACHE") && ENV["JULIA_SKIP_PKGCACHE"] == "1"
return
end
vers = "v$(VERSION.major).$(VERSION.minor)"
pushfirst!(Base.LOAD_CACHE_PATH, abspath(Dir._pkgroot(), "lib", vers))
end
Expand Down
25 changes: 0 additions & 25 deletions base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -487,31 +487,6 @@ using Base
# Ensure this file is also tracked
pushfirst!(Base._included_files, (@__MODULE__, joinpath(@__DIR__, "sysimg.jl")))

# load some stdlib packages but don't put their names in Main
Base.require(:Base64)
Base.require(:CRC32c)
Base.require(:Dates)
Base.require(:DelimitedFiles)
Base.require(:FileWatching)
Base.require(:Logging)
Base.require(:IterativeEigensolvers)
Base.require(:Mmap)
Base.require(:Profile)
Base.require(:SharedArrays)
Base.require(:SuiteSparse)
Base.require(:Test)
Base.require(:Unicode)
Base.require(:Distributed)
Base.require(:Printf)

@eval Base begin
@deprecate_binding Test root_module(:Test) true ", run `using Test` instead"
@deprecate_binding Mmap root_module(:Mmap) true ", run `using Mmap` instead"
@deprecate_binding Profile root_module(:Profile) true ", run `using Profile` instead"
@deprecate_binding Dates root_module(:Dates) true ", run `using Dates` instead"
@deprecate_binding Distributed root_module(:Distributed) true ", run `using Distributed` instead"
end

empty!(LOAD_PATH)

Base.isfile("userimg.jl") && Base.include(Main, "userimg.jl")
Expand Down
30 changes: 30 additions & 0 deletions contrib/stdlib_cache.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env julia
# This file is a part of Julia. License is MIT: https://julialang.org/license

# Builds a cache for all stdlib packages and installs that alongside Julia.

@assert length(ARGS) == 2
pkgdir = ARGS[1]
cachedir = ARGS[2]

let cache_path = Base.LOAD_CACHE_PATH
empty!(cache_path)
push!(cache_path, cachedir)
end

let load_path = Base.LOAD_PATH
empty!(load_path)
push!(load_path, pkgdir)
end

for pkg in readdir(pkgdir)
@info "Building cache for $pkg"
mfile = joinpath(pkgdir, pkg, "src", string(pkg, ".jl"))
if isfile(mfile)
# We can't use Base.compilecache since we don't know the order of dependencies
Base.require(Symbol(pkg))
else
@info "Directory $pkg doesn't have a $mfile. Skipping."
continue
end
end
1 change: 1 addition & 0 deletions stdlib/IterativeEigensolvers/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using IterativeEigensolvers
using Test
using SuiteSparse

@testset "eigs" begin
srand(1234)
Expand Down
1 change: 1 addition & 0 deletions test/sparse/sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using Base.LinAlg: mul!, ldiv!, rdiv!, Adjoint, Transpose
using Base.Printf.@printf
using SuiteSparse

@testset "issparse" begin
@test issparse(sparse(ones(5,5)))
Expand Down