Summary
The Kaleidoscope tutorial JIT (samples/KaleidoscopeTutorial/Kaleidoscope.Common/KaleidoscopeJit.cs) intermittently aborts on Windows x64 with:
LLVM ERROR: IMAGE_REL_AMD64_ADDR32NB relocation requires an ordered section layout
Root cause: an ORC LLJIT created with a null builder defaults to RtDyldObjectLinkingLayer (RuntimeDyld) on x86_64/COFF, and RuntimeDyldCOFFX86_64 fatally aborts when the image-base-relative IMAGE_REL_AMD64_ADDR32NB relocations in a function's .pdata/.xdata unwind info cannot encode. Whether they encode depends on where the default SectionMemoryManager's separately-mmap'd sections land, which is ASLR-dependent — hence intermittent.
The correct fix is to run the object-linking layer on JITLink, whose COFF/x86-64 backend does not impose the ordered-section-layout constraint.
The gap
The LLVM-C API (libLLVM 21.1.8) exposes only RTDyld object-linking-layer creators:
LLVMOrcCreateRTDyldObjectLinkingLayerWithSectionMemoryManager
LLVMOrcCreateRTDyldObjectLinkingLayerWithMCJITMemoryManagerLikeCallbacks
There is no C function that constructs a JITLink ObjectLinkingLayer (it is a C++-only class), so LLVMOrcLLJITBuilderSetObjectLinkingLayerCreator has no JITLink layer to return. The generated bindings already consume the full llvm-c/Orc.h, OrcEE.h, LLJIT.h, LLJITUtils.h set, so this is genuinely absent from the C surface rather than a generator omission.
Request
Expose a JITLink object-linking-layer creator through the libLLVMSharp native helper (which exists precisely to fill such C-API gaps) and surface it through the interop — e.g. a helper returning an LLVMOrcObjectLayerRef backed by llvm::orc::ObjectLinkingLayer + a JITLink in-process memory manager, usable from LLVMOrcLLJITBuilderSetObjectLinkingLayerCreator.
Workaround in place
Until then, the Kaleidoscope sample keeps RtDyld but installs a custom MCJIT-like memory manager that allocates every object's sections from a single contiguous slab, so getImageBase() equals the slab base and the ADDR32NB range check always holds. Once a JITLink creator is available, the sample should drop that workaround and force JITLink instead.
Summary
The Kaleidoscope tutorial JIT (
samples/KaleidoscopeTutorial/Kaleidoscope.Common/KaleidoscopeJit.cs) intermittently aborts on Windows x64 with:Root cause: an ORC LLJIT created with a null builder defaults to
RtDyldObjectLinkingLayer(RuntimeDyld) on x86_64/COFF, andRuntimeDyldCOFFX86_64fatally aborts when the image-base-relativeIMAGE_REL_AMD64_ADDR32NBrelocations in a function's.pdata/.xdataunwind info cannot encode. Whether they encode depends on where the defaultSectionMemoryManager's separately-mmap'd sections land, which is ASLR-dependent — hence intermittent.The correct fix is to run the object-linking layer on JITLink, whose COFF/x86-64 backend does not impose the ordered-section-layout constraint.
The gap
The LLVM-C API (libLLVM 21.1.8) exposes only RTDyld object-linking-layer creators:
LLVMOrcCreateRTDyldObjectLinkingLayerWithSectionMemoryManagerLLVMOrcCreateRTDyldObjectLinkingLayerWithMCJITMemoryManagerLikeCallbacksThere is no C function that constructs a JITLink
ObjectLinkingLayer(it is a C++-only class), soLLVMOrcLLJITBuilderSetObjectLinkingLayerCreatorhas no JITLink layer to return. The generated bindings already consume the fullllvm-c/Orc.h,OrcEE.h,LLJIT.h,LLJITUtils.hset, so this is genuinely absent from the C surface rather than a generator omission.Request
Expose a JITLink object-linking-layer creator through the
libLLVMSharpnative helper (which exists precisely to fill such C-API gaps) and surface it through the interop — e.g. a helper returning anLLVMOrcObjectLayerRefbacked byllvm::orc::ObjectLinkingLayer+ a JITLink in-process memory manager, usable fromLLVMOrcLLJITBuilderSetObjectLinkingLayerCreator.Workaround in place
Until then, the Kaleidoscope sample keeps RtDyld but installs a custom MCJIT-like memory manager that allocates every object's sections from a single contiguous slab, so
getImageBase()equals the slab base and theADDR32NBrange check always holds. Once a JITLink creator is available, the sample should drop that workaround and force JITLink instead.