From c79e5bc9f5363a24fb2f55eaa5e1202c13ed5ea2 Mon Sep 17 00:00:00 2001 From: "Wludzik, Jozef" Date: Thu, 27 Feb 2025 18:52:54 +0100 Subject: [PATCH] Enable building on Fedora41 --- cmake/compiler_flags.cmake | 5 ++- cmake/packaging/generators/rpm.cmake | 45 +++++++++++++++++++ cmake/packaging/setup.cmake | 2 + compiler/compiler_source.cmake | 5 ++- ...ler-warning-as-error-in-npu_compiler.patch | 25 +++++++++++ 5 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 cmake/packaging/generators/rpm.cmake create mode 100644 compiler/npu_compiler_patches/0001-Disable-compiler-warning-as-error-in-npu_compiler.patch diff --git a/cmake/compiler_flags.cmake b/cmake/compiler_flags.cmake index 906f70b..ca10cae 100644 --- a/cmake/compiler_flags.cmake +++ b/cmake/compiler_flags.cmake @@ -28,7 +28,10 @@ add_compile_options( if(NOT ${LINUX_SYSTEM_NAME} STREQUAL "cros_sdk") add_compile_options( # Enable macro security features - -D_FORTIFY_SOURCE=2 + $<$:-D_FORTIFY_SOURCE=2> + # TODO: Adding O3 in release build help to overcome issue with FORTIFY_SOURCE + # issue needs further investigation + $<$:-O3> ) endif() diff --git a/cmake/packaging/generators/rpm.cmake b/cmake/packaging/generators/rpm.cmake new file mode 100644 index 0000000..11b439c --- /dev/null +++ b/cmake/packaging/generators/rpm.cmake @@ -0,0 +1,45 @@ +# +# Copyright (C) 2025 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +include(${CPACK_PROJECT_CONFIG_FILE}) + +set(CPACK_GENERATOR RPM) + +# Exclude firmware directories to generate intel-fw-npu package without conflicts against filesystem package +set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION + /lib /lib/firmware /lib/firmware/updates /lib/firmware/updates/intel /lib/firmware/updates/intel/vpu) + +# Create package per component +set(CPACK_RPM_COMPONENT_INSTALL ON) + +# Component conflicts +set(CPACK_RPM_LEVEL_ZERO_PACKAGE_CONFLICTS "level-zero, level-zero-devel") + +# Get system architecture +execute_process( + COMMAND uname -m + OUTPUT_VARIABLE OUT_RPM_ARCH + OUTPUT_STRIP_TRAILING_WHITESPACE + COMMAND_ERROR_IS_FATAL ANY) + +set(PACKAGE_POSTFIX_NAME ${CPACK_PACKAGE_VERSION}_${LINUX_SYSTEM_NAME}${LINUX_SYSTEM_VERSION_ID}_${OUT_RPM_ARCH}.rpm) +foreach(COMPONENT ${CPACK_COMPONENTS_ALL}) + string(TOUPPER ${COMPONENT} COMPONENT_UPPER) + set(CPACK_RPM_${COMPONENT_UPPER}_FILE_NAME ${CPACK_PACKAGE_NAME}-${COMPONENT}_${PACKAGE_POSTFIX_NAME}) + + if (${COMPONENT_UPPER}_POSTINST) + list(APPEND CPACK_RPM_${COMPONENT_UPPER}_PACKAGE_CONTROL_EXTRA ${${COMPONENT_UPPER}_POSTINST}) + endif() + if (${COMPONENT_UPPER}_PRERM) + list(APPEND CPACK_RPM_${COMPONENT_UPPER}_PACKAGE_CONTROL_EXTRA ${${COMPONENT_UPPER}_PRERM}) + endif() + if (${COMPONENT_UPPER}_POSTRM) + list(APPEND CPACK_RPM_${COMPONENT_UPPER}_PACKAGE_CONTROL_EXTRA ${${COMPONENT_UPPER}_POSTRM}) + endif() + if (${COMPONENT_UPPER}_DEPENDS) + set(CPACK_RPM_${COMPONENT_UPPER}_PACKAGE_REQUIRES ${${COMPONENT_UPPER}_DEPENDS}) + endif() +endforeach() diff --git a/cmake/packaging/setup.cmake b/cmake/packaging/setup.cmake index 41234c2..b236c01 100644 --- a/cmake/packaging/setup.cmake +++ b/cmake/packaging/setup.cmake @@ -42,6 +42,8 @@ if (EXISTS "/etc/debian_version") set(PACKAGE_TYPE "deb") elseif(EXISTS "/etc/portage") set(PACKAGE_TYPE "ebuild") +elseif(EXISTS "/etc/redhat-release") + set(PACKAGE_TYPE "rpm") else() message(WARNING "Unable to detect package type for this system") return() diff --git a/compiler/compiler_source.cmake b/compiler/compiler_source.cmake index 90f324c..ee4d5bf 100644 --- a/compiler/compiler_source.cmake +++ b/compiler/compiler_source.cmake @@ -89,7 +89,10 @@ ExternalProject_Add( git -C ${NPU_COMPILER_SOURCE_DIR} lfs install && git -C ${NPU_COMPILER_SOURCE_DIR} lfs pull && git -C ${NPU_COMPILER_SOURCE_DIR}/thirdparty/vpucostmodel lfs install && - git -C ${NPU_COMPILER_SOURCE_DIR}/thirdparty/vpucostmodel lfs pull + git -C ${NPU_COMPILER_SOURCE_DIR}/thirdparty/vpucostmodel lfs pull && + git -C ${NPU_COMPILER_SOURCE_DIR} reset --hard HEAD && + git -C ${NPU_COMPILER_SOURCE_DIR} apply + ${CMAKE_CURRENT_SOURCE_DIR}/npu_compiler_patches/0001-Disable-compiler-warning-as-error-in-npu_compiler.patch CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" diff --git a/compiler/npu_compiler_patches/0001-Disable-compiler-warning-as-error-in-npu_compiler.patch b/compiler/npu_compiler_patches/0001-Disable-compiler-warning-as-error-in-npu_compiler.patch new file mode 100644 index 0000000..1bb384a --- /dev/null +++ b/compiler/npu_compiler_patches/0001-Disable-compiler-warning-as-error-in-npu_compiler.patch @@ -0,0 +1,25 @@ +From 53f896f0f564b99eea591bc4cf6a8304c2f526f6 Mon Sep 17 00:00:00 2001 +From: "Wludzik, Jozef" +Date: Thu, 27 Feb 2025 17:19:06 +0100 +Subject: [PATCH] Disable compiler warning as error in npu_compiler + +--- + cmake/compile_options.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/cmake/compile_options.cmake b/cmake/compile_options.cmake +index d9baa2c1..0963cbd0 100644 +--- a/cmake/compile_options.cmake ++++ b/cmake/compile_options.cmake +@@ -91,7 +91,7 @@ function(enable_warnings_as_errors TARGET_NAME) + else() + target_compile_options(${TARGET_NAME} + PRIVATE +- -Wall -Wextra -Werror -Werror=suggest-override ++ -Wall -Wextra + ) + endif() + endfunction() +-- +2.34.1 +