@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.
https://github.com/JuliaLang/julia/blob/21eadc5e3129a557df1eb385113132a97996af5e/src/aotcompile.cpp#L342
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
https://github.com/JuliaLang/julia/blob/21eadc5e3129a557df1eb385113132a97996af5e/src/jitlayers.h#L77-L78
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
|
# 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 |
which makes the handling of global values consistent
#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.
@wsmoses is encountering embedded null pointers in IR emitted during precompilation.
The root cause for this is that we have a control flag
.imagingthat controls if we are emitting IR for JIT (with embedded pointers) or IR for caching with relocation.https://github.com/JuliaLang/julia/blob/21eadc5e3129a557df1eb385113132a97996af5e/src/aotcompile.cpp#L342
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
https://github.com/JuliaLang/julia/blob/21eadc5e3129a557df1eb385113132a97996af5e/src/jitlayers.h#L77-L78
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
GPUCompiler.jl/src/jlgen.jl
Lines 770 to 786 in e2d8505
#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.