TBB libs are not installed during Debug build

Hi,

Currently Slicer 3D uses TBB 2019 u9 (the link to the Slicer TBB external pkg).

If you tak a looke at TBB assets for Window/Linux/Mac then you will notice that it uses different naming convention for release and debug libraries. Release libs are called libtbb.so and Debug libtbb_debug.so.

In the same time SlicerBlockInstallTBB.cmake handles only Release mode. So if the Slicer is compiled with TBB in Debug mode then installed Slicer should not work as it is unable to load debug TBB.

I’m not sure but I propose to add something like (UNIX example):

#----------UNIX CASE--------------#
install(
  FILES
    ${TBB_LIB_DIR}/libtbb.so.2
    ${TBB_LIB_DIR}/libtbbmalloc.so.2
    ${TBB_LIB_DIR}/libtbbmalloc_proxy.so.2
    CONFIGURATIONS Release
    DESTINATION ${TBB_INSTALL_LIB_DIR} COMPONENT Runtime)

install(
  FILES
    ${TBB_LIB_DIR}/libtbb_debug.so.2
    ${TBB_LIB_DIR}/libtbbmalloc_debug.so.2
    ${TBB_LIB_DIR}/libtbbmalloc_proxy_debug.so.2
    CONFIGURATIONS Debug
    DESTINATION ${TBB_INSTALL_LIB_DIR} COMPONENT Runtime)

if (CMAKE_BUILD_TYPE EQUAL "Release")
  slicerStripInstalledLibrary(
    FILES
      "${TBB_INSTALL_LIB_DIR}/libtbb.so.2"
      "${TBB_INSTALL_LIB_DIR}/libtbbmalloc.so.2"
      "${TBB_INSTALL_LIB_DIR}/libtbbmalloc_proxy.so.2"
    COMPONENT Runtime)
else ()
  slicerStripInstalledLibrary(
    FILES
      "${TBB_INSTALL_LIB_DIR}/libtbb_debug.so.2"
      "${TBB_INSTALL_LIB_DIR}/libtbbmalloc_debug.so.2"
      "${TBB_INSTALL_LIB_DIR}/libtbbmalloc_proxy_debug.so.2"
    COMPONENT Runtime)
endif()

If this is ok I could implement it in PR

That sounds reasonable to me. Thanks for digging into this :+1:

1 Like

Submitted a PR

I only tried to handle Debug and Release modes but cmake also supports RelWithDebInfo and MinSizeRel.
I don’t Know whether Slicer uses these build types but I don’t have experience of working with RelWithDebInfo and MinSizeRel thus I don’t know what libraries they need (debug or release).

Anyway I could to try fix this PR to handle RelWithDebInfo and MinSizeRel if needed.

Can you describe how it doesn’t work? I’m sure others have built Slicer in debug mode, but there haven’t been any reports of things not working.

1 Like

You are right but I’m talking about installation (and packaging) like executing commands (assuming Slicer is built):

cd Slicer-build
cpack -B ../..

If you have built Slicer in Debug mode then Slicer is linked against libtbb_debug.so. That means if you want to install Slicer then you need to install libtbb_debug.so but Slicer installs libtbb.so instead. Thus when you try to run installed Slicer you should see something like libtbb_debug.so not found (but you have libtbb.so in the installation folder) and the app must fails to start. This happened to me on Ubuntu 20.04.

The idea behind cmake install used by me in PR is taken from cmake the example

Generally speaking you aren’t meant to be making packages of debug or other non-release builds - I believe some tools won’t allow it or it’s against the license to redistribute the debug libs. But I guess there might be times when you’d want to.

1 Like

Yes, and in my case I usually work with SlicerCAT and Debug mode. I needed to check whether I’m able able to correctly package the app or not (are there any bugs in my installation scripts).

To follow up on this, TBB version has been updated from 2019_U9 to 2021.5.0.
See https://github.com/Slicer/Slicer/pull/6405

The install rules have also been tested to make sure tbb release libraries are packaged.

That said, Debug libraries are still excluded. To support this, we would need to set the list of exceptions in SlicerFunctionInstallLibrary.cmake based on the build type by checking the value of CMAKE_BUILD_TYPE (only the case of single configuration generator).

1 Like