[Bf-blender-cvs] [18343c230d2] blender-v2.82-release: Fix/workaround initialization order of static TBB/MKL

Sergey Sharybin noreply at git.blender.org
Fri Jan 24 12:49:40 CET 2020


Commit: 18343c230d2c447f61fb60994b107f6a1adc01e7
Author: Sergey Sharybin
Date:   Fri Jan 24 12:47:35 2020 +0100
Branches: blender-v2.82-release
https://developer.blender.org/rB18343c230d2c447f61fb60994b107f6a1adc01e7

Fix/workaround initialization order of static TBB/MKL

Was caused by recent refactor of dependencies in 517870a4a11f.

While there is no fully reliable solution to this issue other than
making TBB a dynamic library dependency (as documentation tells us
to do), there seems to be simple workaround which doesn't require
deeper changed in build process and packaging.

Tested on Brecht's computer who managed to reproduce the issue on
Linux (T72015#857423).

===================================================================

M	source/blender/usd/CMakeLists.txt
M	source/creator/CMakeLists.txt

===================================================================

diff --git a/source/blender/usd/CMakeLists.txt b/source/blender/usd/CMakeLists.txt
index 1d72593f829..f4cf53e573f 100644
--- a/source/blender/usd/CMakeLists.txt
+++ b/source/blender/usd/CMakeLists.txt
@@ -78,29 +78,11 @@ set(LIB
   bf_blenlib
 )
 
-# Source: https://github.com/PixarAnimationStudios/USD/blob/master/BUILDING.md#linking-whole-archives
-if(WIN32)
-  list(APPEND LIB
-    ${USD_LIBRARIES}
-  )
-elseif(CMAKE_COMPILER_IS_GNUCXX)
-  list(APPEND LIB
-    -Wl,--whole-archive ${USD_LIBRARIES} -Wl,--no-whole-archive
-  )
-elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
-  list(APPEND LIB
-    -Wl,-force_load ${USD_LIBRARIES}
-  )
-else()
-  message(FATAL_ERROR "Unknown how to link USD with your compiler ${CMAKE_CXX_COMPILER_ID}")
-endif()
-
 list(APPEND LIB
   ${BOOST_LIBRARIES}
 )
 
 list(APPEND LIB
-  ${TBB_LIBRARIES}
 )
 
 blender_add_lib(bf_usd "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
@@ -111,3 +93,16 @@ if(WIN32)
   set_property(TARGET bf_usd APPEND_STRING PROPERTY LINK_FLAGS_RELWITHDEBINFO " /WHOLEARCHIVE:${USD_RELEASE_LIB}")
   set_property(TARGET bf_usd APPEND_STRING PROPERTY LINK_FLAGS_MINSIZEREL " /WHOLEARCHIVE:${USD_RELEASE_LIB}")
 endif()
+
+# Source: https://github.com/PixarAnimationStudios/USD/blob/master/BUILDING.md#linking-whole-archives
+if(WIN32)
+  target_link_libraries(bf_usd ${USD_LIBRARIES})
+elseif(CMAKE_COMPILER_IS_GNUCXX)
+  target_link_libraries(bf_usd "-Wl,--whole-archive ${USD_LIBRARIES} -Wl,--no-whole-archive ${TBB_LIBRARIES}")
+elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
+  target_link_libraries(bf_usd  -Wl,-force_load ${USD_LIBRARIES})
+else()
+  message(FATAL_ERROR "Unknown how to link USD with your compiler ${CMAKE_CXX_COMPILER_ID}")
+endif()
+
+target_link_libraries(bf_usd ${TBB_LIBRARIES})
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index d2af282f9a4..82c45b4fe64 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -38,6 +38,14 @@ blender_include_dirs(
 )
 
 set(LIB
+  # This forces TBB libraries to be in front of MKL (which is a part of OpenImageDenoise).
+  #
+  # The need of this comes to need to ensure static libraries initialization order, making it
+  # so TBB is initialized prior to MKL (or any other dpeendnecy).
+  #
+  # This isn't fully robust but seems to work.
+  ${TBB_LIBRARIES}
+
   bf_windowmanager
 )



More information about the Bf-blender-cvs mailing list