From 84e449008c470052ef2b7f3200765f71d9c30513 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Sat, 7 Nov 2026 14:37:51 +0100 Subject: [PATCH] GPU Metal: relink the backend library when the kernels change The Metal IR is packed into the library with -sectcreate at link time, but the link step did not depend on the IR file. A change to the kernel code alone rebuilt the IR without relinking the library, which kept running the old kernels. --- GPU/GPUTracking/Base/metal/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/GPU/GPUTracking/Base/metal/CMakeLists.txt b/GPU/GPUTracking/Base/metal/CMakeLists.txt index 0b8e10d5aa2f8..61ea53064557e 100644 --- a/GPU/GPUTracking/Base/metal/CMakeLists.txt +++ b/GPU/GPUTracking/Base/metal/CMakeLists.txt @@ -103,6 +103,9 @@ if(METAL_ENABLED) # BUILD Metal source code for runtime compilation target target_link_options(${targetName} PRIVATE "-Wl,-sectcreate,__DATA,__gpu_resource,${METAL_BIN}.ir") + # The linker reads the IR, so relink when it changes: otherwise a change to the + # kernels alone leaves the old code in the library. + set_property(TARGET ${targetName} APPEND PROPERTY LINK_DEPENDS ${METAL_BIN}.ir) add_dependencies(${targetName} metal_preprocessed_code) add_dependencies(${targetName} metal_intermediate_representation) endif()