From 9d5164d472ac83a4e4c8393fae9966594b28c78b Mon Sep 17 00:00:00 2001 From: Xavier Hallade Date: Tue, 12 Dec 2023 18:24:27 +0100 Subject: [PATCH] Build: Linux: patch ocloc to store binaries per-generation When storing multiple binaries in a fatbinary, ocloc stores Intel Graphics binaries for specific devices and these don't get found when the device doesn't match fully. Blender compiles one binary per generation rather than per device, to gain space and compile time. We introduce a patch at ocloc level to work around this behavior that otherwise leads to binaries not being found and recompilation being attempted. Pull Request: https://projects.blender.org/blender/blender/pulls/115750 --- build_files/build_environment/cmake/ocloc.cmake | 1 + build_files/build_environment/patches/ocloc.diff | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 build_files/build_environment/patches/ocloc.diff diff --git a/build_files/build_environment/cmake/ocloc.cmake b/build_files/build_environment/cmake/ocloc.cmake index c9ed61b91d7..2d55c133e80 100644 --- a/build_files/build_environment/cmake/ocloc.cmake +++ b/build_files/build_environment/cmake/ocloc.cmake @@ -17,6 +17,7 @@ ExternalProject_Add(external_ocloc PREFIX ${BUILD_DIR}/ocloc CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/ocloc ${DEFAULT_CMAKE_FLAGS} ${OCLOC_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/ocloc + PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/ocloc/src/external_ocloc/ < ${PATCH_DIR}/ocloc.diff ) add_dependencies( diff --git a/build_files/build_environment/patches/ocloc.diff b/build_files/build_environment/patches/ocloc.diff new file mode 100644 index 00000000000..11fb8a6b26f --- /dev/null +++ b/build_files/build_environment/patches/ocloc.diff @@ -0,0 +1,14 @@ +diff --git a/shared/offline_compiler/source/ocloc_fatbinary.cpp b/shared/offline_compiler/source/ocloc_fatbinary.cpp +index 98a1c0e..4d9b5b0 100644 +--- a/shared/offline_compiler/source/ocloc_fatbinary.cpp ++++ b/shared/offline_compiler/source/ocloc_fatbinary.cpp +@@ -286,7 +286,9 @@ int buildFatBinaryForTarget(int retVal, const std::vector &argsCopy + productConfig = ProductConfigHelper::parseMajorMinorRevisionValue(argHelper->productConfigHelper->getProductConfigFromDeviceName(product)); + } + +- fatbinary.appendFileEntry(pointerSize + "." + productConfig, pCompiler->getPackedDeviceBinaryOutput()); ++ // Storing binaries under the hardware prefix instead of the full architecture version number, ++ // as they would otherwise be ignored if they do not fully match that of the execution device. ++ fatbinary.appendFileEntry(pointerSize + "." + NEO::hardwarePrefix[argHelper->productConfigHelper->getProductFamilyFromDeviceName(productConfig)], pCompiler->getPackedDeviceBinaryOutput()); + return retVal; + }