Skip to content

Commit 4165826

Browse files
committed
Add test-JL_stdlibs target for precompiling stdlibs with JuliaLowering
This has a significant blacklist for now, but eventually we should be able to build all of our stdlibs with JuliaLowering (and even include it by default in the sysimage)
1 parent e3573a8 commit 4165826

File tree

3 files changed

+48
-3
lines changed

3 files changed

+48
-3
lines changed

base/Base.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,8 @@ function __init__()
397397
if get_bool_env("JULIA_USE_FLISP_PARSER", false) === false
398398
JuliaSyntax.enable_in_core!()
399399
end
400-
if get_bool_env("JULIA_USE_FLISP_LOWERING", true) === false
401-
# This does not work by default, but JuliaLowering can be added to
400+
if (@isdefined JuliaLowering) && get_bool_env("JULIA_USE_FLISP_LOWERING", true) === false
401+
# This is not available by default, but JuliaLowering can be added to
402402
# Base after-the-fact via an incremental sysimage build.
403403
JuliaLowering.activate!()
404404
end

test/JL_stdlibs.jl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import Libdl
2+
3+
### 34 / 51 (non-sysimage) stdlibs precompile successfully with JuliaLowering ###
4+
const INCOMPATIBLE_STDLIBS = String[
5+
"Statistics", "JuliaSyntaxHighlighting", "Markdown", "Downloads", "LibGit2",
6+
"InteractiveUtils", "Test", "REPL", "Pkg", "LazyArtifacts", "SparseArrays",
7+
"Dates", "TOML"
8+
]
9+
10+
# ensure JL-inclusive sysimage is built / available
11+
run(`$(ENV["MAKE"]) -C $(ENV["BUILDROOT"]) -f sysimage.mk sysimg-JL-$(ENV["JULIA_BUILD_MODE"])`)
12+
13+
stdlibs_to_test = filter(name -> !in(name, INCOMPATIBLE_STDLIBS), String[
14+
strip(split(line, "=")[1])
15+
for line in readlines("$(ENV["JULIAHOME"])/stdlib/Project.toml")[2:end]
16+
])
17+
configs = [
18+
``=>Base.CacheFlags(check_bounds=0, debug_level=2, opt_level=3),
19+
``=>Base.CacheFlags(check_bounds=1, debug_level=2, opt_level=3),
20+
]
21+
compilecache_command = "using Base: CacheFlags; Base.Precompilation.precompilepkgs($(stdlibs_to_test); configs=$(configs))"
22+
23+
debug = ENV["JULIA_BUILD_MODE"] == "debug" ? "-debug" : ""
24+
sysimage = joinpath(dirname(unsafe_string(Base.JLOptions().image_file)), "sys-JL$(debug).$(Libdl.dlext)")
25+
26+
# pre-compile stdlibs (into temporary depot)
27+
mktempdir() do tmp_depot
28+
cmd = addenv(
29+
`$(ENV["JULIA_EXECUTABLE"]) --sysimage $(sysimage) --startup-file=no -e $compilecache_command`,
30+
"JULIA_LOAD_PATH" => "@stdlib$(Base.Linking.pathsep)$(joinpath(ENV["JULIAHOME"], "stdlib"))",
31+
"JULIA_CPU_TARGET" => "sysimage",
32+
"JULIA_USE_FLISP_LOWERING" => "0",
33+
"JULIA_USE_FALLBACK_REPL" => "0",
34+
"JULIA_DEPOT_PATH" => tmp_depot,
35+
; inherit = true
36+
)
37+
success(run(cmd))
38+
end

test/Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ export JULIA_LOAD_PATH := @$(PATHSEP)@stdlib
1111
unexport JULIA_PROJECT :=
1212
unexport JULIA_BINDIR :=
1313

14+
# used by JL_stdlibs.jl test (invokes `make` for JL sysimage)
15+
export MAKE
16+
export BUILDROOT
17+
export JULIAHOME
18+
export JULIA_EXECUTABLE
19+
export JULIA_BUILD_MODE
20+
1421
TESTGROUPS = unicode strings compiler Compiler JuliaSyntax JuliaLowering
1522
TESTS = all default stdlib $(TESTGROUPS) \
1623
$(patsubst $(STDLIBDIR)/%/,%,$(dir $(wildcard $(STDLIBDIR)/*/.))) \
@@ -33,7 +40,7 @@ default:
3340

3441
.PHONY: $(TESTS)
3542
$(TESTS):
36-
@cd $(SRCDIR) && \
43+
+@cd $(SRCDIR) && \
3744
$(call PRINT_JULIA, $(call spawn,$(JULIA_EXECUTABLE)) $(TEST_JULIA_OPTIONS) ./runtests.jl $(TEST_SCRIPT_OPTIONS) $@)
3845

3946
.PHONY: install-revise-deps

0 commit comments

Comments
 (0)