From 305e6673a9b7fbb414677818534cf25c300db3b9 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Wed, 9 Sep 2026 15:27:53 +0200 Subject: [PATCH] Emit native test objects with the JIT target machine The native test helper only used JITTargetMachine for :patch and :table jobs; :bake objects went through the stock target machine (small code model, static relocations). Their 32-bit references to constant pools cannot reach the addresses ORC loads code at, so JITLink rejects the object ("out of range of Pointer32Signed fixup") or, on older LLVM without the range check, the worker segfaults. On Windows the stock machine also emits COFF where the ORC JIT is configured for ELF, yielding garbage results and a crash in LLVMOrcDisposeLLJIT. Only macOS, where Mach-O is inherently position independent, was unaffected. Every :obj request now goes through JITTargetMachine, whose JITDefault code model is large on x86-64 and whose Windows triple is *-elf. Assembly output is unchanged. --- test/helpers/native.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/helpers/native.jl b/test/helpers/native.jl index 7ca5ce9b5..c2aa382cd 100644 --- a/test/helpers/native.jl +++ b/test/helpers/native.jl @@ -56,7 +56,11 @@ end function GPUCompiler.mcgen(@nospecialize(job::NativeCompilerJob), mod::LLVM.Module, format=LLVM.API.LLVMAssemblyFile) - if job.config.params.relocations !== :bake + # objects only exist to be loaded into `load`'s ORC JIT, so always emit them with the + # JIT's target machine: the default one uses the small code model with static + # relocations, whose 32-bit absolute references to e.g. constant pools cannot reach + # the addresses the JIT loads code at (and, on Windows, it emits COFF where ORC wants ELF) + if job.config.params.relocations !== :bake || format == LLVM.API.LLVMObjectFile target = job.config.target @dispose tm=JITTargetMachine(GPUCompiler.llvm_triple(target), target.cpu, target.features) begin