WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit e1829a6

Browse files
committed
build: stop linking to debug TBB version on Linux
1 parent 703351d commit e1829a6

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

cmake/TBB.cmake

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,17 @@ include("cmake/Threading.cmake")
2525

2626
macro(handle_tbb_target)
2727
if(TBB_FOUND)
28-
set_property(TARGET TBB::tbb PROPERTY "MAP_IMPORTED_CONFIG_RELWITHMDD" "DEBUG")
28+
if(WIN32)
29+
# On Windows we must link to debug version of TBB library to ensure ABI compatibility
30+
# with MSVC debug runtime.
31+
set_property(TARGET TBB::tbb PROPERTY "MAP_IMPORTED_CONFIG_RELWITHMDD" "DEBUG")
32+
else()
33+
# On Linux TBB::tbb target may link to libtbb_debug.so which is not compatible with libtbb.so. Linking
34+
# application to both may result in undefined behavior.
35+
# See https://uxlfoundation.github.io/oneTBB/main/intro/limitations.html#debug-tbb-in-the-sycl-program
36+
set_property(TARGET TBB::tbb PROPERTY "MAP_IMPORTED_CONFIG_RELWITHMDD" "RELEASE")
37+
set_property(TARGET TBB::tbb PROPERTY "MAP_IMPORTED_CONFIG_DEBUG" "RELEASE")
38+
endif()
2939
include_directories_with_host_compiler(${_tbb_include_dirs})
3040
list(APPEND EXTRA_SHARED_LIBS TBB::tbb)
3141

cmake/config.cmake.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ if(DNNL_CPU_THREADING_RUNTIME STREQUAL "TBB")
3939
# Reverting the CMAKE_MODULE_PATH to its original state
4040
set(CMAKE_MODULE_PATH ${DNNL_ORIGINAL_CMAKE_MODULE_PATH})
4141
endif()
42+
if(WIN32)
43+
# On Windows we must link to debug version of TBB library to ensure ABI compatibility
44+
# with MSVC debug runtime.
45+
set_property(TARGET TBB::tbb PROPERTY "MAP_IMPORTED_CONFIG_RELWITHMDD" "DEBUG")
46+
else()
47+
# On Linux TBB::tbb target may link to libtbb_debug.so which is not compatible with libtbb.so. Linking
48+
# application to both may result in undefined behavior.
49+
# See https://uxlfoundation.github.io/oneTBB/main/intro/limitations.html#debug-tbb-in-the-sycl-program
50+
set_property(TARGET TBB::tbb PROPERTY "MAP_IMPORTED_CONFIG_RELWITHMDD" "RELEASE")
51+
set_property(TARGET TBB::tbb PROPERTY "MAP_IMPORTED_CONFIG_DEBUG" "RELEASE")
52+
endif()
4253
endif()
4354

4455
# Use a custom find module for transitive dependencies

0 commit comments

Comments
 (0)