Skip to content

Commit 820415d

Browse files
committed
ensure that the non-REPL precompile code actually get precompiled (#41898)
(cherry picked from commit e8faf9d)
1 parent cdfdab0 commit 820415d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

contrib/generate_precompile.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,20 @@ function generate_precompile_statements()
202202
module $pkgname
203203
end
204204
""")
205-
tmp = tempname()
205+
tmp_prec = tempname()
206+
tmp_proc = tempname()
206207
s = """
207208
pushfirst!(DEPOT_PATH, $(repr(prec_path)));
208-
Base.PRECOMPILE_TRACE_COMPILE[] = $(repr(tmp));
209+
Base.PRECOMPILE_TRACE_COMPILE[] = $(repr(tmp_prec));
209210
Base.compilecache(Base.PkgId($(repr(pkgname))), $(repr(path)))
210211
$precompile_script
211212
"""
212-
run(`$(julia_exepath()) -O0 --sysimage $sysimg --startup-file=no -Cnative -e $s`)
213-
for statement in split(read(tmp, String), '\n')
214-
push!(statements, statement)
213+
run(`$(julia_exepath()) -O0 --sysimage $sysimg --trace-compile=$tmp_proc --startup-file=no -Cnative -e $s`)
214+
for f in (tmp_prec, tmp_proc)
215+
for statement in split(read(f, String), '\n')
216+
occursin("Main.", statement) && continue
217+
push!(statements, statement)
218+
end
215219
end
216220
end
217221

0 commit comments

Comments
 (0)