Skip to content

Commit 2d8adfb

Browse files
authored
initialize RNGs in sysimage process (#579)
1 parent 6f4e3cc commit 2d8adfb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/PackageCompiler.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ function run_precompilation_script(project::String, sysimg::String, precompile_f
254254
end
255255

256256

257-
function create_sysimg_object_file(object_file::String,
257+
function create_sysimg_object_file(object_file::String,
258258
packages::Vector{String},
259259
packages_sysimg::Set{Base.PkgId};
260260
project::String,
@@ -330,6 +330,13 @@ function create_sysimg_object_file(object_file::String,
330330
if isdefined(Base, :init_active_project)
331331
Base.init_active_project()
332332
end
333+
let
334+
r = get(Base.loaded_modules, Base.PkgId(Base.UUID("9a3f8284-a2c9-5f02-9a11-845980a1fd5c"), "Random"), nothing)
335+
if r !== nothing
336+
# See e.g. https://discourse.julialang.org/t/assertionerror-0-tid-length-thread-rngs-during-compilation-with-packagecompiler/69179
337+
r.__init__()
338+
end
339+
end
333340
Base.init_depot_path()
334341
""")
335342

0 commit comments

Comments
 (0)