diff --git a/Makefile b/Makefile index 969fb04523d0a..47f908997fba3 100644 --- a/Makefile +++ b/Makefile @@ -414,6 +414,8 @@ ifeq ($(JULIA_BUILD_MODE),release) else ifeq ($(JULIA_BUILD_MODE),debug) $(INSTALL_M) $(build_private_libdir)/sys-debug.$(SHLIB_EXT) $(DESTDIR)$(private_libdir) endif + # Copy depot + cp -R -L $(build_private_libdir)/compiled/ $(DESTDIR)$(private_libdir) # Copy in all .jl sources as well mkdir -p $(DESTDIR)$(datarootdir)/julia/base $(DESTDIR)$(datarootdir)/julia/test diff --git a/base/initdefs.jl b/base/initdefs.jl index d17c7e9e1e02b..852598d04cabd 100644 --- a/base/initdefs.jl +++ b/base/initdefs.jl @@ -50,12 +50,20 @@ environments, repo clones, cached compiled package images, and configuration files. By default it includes: 1. `~/.julia` where `~` is the user home as appropriate on the system; -2. an architecture-specific shared system directory, e.g. `/usr/local/share/julia`; -3. an architecture-independent shared system directory, e.g. `/usr/share/julia`. - -So `DEPOT_PATH` might be: +2. an architecture-specific shared system directory specific to the local host, + e.g. `/usr/local/lib/julia`; +3. an architecture-independent shared system directory specific to the local host, + e.g. `/usr/local/share/julia`; +4. an architecture-specific shared system directory, + e.g. `/usr/lib/julia`; +5. an architecture-independent shared system directory, + e.g. `/usr/share/julia` + +All directories except the first are relative to the path of the `julia` executable. +So if Julia is installed to `/usr/bin/julia`, `DEPOT_PATH` might be: ```julia -[joinpath(homedir(), ".julia"), "/usr/local/share/julia", "/usr/share/julia"] +[joinpath(homedir(), ".julia"), "/usr/local/lib/julia", "/usr/local/share/julia", + "/usr/lib/julia", "/usr/share/julia"] ``` The first entry is the "user depot" and should be writable by and owned by the current user. The user depot is where: registries are cloned, new package versions @@ -76,7 +84,7 @@ Here is an overview of some of the subdirectories that may exist in a depot: * `artifacts`: Contains content that packages use for which Pkg manages the installation of. * `clones`: Contains full clones of package repos. Maintained by `Pkg.jl` and used as a cache. * `config`: Contains julia-level configuration such as a `startup.jl`. -* `compiled`: Contains precompiled `*.ji` files for packages. Maintained by Julia. +* `compiled`: Contains precompiled `*.ji` and `*.so` files for packages. Maintained by Julia. * `dev`: Default directory for `Pkg.develop`. Maintained by `Pkg.jl` and the user. * `environments`: Default package environments. For instance the global environment for a specific julia version. Maintained by `Pkg.jl`. * `logs`: Contains logs of `Pkg` and `REPL` operations. Maintained by `Pkg.jl` and Julia. @@ -95,9 +103,13 @@ See also [`JULIA_DEPOT_PATH`](@ref JULIA_DEPOT_PATH), and const DEPOT_PATH = String[] function append_bundled_depot_path!(DEPOT_PATH) - path = abspath(Sys.BINDIR, "..", "local", "share", "julia") + path = abspath(Sys.BINDIR, "..", "local", "foo", LIBDIR, "julia") + path in DEPOT_PATH || push!(DEPOT_PATH, path) + path = abspath(Sys.BINDIR, "..", "local", "foo", DATAROOTDIR, "julia") + path in DEPOT_PATH || push!(DEPOT_PATH, path) + path = abspath(Sys.BINDIR, LIBDIR, "julia") path in DEPOT_PATH || push!(DEPOT_PATH, path) - path = abspath(Sys.BINDIR, Base.DATAROOTDIR, "julia") + path = abspath(Sys.BINDIR, DATAROOTDIR, "julia") path in DEPOT_PATH || push!(DEPOT_PATH, path) return DEPOT_PATH end diff --git a/pkgimage.mk b/pkgimage.mk index ed5e1095c0229..63a4db9722046 100644 --- a/pkgimage.mk +++ b/pkgimage.mk @@ -4,10 +4,8 @@ JULIAHOME := $(SRCDIR) include $(JULIAHOME)/Make.inc include $(JULIAHOME)/stdlib/stdlib.mk -DEPOTDIR := $(build_prefix)/share/julia - # set some influential environment variables -export JULIA_DEPOT_PATH := $(shell echo $(call cygpath_w,$(DEPOTDIR))) +export JULIA_DEPOT_PATH := $(shell echo $(call cygpath_w,$(build_private_libdir)))$(PATHSEP)$(shell echo $(call cygpath_w,$(build_datarootdir)/julia)) export JULIA_LOAD_PATH := @stdlib$(PATHSEP)$(shell echo $(call cygpath_w,$(JULIAHOME)/stdlib)) unexport JULIA_PROJECT := unexport JULIA_BINDIR := @@ -19,13 +17,13 @@ release: $(BUILDDIR)/stdlib/release.image debug: $(BUILDDIR)/stdlib/debug.image all: release debug -$(DEPOTDIR)/compiled: +$(build_private_libdir)/compiled: mkdir -p $@ print-depot-path: @$(call PRINT_JULIA, $(call spawn,$(JULIA_EXECUTABLE)) --startup-file=no -e '@show Base.DEPOT_PATH') -$(BUILDDIR)/stdlib/%.image: $(JULIAHOME)/stdlib/Project.toml $(JULIAHOME)/stdlib/Manifest.toml $(INDEPENDENT_STDLIBS_SRCS) $(DEPOTDIR)/compiled +$(BUILDDIR)/stdlib/%.image: $(JULIAHOME)/stdlib/Project.toml $(JULIAHOME)/stdlib/Manifest.toml $(INDEPENDENT_STDLIBS_SRCS) $(build_private_libdir)/compiled @$(call PRINT_JULIA, JULIA_CPU_TARGET="sysimage" $(call spawn,$(JULIA_EXECUTABLE)) --startup-file=no -e \ 'Base.Precompilation.precompilepkgs(configs=[``=>Base.CacheFlags(debug_level=2, opt_level=3), ``=>Base.CacheFlags(check_bounds=1, debug_level=2, opt_level=3)])') touch $@ @@ -34,5 +32,5 @@ $(BUILDDIR)/stdlib/release.image: $(build_private_libdir)/sys.$(SHLIB_EXT) $(BUILDDIR)/stdlib/debug.image: $(build_private_libdir)/sys-debug.$(SHLIB_EXT) clean: - rm -rf $(DEPOTDIR)/compiled + rm -rf $(build_private_libdir)/compiled rm -f $(BUILDDIR)/stdlib/*.image diff --git a/test/Makefile b/test/Makefile index 61946e650dee5..8b241255c36e7 100644 --- a/test/Makefile +++ b/test/Makefile @@ -6,7 +6,7 @@ VERSDIR := v$(shell cut -d. -f1-2 < $(JULIAHOME)/VERSION) STDLIBDIR := $(build_datarootdir)/julia/stdlib/$(VERSDIR) # TODO: this Makefile ignores BUILDDIR, except for computing JULIA_EXECUTABLE -export JULIA_DEPOT_PATH := $(build_prefix)/share/julia +export JULIA_DEPOT_PATH := $(shell echo $(call cygpath_w,$(build_private_libdir))) export JULIA_LOAD_PATH := @$(PATHSEP)@stdlib unexport JULIA_PROJECT := unexport JULIA_BINDIR := @@ -46,7 +46,8 @@ relocatedepot: @cd $(SRCDIR) && \ $(call PRINT_JULIA, $(call spawn,$(JULIA_EXECUTABLE)) $(TEST_JULIA_OPTIONS) ./runtests.jl $(TEST_SCRIPT_OPTIONS) $@) @mkdir $(SRCDIR)/relocatedepot - @cp -R $(build_datarootdir)/julia $(SRCDIR)/relocatedepot + @cp -R $(build_datarootdir)/julia/* $(SRCDIR)/relocatedepot + @cp -R $(build_private_libdir)/compiled $(SRCDIR)/relocatedepot @cp -R $(SRCDIR)/RelocationTestPkg1 $(SRCDIR)/relocatedepot @cp -R $(SRCDIR)/RelocationTestPkg2 $(SRCDIR)/relocatedepot @cp -R $(SRCDIR)/RelocationTestPkg3 $(SRCDIR)/relocatedepot @@ -59,7 +60,8 @@ revise-relocatedepot: revise-% : @cd $(SRCDIR) && \ $(call PRINT_JULIA, $(call spawn,$(JULIA_EXECUTABLE)) $(TEST_JULIA_OPTIONS) ./runtests.jl $(TEST_SCRIPT_OPTIONS) --revise $*) @mkdir $(SRCDIR)/relocatedepot - @cp -R $(build_datarootdir)/julia $(SRCDIR)/relocatedepot + @cp -R $(build_datarootdir)/julia/* $(SRCDIR)/relocatedepot + @cp -R $(build_private_libdir)/compiled $(SRCDIR)/relocatedepot @cp -R $(SRCDIR)/RelocationTestPkg1 $(SRCDIR)/relocatedepot @cp -R $(SRCDIR)/RelocationTestPkg2 $(SRCDIR)/relocatedepot @cp -R $(SRCDIR)/RelocationTestPkg3 $(SRCDIR)/relocatedepot diff --git a/test/embedding/Makefile b/test/embedding/Makefile index 4be4974e864cd..9e613c1468764 100644 --- a/test/embedding/Makefile +++ b/test/embedding/Makefile @@ -21,7 +21,7 @@ EXE := $(suffix $(abspath $(JULIA))) # get compiler and linker flags. (see: `contrib/julia-config.jl`) JULIA_CONFIG := $(JULIA) -e 'include(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "julia-config.jl"))' -- -JULIA_LIBDIR := $(shell $(JULIA) -e 'println(joinpath(Sys.BINDIR, "..", "lib"))' --) +JULIA_LIBDIR := $(shell $(JULIA) -e 'println(joinpath(Sys.BINDIR, Base.LIBDIR))' --) CPPFLAGS_ADD := CFLAGS_ADD = $(shell $(JULIA_CONFIG) --cflags) LDFLAGS_ADD = -lm $(shell $(JULIA_CONFIG) --ldflags --ldlibs) diff --git a/test/relocatedepot.jl b/test/relocatedepot.jl index e8758365e3ff4..4ef9833d08549 100644 --- a/test/relocatedepot.jl +++ b/test/relocatedepot.jl @@ -252,7 +252,7 @@ else @testset "load stdlib from test/relocatedepot" begin test_harness() do push!(LOAD_PATH, "@stdlib") - push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot", "julia")) + push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot")) # stdlib should be already precompiled pkg = Base.identify_package("DelimitedFiles") @test Base.isprecompiled(pkg) == true @@ -264,8 +264,7 @@ else pkgname = "RelocationTestPkg1" test_harness() do push!(LOAD_PATH, joinpath(@__DIR__, "relocatedepot")) - push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot")) # required to find src files - push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot", "julia")) # contains cache file + push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot")) pkg = Base.identify_package(pkgname) @test Base.isprecompiled(pkg) == true @test Base.isrelocatable(pkg) == true @@ -276,8 +275,7 @@ else pkgname = "RelocationTestPkg2" test_harness() do push!(LOAD_PATH, joinpath(@__DIR__, "relocatedepot")) - push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot")) # required to find src files - push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot", "julia")) # contains cache file + push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot")) pkg = Base.identify_package(pkgname) @test Base.isprecompiled(pkg) == false # moving depot changes mtime of include_dependency @test Base.isrelocatable(pkg) == false # because not precompiled @@ -294,8 +292,7 @@ else pkgname = "RelocationTestPkg3" test_harness() do push!(LOAD_PATH, joinpath(@__DIR__, "relocatedepot")) - push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot")) # required to find src files - push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot", "julia")) # contains cache file + push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot")) pkg = Base.identify_package(pkgname) @test Base.isprecompiled(pkg) == true @test Base.isrelocatable(pkg) == true @@ -309,8 +306,7 @@ else pkgname = "RelocationTestPkg4" test_harness() do push!(LOAD_PATH, @__DIR__, "relocatedepot") - push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot")) # required to find src files - push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot", "julia")) # contains cache file + push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot")) pkg = Base.identify_package(pkgname) # precompiled but not relocatable @test Base.isprecompiled(pkg) == true diff --git a/test/trimming/Makefile b/test/trimming/Makefile index 3c1de9555e439..66d98adf89092 100644 --- a/test/trimming/Makefile +++ b/test/trimming/Makefile @@ -23,7 +23,7 @@ EXE := $(suffix $(abspath $(JULIA))) # get compiler and linker flags. (see: `contrib/julia-config.jl`) JULIA_CONFIG := $(JULIA) -e 'include(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "julia-config.jl"))' -- -JULIA_LIBDIR := $(shell $(JULIA) --startup-file=no -e 'println(joinpath(Sys.BINDIR, "..", "lib"))' --) +JULIA_LIBDIR := $(shell $(JULIA) --startup-file=no -e 'println(joinpath(Sys.BINDIR, Base.LIBDIR))' --) CPPFLAGS_ADD := CFLAGS_ADD = $(shell $(JULIA_CONFIG) --cflags) LDFLAGS_ADD = -lm $(shell $(JULIA_CONFIG) --ldflags --ldlibs) -ljulia-internal