Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ASAN build #5492

Merged
merged 2 commits into from
May 31, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions plugins/video/pkg_src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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}")

Copy link
Collaborator

@szkarpinski szkarpinski May 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we just set(NEW_LD_PRELOAD "$ENV{LD_PRELOAD}:${cuda_LIBRARY}") to have the colon already there? Also, this will break if somebody has a space in their LD_PRELOAD or cuda path/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the thing is that the LD_PRELOAD has a space, and my command below doesn't like it. So I am using an alternative way to separate paths.

# 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
)
Expand Down
Loading