Files
TheRock/compiler/amd-llvm/offload/plugins-nextgen/common/CMakeLists.txt
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

115 lines
4.2 KiB
CMake

# The error codes in this header are shared with liboffload, so need to be
# generated from the same source.
include(TableGen)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include)
set(LLVM_TARGET_DEFINITIONS ${CMAKE_CURRENT_SOURCE_DIR}/../../liboffload/API/OffloadAPI.td)
tablegen(OFFLOAD include/OffloadErrcodes.inc -gen-errcodes -I ${CMAKE_CURRENT_SOURCE_DIR}/../../liboffload/API)
tablegen(OFFLOAD include/OffloadInfo.inc -gen-info -I ${CMAKE_CURRENT_SOURCE_DIR}/../../liboffload/API)
add_public_tablegen_target(PluginErrcodes)
if(OFFLOAD_ENABLE_EMISSARY_APIS)
set(emissary_sources
src/Emissary.cpp
src/EmissaryPrint.cpp
)
# EmissaryFortrt requires flang_rt; only include when available.
if(TARGET flang_rt.runtime.static)
set(OFFLOAD_HAS_EMISSARY_FORTRT TRUE)
else()
get_clang_resource_dir(CLANG_RESOURCE_LIBDIR PREFIX ${LLVM_BINARY_DIR} SUBDIR "lib/${LLVM_DEFAULT_TARGET_TRIPLE}")
string(REPLACE "${LLVM_LIBDIR_SUFFIX}" "" CLANG_RESOURCE_LIBDIR_NORMALIZED "${CLANG_RESOURCE_LIBDIR}")
find_library(LIBFLANG_RT flang_rt.runtime PATHS "${CLANG_RESOURCE_LIBDIR_NORMALIZED}")
if(LIBFLANG_RT)
set(OFFLOAD_HAS_EMISSARY_FORTRT TRUE)
endif()
endif()
if(OFFLOAD_HAS_EMISSARY_FORTRT)
list(APPEND emissary_sources src/EmissaryFortrt.cpp)
endif()
endif()
# NOTE: Don't try to build `PluginInterface` using `add_llvm_library` because we
# don't want to export `PluginInterface` while `add_llvm_library` requires that.
add_library(PluginCommon OBJECT
src/PluginInterface.cpp
src/GlobalHandler.cpp
src/JIT.cpp
src/RecordReplay.cpp
src/RPC.cpp
src/OffloadError.cpp
src/Utils/ELF.cpp
src/GenericProfiler.cpp
${emissary_sources}
)
add_dependencies(PluginCommon intrinsics_gen PluginErrcodes OffloadAPI)
# Only enable JIT for those targets that LLVM can support.
set(supported_jit_targets AMDGPU NVPTX)
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()
# Include the RPC server from the `libc` project.
include(FindLibcCommonUtils)
target_link_libraries(PluginCommon PRIVATE llvm-libc-common-utilities)
if(OFFLOAD_ENABLE_EMISSARY_APIS AND OFFLOAD_HAS_EMISSARY_FORTRT)
if(TARGET flang_rt.runtime.static)
target_link_libraries(PluginCommon PRIVATE flang_rt.runtime.static
-L${CMAKE_BINARY_DIR}/../../lib -L${CMAKE_INSTALL_PREFIX}/lib)
else()
target_link_libraries(PluginCommon PRIVATE ${LIBFLANG_RT})
endif()
target_compile_definitions(PluginCommon PRIVATE OFFLOAD_HAS_EMISSARY_FORTRT)
endif()
if (OMPT_TARGET_DEFAULT AND LIBOMPTARGET_OMPT_SUPPORT)
add_library(PluginOmpt STATIC OMPT/OmptTracing.cpp OMPT/OmptProfiler.cpp)
target_include_directories(PluginOmpt PUBLIC
OMPT
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/include
${LIBOMPTARGET_LLVM_INCLUDE_DIRS}
${LIBOMPTARGET_BINARY_INCLUDE_DIR}
${LIBOMPTARGET_INCLUDE_DIR}
)
target_compile_options(PluginOmpt PUBLIC ${offload_compile_flags} -fPIC )
target_link_options(PluginOmpt PUBLIC ${offload_link_flags})
target_compile_definitions(PluginOmpt PRIVATE
TARGET_NAME="Profiler"
DEBUG_PREFIX="OMPT"
)
add_dependencies(PluginOmpt PluginErrcodes)
endif()
# Define the TARGET_NAME and DEBUG_PREFIX.
target_compile_definitions(PluginCommon PRIVATE
TARGET_NAME=PluginInterface
DEBUG_PREFIX="PluginInterface"
)
target_compile_options(PluginCommon PUBLIC ${offload_compile_flags})
target_link_options(PluginCommon PUBLIC ${offload_link_flags})
if (LLVM_LINK_LLVM_DYLIB)
target_link_libraries(PluginCommon PRIVATE LLVM)
else()
target_link_libraries(PluginCommon PRIVATE LLVMProfileData)
endif()
target_include_directories(PluginCommon PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/../../liboffload/API
${LIBOMPTARGET_LLVM_INCLUDE_DIRS}
${LIBOMPTARGET_BINARY_INCLUDE_DIR}
${LIBOMPTARGET_INCLUDE_DIR}
)
set_target_properties(PluginCommon PROPERTIES POSITION_INDEPENDENT_CODE ON)