Skip to content

Commit 302db1a

Browse files
authored
[Offload] Do not link every target for JIT (#92013)
Summary: The offload library supports basic JIT functionality, however we currently link against every single target even though only AMDGPU and NVPTX are supported. This somewhat bloats the dynamic library list, so we should constrain it to what's actually used.
1 parent 179efe5 commit 302db1a

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

offload/plugins-nextgen/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ add_subdirectory(common)
1616
function(add_target_library target_name lib_name)
1717
add_llvm_library(${target_name} STATIC
1818
LINK_COMPONENTS
19-
${LLVM_TARGETS_TO_BUILD}
2019
AggressiveInstCombine
2120
Analysis
2221
BinaryFormat

offload/plugins-nextgen/common/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ add_library(PluginCommon OBJECT
2222
add_dependencies(PluginCommon intrinsics_gen)
2323

2424
# Only enable JIT for those targets that LLVM can support.
25-
string(TOUPPER "${LLVM_TARGETS_TO_BUILD}" TargetsSupported)
26-
foreach(Target ${TargetsSupported})
27-
target_compile_definitions(PluginCommon PRIVATE "LIBOMPTARGET_JIT_${Target}")
25+
set(supported_jit_targets AMDGPU NVPTX)
26+
foreach(target IN LISTS supported_jit_targets)
27+
if("${target}" IN_LIST LLVM_TARGETS_TO_BUILD)
28+
target_compile_definitions(PluginCommon PRIVATE "LIBOMPTARGET_JIT_${target}")
29+
llvm_map_components_to_libnames(llvm_libs ${target})
30+
target_link_libraries(PluginCommon PRIVATE ${llvm_libs})
31+
endif()
2832
endforeach()
2933

3034
# Include the RPC server from the `libc` project if availible.

0 commit comments

Comments
 (0)