From 64a0bfebfcd9451d3ba786eaf83972344b387a08 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Thu, 15 Oct 2026 14:09:49 +0200 Subject: [PATCH] Logger: find the NVTX3 headers next to nvcc too, so the aarch64 cross build compiles CUDA::nvtx3 is only an alias for CUDAToolkit_INCLUDE_DIRS. In the aarch64 SBSA cross build that is targets/sbsa-linux/include, and the cross-sbsa packages the image installs (cudart, crt, culibos, cufft) do not put nvtx3 there, so Logger.cpp failed with "nvtx3/nvToolsExt.h: No such file or directory". NVTX v3 is header-only and architecture-neutral, so the headers are now looked for in the toolkit include dirs and then in the include dir beside nvcc (the host tree, which ships them). One CMake decision sets JFJOCH_USE_NVTX on JFJochLogger; where no headers are found the ranges compile out, as they already do without CUDA. Co-Authored-By: Claude Opus 5.5 --- common/CMakeLists.txt | 15 ++++++++++++++- common/Logger.cpp | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index b484af16e..f8a8ff5c9 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -43,8 +43,21 @@ ADD_LIBRARY(JFJochLogger STATIC ) TARGET_LINK_LIBRARIES(JFJochLogger PUBLIC spdlog::spdlog JFJochVersion) +# NVTX v3 is header-only and architecture-neutral. CUDA::nvtx3 is no help here: it only points at +# CUDAToolkit_INCLUDE_DIRS, which in a cross build is the target tree (targets/sbsa-linux/include), +# and NVIDIA's cross-sbsa packages do not put nvtx3 there. So look in the target tree first and then +# in the toolkit's own include dir next to nvcc; where neither has it, the ranges compile out. IF (JFJOCH_CUDA_AVAILABLE) - TARGET_LINK_LIBRARIES(JFJochLogger PRIVATE CUDA::nvtx3) # header-only NVTX v3 + FIND_PATH(JFJOCH_NVTX3_INCLUDE_DIR nvtx3/nvToolsExt.h + HINTS ${CUDAToolkit_INCLUDE_DIRS} "${CUDAToolkit_BIN_DIR}/../include" + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + IF (JFJOCH_NVTX3_INCLUDE_DIR) + TARGET_INCLUDE_DIRECTORIES(JFJochLogger SYSTEM PRIVATE "${JFJOCH_NVTX3_INCLUDE_DIR}") + TARGET_LINK_LIBRARIES(JFJochLogger PRIVATE ${CMAKE_DL_LIBS}) # NVTX loads its injection library with dlopen + TARGET_COMPILE_DEFINITIONS(JFJochLogger PRIVATE JFJOCH_USE_NVTX) + ELSE() + MESSAGE(STATUS "NVTX3 headers not found - NVTX ranges compiled out") + ENDIF() ENDIF() ADD_LIBRARY(JFJochZMQ STATIC ZMQWrappers.cpp ZMQWrappers.h) diff --git a/common/Logger.cpp b/common/Logger.cpp index f84d357db..82cd01e62 100644 --- a/common/Logger.cpp +++ b/common/Logger.cpp @@ -9,7 +9,7 @@ #include "Logger.h" #include "GitInfo.h" -#ifdef JFJOCH_USE_CUDA +#ifdef JFJOCH_USE_NVTX #include uint64_t NvtxRangeStart(const std::string &name) {