From 03d2e25fcd3f5b537d1e092ca4d4cca0a1af0d26 Mon Sep 17 00:00:00 2001 From: Soren Soe <2106410+stsoe@users.noreply.github.com> Date: Thu, 30 Jan 2025 11:16:57 -0800 Subject: [PATCH] Split npu package into base and npu deployment and development (#8723) * Split npu package into base and npu deployment and development The XRT npu component is split into base and npu with latter containing only profiling (xdp) compiled specifically for NPU. The packages are split in deployment and development. - xrt_202510.2.19.0_22.04-amd64-base.deb generated. - xrt_202510.2.19.0_22.04-amd64-base-dev.deb generated. - xrt_202510.2.19.0_22.04-amd64-npu.deb generated. - xrt_202510.2.19.0_22.04-amd64-npu-dev.deb generated. The changes in this PR are mostly in handling package dependencies with CPack. This commit is specifically for Debian packaging. Signed-off-by: Soren Soe <2106410+stsoe@users.noreply.github.com> * Enable RPM build for split npu packages The packages are split in deployment and development. - xrt_202510.2.19.0_41-x86_64-base.rpm generated. - xrt_202510.2.19.0_41-x86_64-base-devel.rpm generated. - xrt_202510.2.19.0_41-x86_64-npu.rpm generated. - xrt_202510.2.19.0_41-x86_64-npu-devel.rpm generated. The changes in this PR are mostly in handling package dependencies with CPack. This commit is specifically for RPM packaging. Signed-off-by: Soren Soe <2106410+stsoe@users.noreply.github.com> * Add missing line continuation in depends Signed-off-by: Soren Soe <2106410+stsoe@users.noreply.github.com> * Skip namelink for xdp_core The xdp_core is not an application library so shouldn't have a namelink. Additionally, make sure xrt.pc is released with base-dev component. These change makes npu-dev component empty and the package is not created. Signed-off-by: Soren Soe <2106410+stsoe@users.noreply.github.com> --------- Signed-off-by: Soren Soe <2106410+stsoe@users.noreply.github.com> --- src/CMake/components.cmake | 8 +- src/CMake/cpackLin.cmake | 147 ++++++++++++++++----- src/CMake/nativeLnx.cmake | 4 +- src/CMake/pkgconfig.cmake | 2 +- src/runtime_src/xdp/profile/CMakeLists.txt | 4 +- 5 files changed, 123 insertions(+), 42 deletions(-) diff --git a/src/CMake/components.cmake b/src/CMake/components.cmake index 21085caf424..5685be29760 100644 --- a/src/CMake/components.cmake +++ b/src/CMake/components.cmake @@ -7,7 +7,7 @@ if (NOT WIN32) if (${LINUX_FLAVOR} MATCHES "^(ubuntu|debian)") set (XRT_DEV_COMPONENT_SUFFIX "dev") - elseif (${LINUX_FLAVOR} MATCHES "^(rhel|centos)") + elseif (${LINUX_FLAVOR} MATCHES "^(rhel|centos|fedora)") set (XRT_DEV_COMPONENT_SUFFIX "devel") endif() else() @@ -88,9 +88,9 @@ if (XRT_NPU) # been explicitly marked alveo or npu set (CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "npu") set (XRT_COMPONENT "npu") - set (XRT_DEV_COMPONENT "npu") - set (XRT_BASE_COMPONENT ${XRT_COMPONENT}) - set (XRT_BASE_DEV_COMPONENT ${XRT_DEV_COMPONENT}) + set (XRT_DEV_COMPONENT "npu-${XRT_DEV_COMPONENT_SUFFIX}") + set (XRT_BASE_COMPONENT "base") + set (XRT_BASE_DEV_COMPONENT "base-${XRT_DEV_COMPONENT_SUFFIX}") endif(XRT_NPU) # Alveo builds one Alveo package for both deployment and development diff --git a/src/CMake/cpackLin.cmake b/src/CMake/cpackLin.cmake index 23a9b9b0fa0..e078cdbbc68 100644 --- a/src/CMake/cpackLin.cmake +++ b/src/CMake/cpackLin.cmake @@ -7,12 +7,12 @@ # XRT_VERSION_PATCH # LINUX_FLAVOR - SET(CPACK_SET_DESTDIR ON) SET(CPACK_PACKAGE_VERSION_RELEASE "${XRT_VERSION_RELEASE}") SET(CPACK_PACKAGE_VERSION_MAJOR "${XRT_VERSION_MAJOR}") SET(CPACK_PACKAGE_VERSION_MINOR "${XRT_VERSION_MINOR}") SET(CPACK_PACKAGE_VERSION_PATCH "${XRT_VERSION_PATCH}") +set(CPACK_PACKAGE_VERSION ${XRT_VERSION_MAJOR}.${XRT_VERSION_MINOR}.${XRT_VERSION_PATCH}) SET(CPACK_PACKAGE_NAME "xrt") SET(CPACK_ARCHIVE_COMPONENT_INSTALL ON) @@ -21,11 +21,27 @@ SET(CPACK_RPM_COMPONENT_INSTALL ON) # For some reason CMake doesn't populate CPACK_COMPONENTS_ALL when the # project has only one component, this leads to cpack generating -# pacage without component name appended. To work-around this, +# package without component name appended. To work-around this, # populate the variable explictly. get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS) message("Install components in the project: ${CPACK_COMPONENTS_ALL}") +# Set up component dependencies on base if built +if (${XRT_BASE_COMPONENT} STREQUAL "base") + set(CPACK_COMPONENT_ALVEO_DEPENDS base) + set(CPACK_COMPONENT_NPU_DEPENDS base) +endif() + +# Set up aws component dependencies. Can be +# xrt or alveo depending on the build +SET(CPACK_COMPONENT_AWS_DEPENDS ${XRT_COMPONENT}) + +# Set up development component dependencies +set(CPACK_COMPONENT_BASE-DEV_DEPENDS base) +set(CPACK_COMPONENT_ALVEO-DEV_DEPENDS alveo) +set(CPACK_COMPONENT_NPU-DEV_DEPENDS npu) +set(CPACK_COMPONENT_XRT-DEV_DEPENDS xrt) + # When the rpmbuild occurs for packaging, it uses a default version of # python to perform a python byte compilation. For the CentOS 7.x OS, this # is python2. Being that the XRT python code is for python3, this results in @@ -72,30 +88,52 @@ if (${LINUX_FLAVOR} MATCHES "^(ubuntu|debian)") SET(CPACK_DEBIAN_AWS_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_BINARY_DIR}/aws/postinst;${CMAKE_CURRENT_BINARY_DIR}/aws/prerm") SET(CPACK_DEBIAN_AZURE_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_BINARY_DIR}/azure/postinst;${CMAKE_CURRENT_BINARY_DIR}/azure/prerm") SET(CPACK_DEBIAN_CONTAINER_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_BINARY_DIR}/container/postinst;${CMAKE_CURRENT_BINARY_DIR}/container/prerm") - + #set (CPACK_DEBIAN_PACKAGE_DEBUG ON) SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS "yes") + set(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS ON) + + # Set the path to the private (cross package) shared libraries + # This makes CPackDeb.cmake invoke dpkg-shlibdeps with -l${dir} option + set (CPACK_DEBIAN_PACKAGE_SHLIBDEPS_PRIVATE_DIRS ${XRT_BUILD_INSTALL_DIR}/lib) if( (${CMAKE_VERSION} VERSION_LESS "3.6.0") AND (${CPACK_DEBIAN_PACKAGE_SHLIBDEPS} STREQUAL "yes") ) # Fix bug in CPackDeb.cmake in use of dpkg-shlibdeps SET(CMAKE_MODULE_PATH ${XRT_SOURCE_DIR}/CMake/patch ${CMAKE_MODULE_PATH}) endif() - SET(CPACK_DEBIAN_AWS_PACKAGE_DEPENDS "xrt (>= ${XRT_VERSION_MAJOR}.${XRT_VERSION_MINOR}.${XRT_VERSION_PATCH})") - SET(CPACK_DEBIAN_XRT_PACKAGE_DEPENDS "ocl-icd-libopencl1 (>= 2.2.0), dkms (>= 2.2.0), udev, python3") + # Dependencies not automatically detected by CPack + SET(CPACK_DEBIAN_BASE_PACKAGE_DEPENDS "ocl-icd-libopencl1 (>= 2.2.0), python3") + SET(CPACK_DEBIAN_BASE-DEV_PACKAGE_DEPENDS "ocl-icd-opencl-dev (>= 2.2.0), uuid-dev (>= 2.27.1)") + + # If base package combines deployment and development, then + # include development dependencies + if (${XRT_BASE_DEV_COMPONENT} STREQUAL "base") + set(CPACK_DEBIAN_BASE_PACKAGE_DEPENDS + "${CPACK_DEBIAN_BASE_PACKAGE_DEPENDS}, \ + ${CPACK_DEBIAN_BASE-DEV_PACKAGE_DEPENDS}") + endif() + + # If base is included in npu, then include base dependencies + if (${XRT_BASE_DEV_COMPONENT} STREQUAL "npu") + set(CPACK_DEBIAN_NPU_PACKAGE_DEPENDS + "${CPACK_DEBIAN_BASE_PACKAGE_DEPENDS}, \ + ${CPACK_DEBIAN_BASE-DEV_PACKAGE_DEPENDS}") + endif() + + # If base is included in alveo, then include base dependencies + if (${XRT_BASE_DEV_COMPONENT} STREQUAL "alveo") + set(CPACK_DEBIAN_ALVEO_PACKAGE_DEPENDS + "${CPACK_DEBIAN_BASE_PACKAGE_DEPENDS}, \ + ${CPACK_DEBIAN_BASE-DEV_PACKAGE_DEPENDS}") + endif() - if (${XRT_DEV_COMPONENT} STREQUAL "xrt") - # applications link with -luuid - SET(CPACK_DEBIAN_XRT_PACKAGE_DEPENDS - "${CPACK_DEBIAN_XRT_PACKAGE_DEPENDS}, \ - ocl-icd-opencl-dev (>= 2.2.0), \ - uuid-dev (>= 2.27.1)") - else() - # xrt development package - SET(CPACK_DEBIAN_XRT-DEV_PACKAGE_NAME ${XRT_DEV_COMPONENT}) - SET(CPACK_DEBIAN_XRT-DEV_PACKAGE_DEPENDS - "xrt (>= ${XRT_VERSION_MAJOR}.${XRT_VERSION_MINOR}.${XRT_VERSION_PATCH}), \ - ocl-icd-opencl-dev (>= 2.2.0), \ - uuid-dev (>= 2.27.1)") + # If base is included in xrt, then include base dependencies + # along with dmks and udev. This is true for XRT legacy + if (${XRT_BASE_DEV_COMPONENT} STREQUAL "xrt") + set(CPACK_DEBIAN_XRT_PACKAGE_DEPENDS + "${CPACK_DEBIAN_BASE_PACKAGE_DEPENDS}, \ + ${CPACK_DEBIAN_BASE-DEV_PACKAGE_DEPENDS}, \ + dkms (>= 2.2.0), udev") endif() if ((${LINUX_FLAVOR} MATCHES "^(ubuntu)") AND (${LINUX_VERSION} STREQUAL "23.10")) @@ -155,22 +193,63 @@ elseif (${LINUX_FLAVOR} MATCHES "^(rhel|centos|amzn|fedora|sles|mariner|almalinu SET(CPACK_RPM_CONTAINER_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/container/postinst") SET(CPACK_RPM_CONTAINER_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/container/prerm") SET(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/local" "/usr/src" "/opt" "/etc/OpenCL" "/etc/OpenCL/vendors" "/usr/lib" "/usr/lib/pkgconfig" "/usr/lib64/pkgconfig" "/lib" "/lib/firmware" "/usr/share/pkgconfig") - SET(CPACK_RPM_AWS_PACKAGE_REQUIRES "xrt >= ${XRT_VERSION_MAJOR}.${XRT_VERSION_MINOR}.${XRT_VERSION_PATCH}") - if (${LINUX_FLAVOR} MATCHES "^(sles)") - SET(CPACK_RPM_XRT_PACKAGE_REQUIRES "ocl-icd-devel >= 2.2, dkms >= 2.2.0, python3 >= 3.6") - elseif (${LINUX_FLAVOR} MATCHES "^(mariner)") - SET(CPACK_RPM_XRT_PACKAGE_REQUIRES "ocl-icd >= 2.2, dkms >= 2.5.0, python3 >= 3.6") - else() - SET(CPACK_RPM_XRT_PACKAGE_REQUIRES "ocl-icd >= 2.2, dkms >= 2.5.0, python3 >= 3.6") - endif() - - if (${XRT_DEV_COMPONENT} STREQUAL "xrt") - # xrt is also development package - SET(CPACK_RPM_XRT_PACKAGE_REQUIRES "${CPACK_RPM_XRT_PACKAGE_REQUIRES}, ocl-icd-devel >= 2.2, libuuid-devel >= 2.23.2") - else() - # xrt development package - SET(CPACK_RPM_XRT-DEV_PACKAGE_NAME ${XRT_DEV_COMPONENT}) - SET(CPACK_RPM_XRT-DEV_PACKAGE_REQUIRES "xrt >= ${XRT_VERSION_MAJOR}.${XRT_VERSION_MINOR}.${XRT_VERSION_PATCH}, ocl-icd-devel >= 2.2, libuuid-devel >= 2.23.2") + + set(CPACK_RPM_BASE_PACKAGE_REQUIRES "ocl-icd >= 2.2, python3 >= 3.6") + set(CPACK_RPM_BASE-DEVEL_PACKAGE_REQUIRES "ocl-icd-devel >= 2.2, libuuid-devel >= 2.23.2") + set(CPACK_RPM_NPU_PACKAGE_REQUIRES "xrt-base = ${CPACK_PACKAGE_VERSION}") + set(CPACK_RPM_NPU-DEVEL_PACKAGE_REQUIRES "xrt-npu = ${CPACK_PACKAGE_VERSION}") + set(CPACK_RPM_ALVEO_PACKAGE_REQUIRES "xrt-base = ${CPACK_PACKAGE_VERSION}") + set(CPACK_RPM_ALVEO-DEVEL_PACKAGE_REQUIRES "xrt-alveo= ${CPACK_PACKAGE_VERSION}") + set(CPACK_RPM_XRT-DEVEL_PACKAGE_REQUIRES "xrt = ${CPACK_PACKAGE_VERSION}") + + # If xrt-base-devel development component is built, then it depends + # on xrt-base deployment. For the cases where xrt-base-devel + # is folded into deployment, we don't want xrt-base dependency. + if (${XRT_BASE_DEV_COMPONENT} STREQUAL "base-devel") + set(CPACK_RPM_BASE-DEVEL_PACKAGE_REQUIRES + "${CPACK_RPM_BASE-DEVEL_PACKAGE_REQUIRES}, \ + xrt-base = ${CPACK_PACKAGE_VERSION}") + endif() + + # If base package combines deployment and development, then + # include development dependencies + if (${XRT_BASE_DEV_COMPONENT} STREQUAL "base") + set(CPACK_RPM_BASE_PACKAGE_REQUIRES + "${CPACK_RPM_BASE_PACKAGE_REQUIRES}, \ + ${CPACK_RPM_BASE-DEVEL_PACKAGE_REQUIRES}") + endif() + + # If base is included in npu, then include base dependencies + if (${XRT_BASE_DEV_COMPONENT} STREQUAL "npu") + set(CPACK_RPM_NPU_PACKAGE_REQUIRES + "${CPACK_RPM_BASE_PACKAGE_REQUIRES}, \ + ${CPACK_RPM_BASE-DEVEL_PACKAGE_REQUIRES}") + endif() + + # If base is included in alveo, then include base dependencies + if (${XRT_BASE_DEV_COMPONENT} STREQUAL "alveo") + set(CPACK_RPM_ALVEO_PACKAGE_REQUIRES + "${CPACK_RPM_BASE_PACKAGE_REQUIRES}, \ + ${CPACK_RPM_BASE-DEVEL_PACKAGE_REQUIRES}") + endif() + + # If base is included in xrt, then include base dependencies + # along with dmks and udev. This is true for XRT legacy + if (${XRT_BASE_DEV_COMPONENT} STREQUAL "xrt") + set(CPACK_RPM_XRT_PACKAGE_REQUIRES + "${CPACK_RPM_BASE_PACKAGE_REQUIRES}, \ + ${CPACK_RPM_BASE-DEVEL_PACKAGE_REQUIRES}, \ + dkms") + endif() + + # If base component is alveo, then aws has a dependency on alveo + if (${XRT_BASE_COMPONENT} STREQUAL "alveo") + set(CPACK_RPM_AWS_PACKAGE_REQUIRES "xrt-alveo = ${CPACK_PACKAGE_VERSION}") + endif() + + # If base component is xrt, then aws has a dependency on xrt + if (${XRT_BASE_COMPONENT} STREQUAL "xrt") + set(CPACK_RPM_AWS_PACKAGE_REQUIRES "xrt = ${CPACK_PACKAGE_VERSION}") endif() if (DEFINED CROSS_COMPILE) diff --git a/src/CMake/nativeLnx.cmake b/src/CMake/nativeLnx.cmake index 65afbad82dc..97e1c5785b9 100644 --- a/src/CMake/nativeLnx.cmake +++ b/src/CMake/nativeLnx.cmake @@ -172,7 +172,9 @@ endif (XRT_BASE) include (CMake/changelog.cmake) # --- Package Config --- -include (CMake/pkgconfig.cmake) +if (XRT_BASE) + include (CMake/pkgconfig.cmake) +endif (XRT_BASE) # --- Coverity Support --- include (CMake/coverity.cmake) diff --git a/src/CMake/pkgconfig.cmake b/src/CMake/pkgconfig.cmake index 364c7b7bd74..256052c0506 100644 --- a/src/CMake/pkgconfig.cmake +++ b/src/CMake/pkgconfig.cmake @@ -19,5 +19,5 @@ configure_file ( install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/xrt.pc DESTINATION ${XRT_PKG_CONFIG_DIR} - COMPONENT ${XRT_DEV_COMPONENT} + COMPONENT ${XRT_BASE_DEV_COMPONENT} ) diff --git a/src/runtime_src/xdp/profile/CMakeLists.txt b/src/runtime_src/xdp/profile/CMakeLists.txt index 951d1c37fae..e74f8715cb1 100644 --- a/src/runtime_src/xdp/profile/CMakeLists.txt +++ b/src/runtime_src/xdp/profile/CMakeLists.txt @@ -36,11 +36,11 @@ target_link_libraries(xdp_core PRIVATE xrt_coreutil) set_target_properties(xdp_core PROPERTIES VERSION ${XRT_VERSION_STRING} SOVERSION ${XRT_SOVERSION}) +# xdp_cre is not an end-user link library, so skip the name link install(TARGETS xdp_core EXPORT xrt-targets RUNTIME DESTINATION ${XRT_INSTALL_BIN_DIR} COMPONENT ${XRT_COMPONENT} - LIBRARY DESTINATION ${XRT_INSTALL_LIB_DIR} COMPONENT ${XRT_COMPONENT} NAMELINK_COMPONENT ${XRT_DEV_COMPONENT} - ARCHIVE DESTINATION ${XRT_INSTALL_LIB_DIR} COMPONENT ${XRT_DEV_COMPONENT}) + LIBRARY DESTINATION ${XRT_INSTALL_LIB_DIR} COMPONENT ${XRT_COMPONENT} NAMELINK_SKIP) # Build the individual plugins add_subdirectory(plugin)