Skip to content

Commit

Permalink
Don't use internal jl_set_const to create constants
Browse files Browse the repository at this point in the history
The internal function `jl_set_const` is allowed during bootstrap only
and ignores world age partition. This would give incorrect results after
JuliaLang/julia#57150. Just eval the constant definition directly,
which has well defined semantics.
  • Loading branch information
Keno authored and JamesWrigley committed Jan 26, 2025
1 parent 1c7eb92 commit 52d5703
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/clusterserialize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,15 @@ function deserialize_global_from_main(s::ClusterSerializer, sym)
return nothing
end
end
Core.eval(Main, Expr(:global, sym))
if sym_isconst
ccall(:jl_set_const, Cvoid, (Any, Any, Any), Main, sym, v)
# Note that the post-lowering const form is not allowed in value
# position, so there needs to be a dummy `nothing` argument to drop the
# return value.
Core.eval(Main, Expr(:block,
Expr(:const, GlobalRef(Main, sym), v),
nothing))
else
Core.eval(Main, Expr(:global, sym))
invokelatest(setglobal!, Main, sym, v)
end
return nothing
Expand Down

0 comments on commit 52d5703

Please sign in to comment.