Skip to content

Commit df7a02f

Browse files
committed
Add precompilation instructions for lazy artifacts.
1 parent 9644b0f commit df7a02f

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

src/JLLWrappers.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module JLLWrappers
22

33
@static if VERSION >= v"1.6.0-DEV"
44
using Preferences
5+
using Artifacts: Artifacts
56
end
67

78
@static if VERSION >= v"1.6.0-DEV"

src/runtime.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,27 @@ function get_julia_libpaths()
9292
end
9393
return JULIA_LIBDIRS
9494
end
95+
96+
# Precompile-time hook invoked by `@generate_wrapper_header` to cover the call sites
97+
# `find_artifact_dir` and `@generate_init_footer` reach at `__init__`
98+
@static if VERSION >= v"1.6.0-DEV"
99+
function precompile_init_callsites(jll_module::Module)
100+
# `@artifact_str` passes `Val(LA)` where `LA` is the first of these
101+
# modules imported by the JLL. The `Val{Artifacts}` flavour is already
102+
# covered by a `precompile(...)` statement in the Artifacts stdlib itself.
103+
for modname in (:LazyArtifacts, :Pkg, :PkgArtifacts)
104+
if isdefined(jll_module, modname)
105+
LA = getfield(jll_module, modname)
106+
argtypes = (Module, String, SubString{String}, String, Dict{String,Any},
107+
Base.SHA1, Base.BinaryPlatforms.Platform, Val{LA})
108+
Base.precompile(Artifacts._artifact_str, argtypes)
109+
Base.precompile(Artifacts.__artifact_str, argtypes)
110+
break
111+
end
112+
end
113+
Base.precompile(get_julia_libpaths, ())
114+
return nothing
115+
end
116+
else
117+
precompile_init_callsites(::Module) = nothing
118+
end

src/wrapper_generators.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ macro generate_wrapper_header(src_name)
2222
# to precompile these into Pkgimage
2323
Base.precompile(find_artifact_dir, ())
2424
Base.precompile(eager_mode, ())
25+
JLLWrappers.precompile_init_callsites(@__MODULE__)
2526
end
2627
end)
2728
end

0 commit comments

Comments
 (0)