Skip to content

Commit b41f62a

Browse files
KenoJamesWrigley
authored andcommitted
Don't use internal jl_set_const to create constants
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.
1 parent 9843937 commit b41f62a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/clusterserialize.jl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,21 @@ function deserialize_global_from_main(s::ClusterSerializer, sym)
167167
return nothing
168168
end
169169
end
170-
Core.eval(Main, Expr(:global, sym))
170+
171171
if sym_isconst
172-
ccall(:jl_set_const, Cvoid, (Any, Any, Any), Main, sym, v)
172+
@static if VERSION >= v"1.12"
173+
# Note that the post-lowering const form is not allowed in value
174+
# position, so there needs to be a dummy `nothing` argument to drop the
175+
# return value.
176+
Core.eval(Main, Expr(:block,
177+
Expr(:const, GlobalRef(Main, sym), v),
178+
nothing))
179+
else
180+
Core.eval(Main, Expr(:global, sym))
181+
ccall(:jl_set_const, Cvoid, (Any, Any, Any), Main, sym, v)
182+
end
173183
else
184+
Core.eval(Main, Expr(:global, sym))
174185
invokelatest(setglobal!, Main, sym, v)
175186
end
176187
return nothing

0 commit comments

Comments
 (0)