[OpenMP][Offload] Target JIT registers no backends when LLVM_LINK_LLVM_DYLIB=ON
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Summary:
When LLVM is configured with `LLVM_LINK_LLVM_DYLIB=ON`, the host-side JIT in `libomptarget` compiles device LLVM-IR images without registering any target backend. Every `-fopenmp-target-jit` run fails with:
```
failure to jit IR image: Unable to find target for this triple (no targets are registered)
```
Environment:
- `-DLLVM_ENABLE_RUNTIMES="...;offload"`
- `-DLLVM_LINK_LLVM_DYLIB=ON`
Reproduction:
```bash
ninja check-offload #: with 11 Failed
```
The compile step succeeds; only the runtime JIT of the LTO bitcode image fails.
Root cause:
`offload/plugins-nextgen/common/CMakeLists.txt` only enables the JIT when LLVM is not linked as a dylib:
```cmake
set(supported_jit_targets AMDGPU NVPTX SPIRV)
if (NOT LLVM_LINK_LLVM_DYLIB)
foreach(target IN LISTS supported_jit_targets)
if("${target}" IN_LIST LLVM_TARGETS_TO_BUILD)
target_compile_definitions(PluginCommon PRIVATE "LIBOMPTARGET_JIT_${target}")
llvm_map_components_to_libnames(llvm_libs ${target})
target_link_libraries(PluginCommon PRIVATE ${llvm_libs})
endif()
endforeach()
endif()
```
With `LLVM_LINK_LLVM_DYLIB=ON`, `LIBOMPTARGET_JIT_` is never defined, so in `offload/plugins-nextgen/common/src/JIT.cpp` the #ifdef `LIBOMPTARGET_JIT_NVPTX` (etc.) blocks are compiled out. JITEngine's constructor therefore never calls `LLVMInitializeNVPTX{TargetInfo,Target,TargetMC,AsmPrinter}()`, and `TargetRegistry::lookupTarget()` finds no registered target.
Contributor guide
Research direction
Start with offload/plugins-nextgen/common/CMakeLists.txt and offload/plugins-nextgen/common/src/JIT.cpp, tracing how JIT target initialization is compiled when LLVM_LINK_LLVM_DYLIB=ON. Run ninja check-offload with that configuration and verify the OpenMP target JIT tests no longer report that no targets are registered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system, compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 64/100