-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Labels
Description
@wsmoses is encountering embedded null pointers in IR emitted during precompilation.
The root cause for this is that we have a control flag .imaging that controls if we are emitting IR for JIT (with embedded pointers) or IR for caching with relocation.
That flag is either set as an argument by us (which we never turned on #125 #348) or calculated based on the startup flags of Julia
This didn't show up before since outside precompilation imaging_default() returns false.
Likely the best way would be to follow the pattern we have for 1.13 and above
Lines 770 to 786 in e2d8505
| # Since Julia 1.13, the caller is responsible for initializing global variables that | |
| # point to global values or bindings with their address in memory. | |
| num_gvars = Ref{Csize_t}(0) | |
| @ccall jl_get_llvm_gvs(native_code::Ptr{Cvoid}, num_gvars::Ptr{Csize_t}, | |
| C_NULL::Ptr{Cvoid})::Nothing | |
| gvs = Vector{Ptr{LLVM.API.LLVMOpaqueValue}}(undef, num_gvars[]) | |
| @ccall jl_get_llvm_gvs(native_code::Ptr{Cvoid}, num_gvars::Ptr{Csize_t}, | |
| gvs::Ptr{LLVM.API.LLVMOpaqueValue})::Nothing | |
| inits = Vector{Ptr{Cvoid}}(undef, num_gvars[]) | |
| @ccall jl_get_llvm_gv_inits(native_code::Ptr{Cvoid}, num_gvars::Ptr{Csize_t}, | |
| inits::Ptr{Cvoid})::Nothing | |
| for (gv_ref, init) in zip(gvs, inits) | |
| gv = GlobalVariable(gv_ref) | |
| val = const_inttoptr(ConstantInt(Int64(init)), LLVM.PointerType()) | |
| initializer!(gv, val) | |
| end |
#752 is an attempt to do that by looking at the table of global values, but we lack the infrastructure to access all the information needed.
Reactions are currently unavailable