Skip to content

Commit

Permalink
Add checkbounds switch stdlibs
Browse files Browse the repository at this point in the history
  • Loading branch information
Keno committed Jul 18, 2023
1 parent 6e915f9 commit 26c14f8
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 18 deletions.
13 changes: 8 additions & 5 deletions base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,14 @@ function exec_options(opts)
end

# Maybe redefine bounds checking if requested
if JLOptions().check_bounds != 0
if JLOptions().check_bounds == 1
Core.eval(Main, :(Core.should_check_bounds(boundscheck::Bool) = true))
else
Core.eval(Main, :(Core.should_check_bounds(boundscheck::Bool) = false))
if ccall(:jl_generating_output, Cint, ()) == 0
# Inoperative during output generation. Determined by mandatory deps mechanism.
if JLOptions().check_bounds != 0
if JLOptions().check_bounds == 1
require(PkgId(UUID((0xb3a877e5_8181_4b4a, 0x8173_0b9cb13136fe)),"--check-bounds=yes"))
else
require(PkgId(UUID((0x5ece1bc4_2007_43a8, 0xac47_40059be74678)),"--check-bounds=no"))
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2924,7 +2924,7 @@ function maybe_cachefile_lock(f, pkg::PkgId, srcpath::String; stale_age=300)
pid, hostname, age = invokelatest(parse_pidfile_hook, pidfile)
verbosity = isinteractive() ? CoreLogging.Info : CoreLogging.Debug
if isempty(hostname) || hostname == gethostname()
@logmsg verbosity "Waiting for another process (pid: $pid) to finish precompiling $pkg"
@logmsg verbosity "Waiting for another process (pid: $pid) to finish precompiling $pkg (pidfile: $pidfile)"
else
@logmsg verbosity "Waiting for another machine (hostname: $hostname, pid: $pid) to finish precompiling $pkg"
end
Expand Down
33 changes: 22 additions & 11 deletions pkgimage.mk
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,44 @@ all-release: $(addprefix cache-release-, $(STDLIBS))
all-debug: $(addprefix cache-debug-, $(STDLIBS))

define pkgimg_builder
$1_SRCS := $$(shell find $$(build_datarootdir)/julia/stdlib/$$(VERSDIR)/$1/src -name \*.jl) \
PKGIMG_SRCS := $$(shell find "$$(build_datarootdir)/julia/stdlib/$$(VERSDIR)/$1/src" -name \*.jl) \
$$(wildcard $$(build_prefix)/manifest/$$(VERSDIR)/$1)
$$(BUILDDIR)/stdlib/$1.release.image: $$($1_SRCS) $$(addsuffix .release.image,$$(addprefix $$(BUILDDIR)/stdlib/,$2)) $(build_private_libdir)/sys.$(SHLIB_EXT)
# @$$(call PRINT_JULIA, $$(call spawn,$$(JULIA_EXECUTABLE)) --startup-file=no --check-bounds=yes -e 'Base.compilecache(Base.identify_package("$1"))')
PKGIMG_SENTINEL_NAME = $(subst =,_EQ_,$1)
$$(BUILDDIR)/stdlib/$$(PKGIMG_SENTINEL_NAME).release.image: $$(PKGIMG_SRCS) $$(addsuffix .release.image,$$(addprefix $$(BUILDDIR)/stdlib/,$2)) $(build_private_libdir)/sys.$(SHLIB_EXT)
@$$(call PRINT_JULIA, $$(call spawn,$$(JULIA_EXECUTABLE)) --startup-file=no -e 'Base.compilecache(Base.identify_package("$1"))')
touch $$@
cache-release-$1: $$(BUILDDIR)/stdlib/$1.release.image
$$(BUILDDIR)/stdlib/$1.debug.image: $$($1_SRCS) $$(addsuffix .debug.image,$$(addprefix $$(BUILDDIR)/stdlib/,$2)) $(build_private_libdir)/sys-debug.$(SHLIB_EXT)
# @$$(call PRINT_JULIA, $$(call spawn,$$(JULIA_EXECUTABLE)) --startup-file=no --check-bounds=yes -e 'Base.compilecache(Base.identify_package("$1"))')
$$(BUILDDIR)/stdlib/$$(PKGIMG_SENTINEL_NAME).release.checkbounds.image: $$(PKGIMG_SRCS) $$(addsuffix .release.checkbounds.image,$$(addprefix $$(BUILDDIR)/stdlib/,$2)) $$(BUILDDIR)/stdlib/--check-bounds_EQ_yes.release.image $(build_private_libdir)/sys.$(SHLIB_EXT)
@$$(call PRINT_JULIA, $$(call spawn,$$(JULIA_EXECUTABLE)) --startup-file=no --check-bounds=yes -e 'Base.compilecache(Base.identify_package("$1"))')
touch $$@
cache-release-$$(PKGIMG_SENTINEL_NAME): $$(BUILDDIR)/stdlib/$1.release.image $$(BUILDDIR)/stdlib/$1.release.checkbounds.image
$$(BUILDDIR)/stdlib/$$(PKGIMG_SENTINEL_NAME).debug.image: $$(PKGIMG_SRCS) $$(addsuffix .debug.image,$$(addprefix $$(BUILDDIR)/stdlib/,$2)) $(build_private_libdir)/sys-debug.$(SHLIB_EXT)
@$$(call PRINT_JULIA, $$(call spawn,$$(JULIA_EXECUTABLE)) --startup-file=no -e 'Base.compilecache(Base.identify_package("$1"))')
cache-debug-$1: $$(BUILDDIR)/stdlib/$1.debug.image
.SECONDARY: $$(BUILDDIR)/stdlib/$1.release.image $$(BUILDDIR)/stdlib/$1.debug.image
touch $$@
$$(BUILDDIR)/stdlib/$$(PKGIMG_SENTINEL_NAME).debug.checkbounds.image: $$(PKGIMG_SRCS) $$(addsuffix .debug.checkbounds.image,$$(addprefix $$(BUILDDIR)/stdlib/,$2)) $$(BUILDDIR)/stdlib/--check-bounds_EQ_yes.debug.image $(build_private_libdir)/sys-debug.$(SHLIB_EXT)
@$$(call PRINT_JULIA, $$(call spawn,$$(JULIA_EXECUTABLE)) --startup-file=no --check-bounds=yes -e 'Base.compilecache(Base.identify_package("$1"))')
touch $$@
cache-debug-$$(PKGIMG_SENTINEL_NAME): $$(BUILDDIR)/stdlib/$$(PKGIMG_SENTINEL_NAME).debug.image $$(BUILDDIR)/stdlib/$$(PKGIMG_SENTINEL_NAME).debug.checkbounds.image
.SECONDARY: $$(BUILDDIR)/stdlib/$$(PKGIMG_SENTINEL_NAME).release.image $$(BUILDDIR)/stdlib/$$(PKGIMG_SENTINEL_NAME).release.checkbounds.image $$(BUILDDIR)/stdlib/$$(PKGIMG_SENTINEL_NAME).debug.image $$(BUILDDIR)/stdlib/$$(PKGIMG_SENTINEL_NAME).debug.checkbounds.image
endef

# Used to just define them in the dependency graph
# reside in the system image
define sysimg_builder
$$(BUILDDIR)/stdlib/$1.release.image:
touch $$@
cache-release-$1: $$(BUILDDIR)/stdlib/$1.release.image
$$(BUILDDIR)/stdlib/$1.release.checkbounds.image:
touch $$@
cache-release-$1: $$(BUILDDIR)/stdlib/$1.release.image $$(BUILDDIR)/stdlib/$1.release.checkbounds.image
$$(BUILDDIR)/stdlib/$1.debug.image:
touch $$@
cache-debug-$1: $$(BUILDDIR)/stdlib/$1.debug.image
.SECONDARY: $$(BUILDDIR)/stdlib/$1.release.image $$(BUILDDIR)/stdlib/$1.debug.image
$$(BUILDDIR)/stdlib/$1.debug.checkbounds.image:
touch $$@
cache-debug-$1: $$(BUILDDIR)/stdlib/$1.debug.image $$(BUILDDIR)/stdlib/$1.debug.checkbounds.image
.SECONDARY: $$(BUILDDIR)/stdlib/$1.release.image $$(BUILDDIR)/stdlib/$1.release.checkbounds.image $$(BUILDDIR)/stdlib/$1.debug.image $$(BUILDDIR)/stdlib/$1.debug.checkbounds.image
endef

# no dependencies
$(eval $(call pkgimg_builder,--check-bounds=yes,))
$(eval $(call pkgimg_builder,MozillaCACerts_jll,))
$(eval $(call sysimg_builder,ArgTools,))
$(eval $(call sysimg_builder,Artifacts,))
Expand Down
2 changes: 2 additions & 0 deletions stdlib/--check-bounds=no/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name = "--check-bounds=no"
uuid = "5ece1bc4-2007-43a8-ac47-40059be74678"
8 changes: 8 additions & 0 deletions stdlib/--check-bounds=no/src/--check-bounds=no.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
__precompile__(:mandatory)
module var"--check-bounds=no"

@Base.recompile_invalidations begin
Core.should_check_bounds(boundscheck::Bool) = false
end

end
2 changes: 2 additions & 0 deletions stdlib/--check-bounds=yes/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name = "--check-bounds=yes"
uuid = "b3a877e5-8181-4b4a-8173-0b9cb13136fe"
8 changes: 8 additions & 0 deletions stdlib/--check-bounds=yes/src/--check-bounds=yes.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
__precompile__(:mandatory)
module var"--check-bounds=yes"

@Base.recompile_invalidations begin
Core.should_check_bounds(boundscheck::Bool) = true
end

end
2 changes: 1 addition & 1 deletion stdlib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ $(foreach jll,$(JLLS),$(eval $(call download-artifacts-toml,$(jll))))
STDLIBS = Artifacts Base64 CRC32c Dates Distributed FileWatching \
Future InteractiveUtils LazyArtifacts Libdl LibGit2 LinearAlgebra Logging \
Markdown Mmap Printf Profile Random REPL Serialization \
SharedArrays Sockets Test TOML Unicode UUIDs \
SharedArrays Sockets Test TOML Unicode UUIDs --check-bounds=yes --check-bounds=no \
$(JLL_NAMES)

STDLIBS_EXT = Pkg Statistics LibCURL DelimitedFiles Downloads ArgTools Tar NetworkOptions SuiteSparse SparseArrays SHA
Expand Down

0 comments on commit 26c14f8

Please sign in to comment.