From f0b1c5fa0e57f60446bba7d0c83bfda93a2b8b63 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Thu, 9 Jun 2022 16:04:56 -0400 Subject: [PATCH] build: cleanup base files inclusion (#45441) Ensures the out-of-tree build has the correct files installed, and simplifies some of the `include`s used in Base. Fixes a return value that was relied on (largely unnecessarily) by a loading test, despite being invalid before now. Fixes #31140 --- Makefile | 28 +++++---- base/.gitignore | 6 -- base/Base.jl | 14 +---- base/Makefile | 88 +++++++++++++++++++-------- base/cpuid.jl | 2 +- base/filesystem.jl | 2 +- base/initdefs.jl | 6 +- base/libc.jl | 2 +- base/libuv.jl | 2 +- base/loading.jl | 4 +- base/pcre.jl | 3 +- base/sysimg.jl | 9 ++- doc/src/devdocs/build/distributing.md | 6 +- src/base | 1 + stdlib/Profile/src/Profile.jl | 2 +- sysimage.mk | 77 +++++++++++------------ 16 files changed, 136 insertions(+), 116 deletions(-) create mode 120000 src/base diff --git a/Makefile b/Makefile index 1bd8b66a009be..f1647f1acd983 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ default: $(JULIA_BUILD_MODE) # contains either "debug" or "release" all: debug release # sort is used to remove potential duplicates -DIRS := $(sort $(build_bindir) $(build_depsbindir) $(build_libdir) $(build_private_libdir) $(build_libexecdir) $(build_includedir) $(build_includedir)/julia $(build_sysconfdir)/julia $(build_datarootdir)/julia $(build_datarootdir)/julia/stdlib $(build_man1dir)) +DIRS := $(sort $(build_bindir) $(build_depsbindir) $(build_libdir) $(build_private_libdir) $(build_libexecdir) $(build_includedir) $(build_includedir)/julia $(build_sysconfdir)/julia $(build_datarootdir)/julia $(build_datarootdir)/julia/src $(build_datarootdir)/julia/stdlib $(build_man1dir)) ifneq ($(BUILDROOT),$(JULIAHOME)) BUILDDIRS := $(BUILDROOT) $(addprefix $(BUILDROOT)/,base src src/flisp src/support src/clangsa cli doc deps stdlib test test/clangsa test/embedding test/llvmpasses) BUILDDIRMAKE := $(addsuffix /Makefile,$(BUILDDIRS)) $(BUILDROOT)/sysimage.mk @@ -37,13 +37,13 @@ configure: endif $(foreach dir,$(DIRS),$(eval $(call dir_target,$(dir)))) -$(foreach link,base $(JULIAHOME)/test,$(eval $(call symlink_target,$(link),$$(build_datarootdir)/julia,$(notdir $(link))))) +$(eval $(call symlink_target,$(JULIAHOME)/test,$$(build_datarootdir)/julia,test)) julia_flisp.boot.inc.phony: julia-deps @$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/src julia_flisp.boot.inc.phony # Build the HTML docs (skipped if already exists, notably in tarballs) -$(BUILDROOT)/doc/_build/html/en/index.html: $(shell find $(BUILDROOT)/base $(BUILDROOT)/doc \( -path $(BUILDROOT)/doc/_build -o -path $(BUILDROOT)/doc/deps -o -name *_constants.jl -o -name *_h.jl -o -name version_git.jl \) -prune -o -type f -print) +$(BUILDROOT)/doc/_build/html/en/index.html: $(shell find $(BUILDROOT)/base $(BUILDROOT)/doc \( -path $(BUILDROOT)/doc/_build -o -path $(BUILDROOT)/doc/deps \) -prune -o -type f -print) @$(MAKE) docs julia-symlink: julia-cli-$(JULIA_BUILD_MODE) @@ -56,7 +56,7 @@ ifndef JULIA_VAGRANT_BUILD endif endif -julia-deps: | $(DIRS) $(build_datarootdir)/julia/base $(build_datarootdir)/julia/test +julia-deps: | $(DIRS) $(build_datarootdir)/julia/test @$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/deps # `julia-stdlib` depends on `julia-deps` so that the fake JLL stdlibs can copy in their Artifacts.toml files. @@ -84,9 +84,14 @@ julia-sysimg-ji : julia-stdlib julia-base julia-cli-$(JULIA_BUILD_MODE) julia-sr julia-sysimg-bc : julia-stdlib julia-base julia-cli-$(JULIA_BUILD_MODE) julia-src-$(JULIA_BUILD_MODE) | $(build_private_libdir) @$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT) -f sysimage.mk sysimg-bc JULIA_EXECUTABLE='$(JULIA_EXECUTABLE)' -julia-sysimg-release julia-sysimg-debug : julia-sysimg-% : julia-sysimg-ji julia-src-% - @$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT) -f sysimage.mk sysimg-$* +$(JULIA_SYSIMG_release): julia-sysimg-ji julia-src-release + @$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT) -f sysimage.mk sysimg-release +$(JULIA_SYSIMG_debug) : julia-sysimg-ji julia-src-debug + @$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT) -f sysimage.mk sysimg-debug +julia-sysimg-release : $(JULIA_SYSIMG_release) +julia-sysimg-debug : $(JULIA_SYSIMG_debug) +julia-base-cache: $(build_datarootdir)/julia/base.cache julia-debug julia-release : julia-% : julia-sysimg-% julia-src-% julia-symlink julia-libccalltest julia-libllvmcalltest julia-base-cache debug release : % : julia-% @@ -156,10 +161,10 @@ $(build_datarootdir)/julia/julia-config.jl: $(JULIAHOME)/contrib/julia-config.jl $(build_depsbindir)/stringreplace: $(JULIAHOME)/contrib/stringreplace.c | $(build_depsbindir) @$(call PRINT_CC, $(HOSTCC) -o $(build_depsbindir)/stringreplace $(JULIAHOME)/contrib/stringreplace.c) -julia-base-cache: julia-sysimg-$(JULIA_BUILD_MODE) | $(DIRS) $(build_datarootdir)/julia +$(build_datarootdir)/julia/base.cache: $(JULIA_SYSIMG) | $(DIRS) $(build_datarootdir)/julia @JULIA_BINDIR=$(call cygpath_w,$(build_bindir)) WINEPATH="$(call cygpath_w,$(build_bindir));$$WINEPATH" \ $(call spawn, $(JULIA_EXECUTABLE) --startup-file=no $(call cygpath_w,$(JULIAHOME)/etc/write_base_cache.jl) \ - $(call cygpath_w,$(build_datarootdir)/julia/base.cache)) + $(call cygpath_w,$@)) # public libraries, that are installed in $(prefix)/lib JL_TARGETS := julia @@ -313,10 +318,9 @@ ifeq ($(BUNDLE_DEBUG_LIBS),1) endif # Copy in all .jl sources as well - mkdir -p $(DESTDIR)$(datarootdir)/julia/base $(DESTDIR)$(datarootdir)/julia/test - cp -R -L $(JULIAHOME)/base/* $(DESTDIR)$(datarootdir)/julia/base - cp -R -L $(JULIAHOME)/test/* $(DESTDIR)$(datarootdir)/julia/test + mkdir -p $(DESTDIR)$(datarootdir)/julia/src $(DESTDIR)$(datarootdir)/julia/test cp -R -L $(build_datarootdir)/julia/* $(DESTDIR)$(datarootdir)/julia + cp -R -L $(JULIAHOME)/test/* $(DESTDIR)$(datarootdir)/julia/test # Copy documentation cp -R -L $(BUILDROOT)/doc/_build/html $(DESTDIR)$(docdir)/ # Remove various files which should not be installed @@ -462,7 +466,7 @@ ifneq ($(BUILDROOT),$(JULIAHOME)) $(error make light-source-dist does not work in out-of-tree builds) endif # Save git information - -@$(MAKE) -C $(JULIAHOME)/base version_git.jl.phony + -@$(MAKE) -C $(JULIAHOME)/base version_git.jl # Create file light-source-dist.tmp to hold all the filenames that go into the tarball echo "base/version_git.jl" > light-source-dist.tmp diff --git a/base/.gitignore b/base/.gitignore index e572b8ea229d0..f7460230f217b 100644 --- a/base/.gitignore +++ b/base/.gitignore @@ -1,10 +1,4 @@ -/features_h.jl -/pcre_h.jl -/errno_h.jl -/build_h.jl /build_h.jl.phony -/file_constants.jl -/uv_constants.jl /version_git.jl /version_git.jl.phony /userimg.jl diff --git a/base/Base.jl b/base/Base.jl index d50228de198a1..6fb7a7b897317 100644 --- a/base/Base.jl +++ b/base/Base.jl @@ -151,18 +151,8 @@ using .Iterators: Flatten, Filter, product # for generators include("namedtuple.jl") # For OS specific stuff -# We need to strcat things here, before strings are really defined -function strcat(x::String, y::String) - out = ccall(:jl_alloc_string, Ref{String}, (Csize_t,), Core.sizeof(x) + Core.sizeof(y)) - GC.@preserve x y out begin - out_ptr = unsafe_convert(Ptr{UInt8}, out) - unsafe_copyto!(out_ptr, unsafe_convert(Ptr{UInt8}, x), Core.sizeof(x)) - unsafe_copyto!(out_ptr + Core.sizeof(x), unsafe_convert(Ptr{UInt8}, y), Core.sizeof(y)) - end - return out -end -include(strcat((length(Core.ARGS)>=2 ? Core.ARGS[2] : ""), "build_h.jl")) # include($BUILDROOT/base/build_h.jl) -include(strcat((length(Core.ARGS)>=2 ? Core.ARGS[2] : ""), "version_git.jl")) # include($BUILDROOT/base/version_git.jl) +include("../build_h.jl") +include("../version_git.jl") # These used to be in build_h.jl and are retained for backwards compatibility const libblas_name = "libblastrampoline" diff --git a/base/Makefile b/base/Makefile index 5c12ab1c149d8..72b3ed145605e 100644 --- a/base/Makefile +++ b/base/Makefile @@ -6,7 +6,22 @@ include $(JULIAHOME)/Make.inc TAGGED_RELEASE_BANNER := "" -all: $(addprefix $(BUILDDIR)/,pcre_h.jl errno_h.jl build_h.jl.phony features_h.jl file_constants.jl uv_constants.jl version_git.jl.phony) +all: + +BASE_SRCS := $(patsubst ./%,%,$(shell cd $(SRCDIR) && find . -name \*.jl -and -not -name version_git.jl -and -not -name '*.phony')) +GENERATED_SRCS := pcre_h.jl errno_h.jl build_h.jl.phony features_h.jl file_constants.jl uv_constants.jl version_git.jl.phony + +GENERATED_DSTS := $(addprefix $(build_datarootdir)/julia/src/,$(GENERATED_SRCS)) +BASE_DSTS := $(addprefix $(build_datarootdir)/julia/src/base/,$(BASE_SRCS)) $(GENERATED_DSTS) +BASE_DIRS := $(sort $(dir $(BASE_DSTS))) +$(foreach dir,$(BASE_DIRS),$(eval $(call dir_target,$(dir)))) + +# we might like to add "| $(BASE_DIRS)" here, but that causes many version of 'make' to get confused and fail to build consistently +$(build_datarootdir)/julia/src/base/%.jl: $(SRCDIR)/%.jl + @mkdir -p $(dir $@) + cp $< $@ + +all: $(BASE_DSTS) PCRE_CONST := 0x[0-9a-fA-F]+|[0-9]+|\([\-0-9]+\) ifeq ($(USE_SYSTEM_PCRE), 1) @@ -17,29 +32,37 @@ endif define parse_features @echo "# $(2) features" >> $@ -@$(call PRINT_PERL, cat $(SRCDIR)/../src/features_$(1).h | perl -lne 'print "const JL_$(2)_$$1 = UInt32($$2)" if /^\s*JL_FEATURE_DEF(?:_NAME)?\(\s*(\w+)\s*,\s*([^,]+)\s*,.*\)\s*(?:\/\/.*)?$$/' >> $@) +@$(call PRINT_PERL, cat $(JULIAHOME)/src/features_$(1).h | \ + perl -lne 'print "const JL_$(2)_$$1 = UInt32($$2)" if /^\s*JL_FEATURE_DEF(?:_NAME)?\(\s*(\w+)\s*,\s*([^,]+)\s*,.*\)\s*(?:\/\/.*)?$$/' >> $@) @echo >> $@ endef -$(BUILDDIR)/features_h.jl: $(SRCDIR)/../src/features_x86.h $(SRCDIR)/../src/features_aarch32.h $(SRCDIR)/../src/features_aarch64.h +$(build_datarootdir)/julia/src/features_h.jl: $(JULIAHOME)/src/features_x86.h $(JULIAHOME)/src/features_aarch32.h $(JULIAHOME)/src/features_aarch64.h + @mkdir -p $(dir $@) @-rm -f $@ @$(call parse_features,x86,X86) @$(call parse_features,aarch32,AArch32) @$(call parse_features,aarch64,AArch64) -$(BUILDDIR)/pcre_h.jl: $(PCRE_INCL_PATH) +$(build_datarootdir)/julia/src/pcre_h.jl: $(PCRE_INCL_PATH) + @mkdir -p $(dir $@) @$(call PRINT_PERL, $(CPP) -D PCRE2_CODE_UNIT_WIDTH=8 -dM $< | perl -nle '/^\s*#define\s+PCRE2_(\w*)\s*\(?($(PCRE_CONST))\)?u?\s*$$/ and print index($$1, "ERROR_") == 0 ? "const $$1 = Cint($$2)" : "const $$1 = UInt32($$2)"' | LC_ALL=C sort > $@) -$(BUILDDIR)/errno_h.jl: +$(build_datarootdir)/julia/src/errno_h.jl: + @mkdir -p $(dir $@) @$(call PRINT_PERL, echo '#include ' | $(CPP) -dM - | perl -nle 'print "const $$1 = Int32($$2)" if /^#define\s+(E\w+)\s+(\d+)\s*$$/' | LC_ALL=C sort > $@) -$(BUILDDIR)/file_constants.jl: $(SRCDIR)/../src/file_constants.h +$(build_datarootdir)/julia/src/file_constants.jl: $(JULIAHOME)/src/file_constants.h + @mkdir -p $(dir $@) @$(call PRINT_PERL, $(CPP_STDOUT) -DJULIA $< | perl -nle 'print "$$1 0o$$2" if /^(\s*const\s+[A-z_]+\s+=)\s+(0[0-9]*)\s*$$/; print "$$1" if /^\s*(const\s+[A-z_]+\s+=\s+([1-9]|0x)[0-9A-z]*)\s*$$/' > $@) -$(BUILDDIR)/uv_constants.jl: $(SRCDIR)/../src/uv_constants.h $(LIBUV_INC)/uv/errno.h +$(build_datarootdir)/julia/src/uv_constants.jl: $(JULIAHOME)/src/uv_constants.h $(LIBUV_INC)/uv/errno.h + @mkdir -p $(dir $@) @$(call PRINT_PERL, $(CPP_STDOUT) "-I$(LIBUV_INC)" -DJULIA $< | tail -n 16 > $@) +$(build_datarootdir)/julia/src/build_h.jl.phony: $(BUILDDIR)/build_h.jl.phony $(BUILDDIR)/build_h.jl.phony: + @mkdir -p $(build_datarootdir)/julia/src @echo "# This file is automatically generated in base/Makefile" > $@ ifeq ($(XC_HOST),) @echo "const MACHINE = \"$(BUILD_MACHINE)\"" >> $@ @@ -87,35 +110,44 @@ endif @# This to ensure that we always rebuild this file, but only when it is modified do we touch build_h.jl, @# ensuring we rebuild the system image as infrequently as possible - @if ! cmp -s $@ build_h.jl; then \ + @if ! cmp -s $@ $(build_datarootdir)/julia/src/build_h.jl; then \ $(call PRINT_PERL,) \ - mv $@ build_h.jl; \ + mv $@ $(build_datarootdir)/julia/src/build_h.jl; \ else \ rm -f $@; \ fi +$(build_datarootdir)/julia/src/version_git.jl.phony: $(BUILDDIR)/version_git.jl.phony $(BUILDDIR)/version_git.jl.phony: $(SRCDIR)/version_git.sh -ifneq ($(NO_GIT), 1) - sh $< $(SRCDIR) > $@ - @# This to avoid touching version_git.jl when it is not modified, - @# so that the system image does not need to be rebuilt. - @if ! cmp -s $@ version_git.jl; then \ - $(call PRINT_PERL,) \ - mv $@ version_git.jl; \ - else \ - rm -f $@; \ - fi -else -ifeq ($(shell [ -f $(BUILDDIR)/version_git.jl ] && echo "true"), true) - @# Give warning if boilerplate git is used + @mkdir -p $(build_datarootdir)/julia/src +ifneq ($(NO_GIT),1) + @sh $< $(SRCDIR) > $@ +else ifeq ($(shell [ -f $(BUILDDIR)/version_git.jl ] && echo "true"), true) + @# Give warning if boilerplate git is found here @if grep -q "Default output if git is not available" $(BUILDDIR)/version_git.jl; then \ echo "WARNING: Using boilerplate git version info" >&2; \ fi + @cp $(BUILDDIR)/version_git.jl $@ +else ifeq ($(shell [ -f $(SRCDIR)/version_git.jl ] && echo "true"), true) + @# Give warning if boilerplate git is found here + @if grep -q "Default output if git is not available" $(SRCDIR)/version_git.jl; then \ + echo "WARNING: Using boilerplate git version info" >&2; \ + fi + @cp $(SRCDIR)/version_git.jl $@ else $(warning "WARNING: Generating boilerplate git version info") - @sh $(SRCDIR)/version_git.sh $(SRCDIR) NO_GIT > $(BUILDDIR)/version_git.jl -endif + @sh $< $(SRCDIR) NO_GIT > $@ endif + @# This to avoid touching version_git.jl when it is not modified, + @# so that the system image does not need to be rebuilt. + @if ! cmp -s $@ $(build_datarootdir)/julia/src/version_git.jl; then \ + $(call PRINT_PERL,) \ + mv $@ $(build_datarootdir)/julia/src/version_git.jl; \ + else \ + rm -f $@; \ + fi +$(BUILDDIR)/version_git.jl: $(SRCDIR)/version_git.sh + sh $< $(SRCDIR) > $@ ifeq (,$(filter $(OS), WINNT emscripten)) # For any USE_SYSTEM_* libraries that will be dynamically loaded by libjulia, @@ -163,7 +195,7 @@ endif define symlink_system_library libname_$2 := $$(notdir $(call versioned_libname,$2,$3)) libpath_$2 := $$(shell $$(call spawn,$$(LIBWHICH)) -p $$(libname_$2) 2>/dev/null) -symlink_$2: $$(build_private_libdir)/$$(libname_$2) +symlink_$2: $$(build_private_libdir)/$$(libname_$2) .FORCE $$(build_private_libdir)/$$(libname_$2): @if [ -e "$$(libpath_$2)" ]; then \ REALPATH=$$(libpath_$2); \ @@ -269,7 +301,10 @@ endif symlink_system_libraries: $(SYMLINK_SYSTEM_LIBRARIES) -.PHONY: $(BUILDDIR)/build_h.jl.phony $(BUILDDIR)/version_git.jl.phony clean all symlink_* +.FORCE: +.PHONY: $(BUILDDIR)/version_git.jl $(BUILDDIR)/version_git.jl.phony $(build_datarootdir)/julia/src/version_git.jl.phony \ + $(BUILDDIR)/build_h.jl.phony $(build_datarootdir)/julia/src/build_h.jl.phony \ + clean all .FORCE clean: -rm -f $(BUILDDIR)/pcre_h.jl @@ -281,4 +316,5 @@ clean: -rm -f $(BUILDDIR)/file_constants.jl -rm -f $(BUILDDIR)/version_git.jl -rm -f $(BUILDDIR)/version_git.jl.phony + -rm -rf $(build_datarootdir)/julia/src/* -rm -f $(build_private_libdir)/lib*.$(SHLIB_EXT)* diff --git a/base/cpuid.jl b/base/cpuid.jl index 48930d8064ba9..476e4b49fa1dc 100644 --- a/base/cpuid.jl +++ b/base/cpuid.jl @@ -21,7 +21,7 @@ Base.:<=(a::ISA, b::ISA) = a.features <= b.features Base.:<(a::ISA, b::ISA) = a.features < b.features Base.isless(a::ISA, b::ISA) = a < b -include(string(length(Core.ARGS) >= 2 ? Core.ARGS[2] : "", "features_h.jl")) # include($BUILDROOT/base/features_h.jl) +include("../features_h.jl") # Keep in sync with `arch_march_isa_mapping`. const ISAs_by_family = Dict( diff --git a/base/filesystem.jl b/base/filesystem.jl index 30d4928b9f0b6..863eedf8ade9d 100644 --- a/base/filesystem.jl +++ b/base/filesystem.jl @@ -91,7 +91,7 @@ uv_fs_req_cleanup(req) = ccall(:uv_fs_req_cleanup, Cvoid, (Ptr{Cvoid},), req) include("path.jl") include("stat.jl") include("file.jl") -include(string(length(Core.ARGS) >= 2 ? Core.ARGS[2] : "", "file_constants.jl")) # include($BUILDROOT/base/file_constants.jl) +include("../file_constants.jl") ## Operations with File (fd) objects ## diff --git a/base/initdefs.jl b/base/initdefs.jl index 1988e56c6eb1d..89fc88b0673a3 100644 --- a/base/initdefs.jl +++ b/base/initdefs.jl @@ -93,6 +93,7 @@ function append_default_depot_path!(DEPOT_PATH) path in DEPOT_PATH || push!(DEPOT_PATH, path) path = abspath(Sys.BINDIR, "..", "share", "julia") path in DEPOT_PATH || push!(DEPOT_PATH, path) + return DEPOT_PATH end function init_depot_path() @@ -111,6 +112,7 @@ function init_depot_path() else append_default_depot_path!(DEPOT_PATH) end + nothing end ## LOAD_PATH & ACTIVE_PROJECT ## @@ -220,9 +222,7 @@ function parse_load_path(str::String) end function init_load_path() - if Base.creating_sysimg - paths = ["@stdlib"] - elseif haskey(ENV, "JULIA_LOAD_PATH") + if haskey(ENV, "JULIA_LOAD_PATH") paths = parse_load_path(ENV["JULIA_LOAD_PATH"]) else paths = filter!(env -> env !== nothing, diff --git a/base/libc.jl b/base/libc.jl index 7d88e89bf605a..a14920ec4f6b8 100644 --- a/base/libc.jl +++ b/base/libc.jl @@ -14,7 +14,7 @@ if Sys.iswindows() export GetLastError, FormatMessage end -include(string(length(Core.ARGS) >= 2 ? Core.ARGS[2] : "", "errno_h.jl")) # include($BUILDROOT/base/errno_h.jl) +include("../errno_h.jl") ## RawFD ## diff --git a/base/libuv.jl b/base/libuv.jl index 64b228c6500e7..ea3d64072378f 100644 --- a/base/libuv.jl +++ b/base/libuv.jl @@ -2,7 +2,7 @@ # Core definitions for interacting with the libuv library from Julia -include(string(length(Core.ARGS) >= 2 ? Core.ARGS[2] : "", "uv_constants.jl")) # include($BUILDROOT/base/uv_constants.jl) +include("../uv_constants.jl") # convert UV handle data to julia object, checking for null function uv_sizeof_handle(handle) diff --git a/base/loading.jl b/base/loading.jl index 88ba1050d2b02..740c2f922259e 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -42,7 +42,7 @@ elseif Sys.isapple() # char filename[max_filename_length]; # }; # Buffer buf; - # getattrpath(path, &attr_list, &buf, sizeof(buf), FSOPT_NOFOLLOW); + # getattrlist(path, &attr_list, &buf, sizeof(buf), FSOPT_NOFOLLOW); function isfile_casesensitive(path) isaccessiblefile(path) || return false path_basename = String(basename(path)) @@ -804,7 +804,7 @@ end function find_source_file(path::AbstractString) (isabspath(path) || isfile(path)) && return path - base_path = joinpath(Sys.BINDIR, DATAROOTDIR, "julia", "base", path) + base_path = joinpath(Sys.BINDIR, DATAROOTDIR, "julia", "src", "base", path) return isfile(base_path) ? normpath(base_path) : nothing end diff --git a/base/pcre.jl b/base/pcre.jl index d689e9be29113..963b3ee4726a2 100644 --- a/base/pcre.jl +++ b/base/pcre.jl @@ -6,8 +6,7 @@ module PCRE import ..RefValue -# include($BUILDROOT/base/pcre_h.jl) -include(string(length(Core.ARGS) >= 2 ? Core.ARGS[2] : "", "pcre_h.jl")) +include("../pcre_h.jl") const PCRE_LIB = "libpcre2-8" diff --git a/base/sysimg.jl b/base/sysimg.jl index d2d18c7d23111..1f910db36404f 100644 --- a/base/sysimg.jl +++ b/base/sysimg.jl @@ -11,14 +11,13 @@ import Base.MainInclude: eval, include pushfirst!(Base._included_files, (@__MODULE__, joinpath(@__DIR__, "Base.jl"))) pushfirst!(Base._included_files, (@__MODULE__, joinpath(@__DIR__, "sysimg.jl"))) -# set up depot & load paths to be able to find stdlib packages -@eval Base creating_sysimg = true -Base.init_depot_path() -Base.init_load_path() - if Base.is_primary_base_module # load some stdlib packages but don't put their names in Main let + # set up depot & load paths to be able to find stdlib packages + push!(empty!(LOAD_PATH), "@stdlib") + Base.append_default_depot_path!(DEPOT_PATH) + # Stdlibs sorted in dependency, then alphabetical, order by contrib/print_sorted_stdlibs.jl # Run with the `--exclude-jlls` option to filter out all JLL packages stdlibs = [ diff --git a/doc/src/devdocs/build/distributing.md b/doc/src/devdocs/build/distributing.md index c49f6f071224c..9ae75a8683020 100644 --- a/doc/src/devdocs/build/distributing.md +++ b/doc/src/devdocs/build/distributing.md @@ -18,12 +18,12 @@ GPL licensed. We do hope to have a non-GPL distribution of Julia in the future. Versioning and Git ------------------ The Makefile uses both the `VERSION` file and commit hashes and tags from the -git repository to generate the `base/version_git.jl` with information we use to +git repository to generate the `version_git.jl` with information we use to fill the splash screen and the `versioninfo()` output. If you for some reason don't want to have the git repository available when building you should -pregenerate the `base/version_git.jl` file with: +pre-generate the `version_git.jl` file with: - make -C base version_git.jl.phony + make -C base version_git.jl Julia has lots of build dependencies where we use patched versions that has not yet been included by the popular package managers. These dependencies will usually diff --git a/src/base b/src/base new file mode 120000 index 0000000000000..24312d19b81d4 --- /dev/null +++ b/src/base @@ -0,0 +1 @@ +../base \ No newline at end of file diff --git a/stdlib/Profile/src/Profile.jl b/stdlib/Profile/src/Profile.jl index e24544839fc5f..593f265eba3fa 100644 --- a/stdlib/Profile/src/Profile.jl +++ b/stdlib/Profile/src/Profile.jl @@ -504,7 +504,7 @@ function short_path(spath::Symbol, filenamecache::Dict{Symbol, String}) end end return path - elseif isfile(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "base", path)) + elseif isfile(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "src", "base", path)) # do the same mechanic for Base (or Core/Compiler) files as above, # but they start from a relative path return joinpath("@Base", normpath(path)) diff --git a/sysimage.mk b/sysimage.mk index 2d154672d8130..8b7d19926f9da 100644 --- a/sysimage.mk +++ b/sysimage.mk @@ -20,54 +20,51 @@ $(build_private_libdir)/%.$(SHLIB_EXT): $(build_private_libdir)/%-o.a @$(INSTALL_NAME_CMD)$(notdir $@) $@ @$(DSYMUTIL) $@ -COMPILER_SRCS := $(addprefix $(JULIAHOME)/, \ - base/boot.jl \ - base/docs/core.jl \ - base/abstractarray.jl \ - base/abstractdict.jl \ - base/array.jl \ - base/bitarray.jl \ - base/bitset.jl \ - base/bool.jl \ - base/ctypes.jl \ - base/error.jl \ - base/essentials.jl \ - base/expr.jl \ - base/generator.jl \ - base/int.jl \ - base/indices.jl \ - base/iterators.jl \ - base/namedtuple.jl \ - base/number.jl \ - base/operators.jl \ - base/options.jl \ - base/pair.jl \ - base/pointer.jl \ - base/promotion.jl \ - base/range.jl \ - base/reflection.jl \ - base/traits.jl \ - base/refvalue.jl \ - base/tuple.jl) -COMPILER_SRCS += $(shell find $(JULIAHOME)/base/compiler -name \*.jl) -# sort these to remove duplicates -BASE_SRCS := $(sort $(shell find $(JULIAHOME)/base -name \*.jl -and -not -name sysimg.jl) \ - $(shell find $(BUILDROOT)/base -name \*.jl -and -not -name sysimg.jl)) -STDLIB_SRCS := $(JULIAHOME)/base/sysimg.jl $(shell find $(build_datarootdir)/julia/stdlib/$(VERSDIR)/*/src -name \*.jl) \ - $(build_prefix)/manifest/Pkg -RELBUILDROOT := $(call rel_path,$(JULIAHOME)/base,$(BUILDROOT)/base)/ # <-- make sure this always has a trailing slash +BASE_DIR := $(build_datarootdir)/julia/src +COMPILER_SRCS := $(addprefix $(BASE_DIR)/base/, \ + boot.jl \ + docs/core.jl \ + abstractarray.jl \ + abstractdict.jl \ + array.jl \ + bitarray.jl \ + bitset.jl \ + bool.jl \ + ctypes.jl \ + error.jl \ + essentials.jl \ + expr.jl \ + generator.jl \ + int.jl \ + indices.jl \ + iterators.jl \ + namedtuple.jl \ + number.jl \ + operators.jl \ + options.jl \ + pair.jl \ + pointer.jl \ + promotion.jl \ + range.jl \ + reflection.jl \ + traits.jl \ + refvalue.jl \ + tuple.jl) +COMPILER_SRCS += $(shell find $(BASE_DIR)/base/compiler -name \*.jl) +BASE_SRCS := $(shell find $(BASE_DIR) -name \*.jl -and -not -name sysimg.jl) +STDLIB_SRCS := $(BASE_DIR)/base/sysimg.jl $(shell find $(build_datarootdir)/julia/stdlib/$(VERSDIR)/*/src -name \*.jl) $(build_private_libdir)/corecompiler.ji: $(COMPILER_SRCS) - @$(call PRINT_JULIA, cd $(JULIAHOME)/base && \ + @$(call PRINT_JULIA, cd $(BASE_DIR)/base && \ $(call spawn,$(JULIA_EXECUTABLE)) -C "$(JULIA_CPU_TARGET)" --output-ji $(call cygpath_w,$@).tmp \ --startup-file=no --warn-overwrite=yes -g$(BOOTSTRAP_DEBUG_LEVEL) -O0 compiler/compiler.jl) @mv $@.tmp $@ $(build_private_libdir)/sys.ji: $(build_private_libdir)/corecompiler.ji $(JULIAHOME)/VERSION $(BASE_SRCS) $(STDLIB_SRCS) - @$(call PRINT_JULIA, cd $(JULIAHOME)/base && \ + @$(call PRINT_JULIA, cd $(BASE_DIR)/base && \ if ! JULIA_BINDIR=$(call cygpath_w,$(build_bindir)) WINEPATH="$(call cygpath_w,$(build_bindir));$$WINEPATH" \ $(call spawn, $(JULIA_EXECUTABLE)) -g1 -O0 -C "$(JULIA_CPU_TARGET)" --output-ji $(call cygpath_w,$@).tmp $(JULIA_SYSIMG_BUILD_FLAGS) \ - --startup-file=no --warn-overwrite=yes --sysimage $(call cygpath_w,$<) sysimg.jl $(RELBUILDROOT); then \ + --startup-file=no --warn-overwrite=yes --sysimage $(call cygpath_w,$<) sysimg.jl; then \ echo '*** This error might be fixed by running `make clean`. If the error persists$(COMMA) try `make cleanall`. ***'; \ false; \ fi ) @@ -75,7 +72,7 @@ $(build_private_libdir)/sys.ji: $(build_private_libdir)/corecompiler.ji $(JULIAH define sysimg_builder $$(build_private_libdir)/sys$1-o.a $$(build_private_libdir)/sys$1-bc.a : $$(build_private_libdir)/sys$1-%.a : $$(build_private_libdir)/sys.ji - @$$(call PRINT_JULIA, cd $$(JULIAHOME)/base && \ + @$$(call PRINT_JULIA, cd $$(BASE_DIR)/base && \ if ! JULIA_BINDIR=$$(call cygpath_w,$(build_bindir)) WINEPATH="$$(call cygpath_w,$$(build_bindir));$$$$WINEPATH" \ JULIA_NUM_THREADS=1 \ $$(call spawn, $3) $2 -C "$$(JULIA_CPU_TARGET)" --output-$$* $$(call cygpath_w,$$@).tmp $$(JULIA_SYSIMG_BUILD_FLAGS) \