Skip to content

Commit e365477

Browse files
committed
Run __init__() even in sysimage builds
This change makes the LinearAlgebra initialization code run during the sysimage build, similar to how it would run when using LinearAlgebra at top-level in a normal package. In this configuration, we can't rely on the serializer to isolate side-effects for us, so we have to manually ensure that any mutations that we perform here are not accidentally persisted to run-time.
1 parent 2c3fe9b commit e365477

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/LinearAlgebra.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,8 @@ function lbt_openblas_onload_callback()
841841
end
842842
BLAS.lbt_set_num_threads(nthreads)
843843
end
844+
845+
return nothing
844846
end
845847

846848
function __init__()
@@ -849,4 +851,7 @@ function __init__()
849851
libblastrampoline_jll.add_dependency!(OpenBLAS_jll, libopenblas, lbt_openblas_onload_callback)
850852
end
851853

854+
# Register eagerly, so that LinearAlgebra is available for sysimage builds (incl. `--trim`)
855+
libblastrampoline_jll.add_dependency!(OpenBLAS_jll, libopenblas, lbt_openblas_onload_callback)
856+
852857
end # module LinearAlgebra

0 commit comments

Comments
 (0)