From ca5583f9d4d92933f56ea964cdc0cbbd53746c61 Mon Sep 17 00:00:00 2001 From: Joaquin Anton Date: Thu, 30 May 2024 10:56:25 +0200 Subject: [PATCH 1/2] Fix ASAN build Signed-off-by: Joaquin Anton --- plugins/video/pkg_src/CMakeLists.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/video/pkg_src/CMakeLists.txt b/plugins/video/pkg_src/CMakeLists.txt index 8f8158193f..ddbfda3afc 100644 --- a/plugins/video/pkg_src/CMakeLists.txt +++ b/plugins/video/pkg_src/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -70,12 +70,19 @@ find_library(cuda_LIBRARY cuda PATHS ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES} PATH_SUFFIXES lib/stubs lib64/stubs) +if(NOT $ENV{LD_PRELOAD} STREQUAL "") + set(NEW_LD_PRELOAD "$ENV{LD_PRELOAD} ${cuda_LIBRARY}") +else() + set(NEW_LD_PRELOAD "${cuda_LIBRARY}") +endif() +string(REPLACE " " ":" NEW_LD_PRELOAD "${NEW_LD_PRELOAD}") + # Generates .pyi stubs # Note: Needs to preload libcuda.so stub so that the shared-object library can be loaded add_custom_target(dali_${PLUGIN_NAME}_generate_stubs ALL DEPENDS dali_${PLUGIN_NAME} BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/fn/plugin/video/ - COMMAND LD_PRELOAD=${cuda_LIBRARY} ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/generate_plugin_stubs.py + COMMAND LD_PRELOAD=${NEW_LD_PRELOAD} ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/generate_plugin_stubs.py ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_BINARY_DIR}/libdali_${PLUGIN_NAME}.so ) From 6c183e35f362ea9edc487f9fa3d307fc4130bd7e Mon Sep 17 00:00:00 2001 From: Joaquin Anton Date: Fri, 31 May 2024 09:47:55 +0200 Subject: [PATCH 2/2] Better solution Signed-off-by: Joaquin Anton --- plugins/video/pkg_src/CMakeLists.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/video/pkg_src/CMakeLists.txt b/plugins/video/pkg_src/CMakeLists.txt index ddbfda3afc..f56c6ab2bb 100644 --- a/plugins/video/pkg_src/CMakeLists.txt +++ b/plugins/video/pkg_src/CMakeLists.txt @@ -75,17 +75,17 @@ if(NOT $ENV{LD_PRELOAD} STREQUAL "") else() set(NEW_LD_PRELOAD "${cuda_LIBRARY}") endif() -string(REPLACE " " ":" NEW_LD_PRELOAD "${NEW_LD_PRELOAD}") # Generates .pyi stubs # Note: Needs to preload libcuda.so stub so that the shared-object library can be loaded add_custom_target(dali_${PLUGIN_NAME}_generate_stubs ALL - DEPENDS dali_${PLUGIN_NAME} - BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/fn/plugin/video/ - COMMAND LD_PRELOAD=${NEW_LD_PRELOAD} ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/generate_plugin_stubs.py - ${CMAKE_CURRENT_BINARY_DIR} - ${PROJECT_BINARY_DIR}/libdali_${PLUGIN_NAME}.so - ) +DEPENDS dali_${PLUGIN_NAME} +BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/fn/plugin/video/ +COMMAND /bin/bash -c + "LD_PRELOAD=\"${NEW_LD_PRELOAD}\" \ + ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/generate_plugin_stubs.py \ + ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_BINARY_DIR}/libdali_${PLUGIN_NAME}.so" +) install(TARGETS dali_${PLUGIN_NAME} RUNTIME DESTINATION nvidia/dali/plugin/${PLUGIN_NAME}