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

TBB universal fix (2020/2021 fixes) #7332

Closed
wants to merge 3 commits into from

Conversation

theofficialgman
Copy link

@theofficialgman theofficialgman commented Nov 23, 2021

I have decided to close this PR: #7149 since I do not have control over it and some changes had to be made. Should fix issues seen here: #6355

I've tested this PR on bionic with TBB 2017. The changes should allow TBB 2020/TBB 2021 to build but I still need confirmation from @bnavigator on TBB 2021 as well as testing myself on hirsute with TBB 2020

loqs added 3 commits November 22, 2021 18:56
- Retrieved from [1], SHA:  172e85feaf7cd36533012d66fb12a8942888d61d on 2021-05-26
- [1]: https://gitlab.kitware.com/vtk/vtk/blob/master/CMake/FindTBB.cmake
- Protect against the case when the user has multiple installs of TBB
  in their search paths and the first install does not contain debug
  libraries.  In this case it is possible to get mismatched versions
  of TBB inserted into TBB_LIBRARIES.
- Also suppresses warning about use of TBB_ROOT on modern versions of
  CMake due to CMP0074.
Copied from ceres-solver/ceres-solver@4e69a47
@bnavigator
Copy link
Contributor

Hi,

I can't apply this PR patch to PrusaSlicer-2.3.3, so there must have been changes in FindTBB.cmake between the release and current master.

But as your patch entirely replaces FindTBB.cmake, I did just the same with 2.3.3. The cmake runs fine but it fails at some include:

[    3s] + cd build
[    3s] + /usr/bin/cmake /home/abuild/rpmbuild/BUILD/PrusaSlicer-version_2.3.3/. '-GUnix Makefiles' -DCMAKE_INSTALL_PREFIX:PATH=/usr -DINCLUDE_INSTALL_DIR:PATH=/usr/include -DLIB_INSTALL_DIR:PATH=/usr/lib64 -DSYSCONF_INSTALL_DIR:PATH=/etc -DSHARE_INSTALL_PREFIX:PATH=/usr/share -DCMAKE_INSTALL_LIBDIR:PATH=lib64 -DCMAKE_INSTALL_LIBEXECDIR=/usr/libexec -DCMAKE_BUILD_TYPE=RelWithDebInfo '-DCMAKE_C_FLAGS=-O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -DNDEBUG' '-DCMAKE_CXX_FLAGS=-O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -DNDEBUG' '-DCMAKE_Fortran_FLAGS=-O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -DNDEBUG' '-DCMAKE_EXE_LINKER_FLAGS=-flto=auto -Wl,--as-needed -Wl,--no-undefined -Wl,-z,now' '-DCMAKE_MODULE_LINKER_FLAGS=-flto=auto -Wl,--as-needed' '-DCMAKE_SHARED_LINKER_FLAGS=-flto=auto -Wl,--as-needed -Wl,--no-undefined -Wl,-z,now' -DLIB_SUFFIX=64 -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DBUILD_SHARED_LIBS:BOOL=ON -DBUILD_STATIC_LIBS:BOOL=OFF -DCMAKE_COLOR_MAKEFILE:BOOL=OFF -DCMAKE_INSTALL_DO_STRIP:BOOL=OFF -DCMAKE_MODULES_INSTALL_DIR=/usr/lib64/cmake/PrusaSlicer -DSLIC3R_FHS=1 -DSLIC3R_GTK=3 -DOPENVDB_FIND_MODULE_PATH=/usr/lib64/cmake/OpenVDB
[    3s] -- The C compiler identification is GNU 11.2.1
[    3s] -- The CXX compiler identification is GNU 11.2.1
[    3s] -- Detecting C compiler ABI info
[    3s] -- Detecting C compiler ABI info - done
[    3s] -- Check for working C compiler: /usr/bin/cc - skipped
[    3s] -- Detecting C compile features
[    3s] -- Detecting C compile features - done
[    3s] -- Detecting CXX compiler ABI info
[    3s] -- Detecting CXX compiler ABI info - done
[    3s] -- Check for working CXX compiler: /usr/bin/c++ - skipped
[    3s] -- Detecting CXX compile features
[    3s] -- Detecting CXX compile features - done
[    3s] -- SLIC3R_ASAN: OFF
[    3s] -- SLIC3R_BUILD_SANDBOXES: OFF
[    3s] -- SLIC3R_BUILD_TESTS: ON
[    3s] -- SLIC3R_FHS: 1
[    3s] -- SLIC3R_GTK: 3
[    3s] -- SLIC3R_GUI: ON
[    3s] -- SLIC3R_MSVC_COMPILE_PARALLEL: ON
[    3s] -- SLIC3R_MSVC_PDB: ON
[    3s] -- SLIC3R_PCH: ON
[    3s] -- SLIC3R_PERL_XS: OFF
[    3s] -- SLIC3R_PROFILE: OFF
[    3s] -- SLIC3R_STATIC: OFF
[    3s] -- SLIC3R_WX_STABLE: OFF
[    3s] -- SLIC3R_STATIC: OFF
[    3s] -- CMAKE_PREFIX_PATH: (default)
[    3s] -- Found PkgConfig: /usr/bin/pkg-config (found version "1.8.0") 
[    3s] -- Looking for pthread.h
[    3s] -- Looking for pthread.h - found
[    3s] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
[    3s] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
[    3s] -- Found Threads: TRUE  
[    3s] CMake Warning (dev) at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
[    3s]   The package name passed to `find_package_handle_standard_args` (DBUS) does
[    3s]   not match the name of the calling package (DBus).  This can lead to
[    3s]   problems in calling code that expects `find_package` result variables
[    3s]   (e.g., `_FOUND`) to follow a certain pattern.
[    3s] Call Stack (most recent call first):
[    3s]   cmake/modules/FindDBus.cmake:59 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
[    3s]   CMakeLists.txt:183 (find_package)
[    3s] This warning is for project developers.  Use -Wno-dev to suppress it.
[    3s] 
[    3s] -- Found DBUS: /usr/include/dbus-1.0;/usr/lib64/dbus-1.0/include  
[    3s] -- Found Boost: /usr/lib64/cmake/Boost-1.77.0/BoostConfig.cmake (found suitable version "1.77.0", minimum required is "1.64.0") found components: system filesystem thread log locale regex chrono atomic date_time 
[    3s] -- Boost::boost exists
[    3s] -- Found CURL: /usr/lib64/libcurl.so (found version "7.79.1") 
[    3s] -- Found ZLIB: /usr/lib64/libz.so (found version "1.2.11") 
[    3s] -- Found Eigen3: /usr/include/eigen3 (Required is at least version "3.3") 
[    3s] -- Found EXPAT: /usr/lib64/libexpat.so (found version "2.4.1") 
[    3s] -- Found PNG: /usr/lib64/libpng.so (found version "1.6.37") 
[    3s] -- Found OpenGL: /usr/lib64/libOpenGL.so   
[    3s] -- Could NOT find GLEW (missing: GLEW_INCLUDE_DIRS GLEW_LIBRARIES) 
[    3s] -- GLEW not found, using bundled version.
[    3s] -- Found NLopt in '/usr/lib64'.
[    3s] -- Using NLopt include directory '/usr/include'.
[    3s] -- Using NLopt library '/usr/lib64/libnlopt.so'.
[    3s] COMPONENT = openvdb
[    3s] -- OpenVDB ABI Version: 9
[    3s] -- Found TBB: /usr/include (found version "2021.4") found components: tbb 
[    3s] -- Found Boost: /usr/lib64/cmake/Boost-1.77.0/BoostConfig.cmake (found version "1.77.0") found components: iostreams system 
[    3s] -- Found Blosc: /usr/lib64/libblosc.so (found version "1.21.1") 
[    3s] CMake Deprecation Warning at src/admesh/CMakeLists.txt:2 (cmake_minimum_required):
[    3s]   Compatibility with CMake < 2.8.12 will be removed from a future version of
[    3s]   CMake.
[    3s] 
[    3s]   Update the VERSION argument <min> value or use a ...<max> suffix to tell
[    3s]   CMake that the project does not need compatibility with older versions.
[    3s] 
[    3s] 
[    4s] CMake Deprecation Warning at src/boost/CMakeLists.txt:2 (cmake_minimum_required):
[    4s]   Compatibility with CMake < 2.8.12 will be removed from a future version of
[    4s]   CMake.
[    4s] 
[    4s]   Update the VERSION argument <min> value or use a ...<max> suffix to tell
[    4s]   CMake that the project does not need compatibility with older versions.
[    4s] 
[    4s] 
[    4s] CMake Deprecation Warning at src/clipper/CMakeLists.txt:2 (cmake_minimum_required):
[    4s]   Compatibility with CMake < 2.8.12 will be removed from a future version of
[    4s]   CMake.
[    4s] 
[    4s]   Update the VERSION argument <min> value or use a ...<max> suffix to tell
[    4s]   CMake that the project does not need compatibility with older versions.
[    4s] 
[    4s] 
[    4s] CMake Deprecation Warning at src/miniz/CMakeLists.txt:2 (cmake_minimum_required):
[    4s]   Compatibility with CMake < 2.8.12 will be removed from a future version of
[    4s]   CMake.
[    4s] 
[    4s]   Update the VERSION argument <min> value or use a ...<max> suffix to tell
[    4s]   CMake that the project does not need compatibility with older versions.
[    4s] 
[    4s] 
[    4s] -- Miniz NOT found in system, using bundled version...
[    4s] CMake Deprecation Warning at src/glu-libtess/CMakeLists.txt:2 (cmake_minimum_required):
[    4s]   Compatibility with CMake < 2.8.12 will be removed from a future version of
[    4s]   CMake.
[    4s] 
[    4s]   Update the VERSION argument <min> value or use a ...<max> suffix to tell
[    4s]   CMake that the project does not need compatibility with older versions.
[    4s] 
[    4s] 
[    4s] CMake Deprecation Warning at src/polypartition/CMakeLists.txt:2 (cmake_minimum_required):
[    4s]   Compatibility with CMake < 2.8.12 will be removed from a future version of
[    4s]   CMake.
[    4s] 
[    4s]   Update the VERSION argument <min> value or use a ...<max> suffix to tell
[    4s]   CMake that the project does not need compatibility with older versions.
[    4s] 
[    4s] 
[    4s] CMake Deprecation Warning at src/poly2tri/CMakeLists.txt:2 (cmake_minimum_required):
[    4s]   Compatibility with CMake < 2.8.12 will be removed from a future version of
[    4s]   CMake.
[    4s] 
[    4s]   Update the VERSION argument <min> value or use a ...<max> suffix to tell
[    4s]   CMake that the project does not need compatibility with older versions.
[    4s] 
[    4s] 
[    4s] CMake Deprecation Warning at src/qhull/CMakeLists.txt:31 (cmake_minimum_required):
[    4s]   Compatibility with CMake < 2.8.12 will be removed from a future version of
[    4s]   CMake.
[    4s] 
[    4s]   Update the VERSION argument <min> value or use a ...<max> suffix to tell
[    4s]   CMake that the project does not need compatibility with older versions.
[    4s] 
[    4s] 
[    4s] -- qhull Version: 7.2.0 (static linking)
[    4s] CMake Deprecation Warning at src/Shiny/CMakeLists.txt:2 (cmake_minimum_required):
[    4s]   Compatibility with CMake < 2.8.12 will be removed from a future version of
[    4s]   CMake.
[    4s] 
[    4s]   Update the VERSION argument <min> value or use a ...<max> suffix to tell
[    4s]   CMake that the project does not need compatibility with older versions.
[    4s] 
[    4s] 
[    4s] CMake Deprecation Warning at src/semver/CMakeLists.txt:2 (cmake_minimum_required):
[    4s]   Compatibility with CMake < 2.8.12 will be removed from a future version of
[    4s]   CMake.
[    4s] 
[    4s]   Update the VERSION argument <min> value or use a ...<max> suffix to tell
[    4s]   CMake that the project does not need compatibility with older versions.
[    4s] 
[    4s] 
[    4s] -- IGL NOT found, using bundled version...
[    4s] -- Using header-only CGAL
[    4s] -- Targetting Unix Makefiles
[    4s] -- Using /usr/bin/c++ compiler.
[    4s] -- Found GMP: /usr/lib64/libgmp.so  
[    4s] -- Found MPFR: /usr/lib64/libmpfr.so  
[    4s] -- Found Boost: /usr/lib64/cmake/Boost-1.77.0/BoostConfig.cmake (found suitable version "1.77.0", minimum required is "1.48")  
[    4s] -- Boost include dirs: /usr/include
[    4s] -- Boost libraries:    
[    4s] -- Using gcc version 4 or later. Adding -frounding-math
[    4s] -- Adding precompiled header pchheader.hpp to target libslic3r.
[    4s] CMake Deprecation Warning at src/imgui/CMakeLists.txt:2 (cmake_minimum_required):
[    4s]   Compatibility with CMake < 2.8.12 will be removed from a future version of
[    4s]   CMake.
[    4s] 
[    4s]   Update the VERSION argument <min> value or use a ...<max> suffix to tell
[    4s]   CMake that the project does not need compatibility with older versions.
[    4s] 
[    4s] 
[    4s] -- wx-config path: /usr/bin/wx-config
[    4s] -- wx libs: -L/usr/lib64;-pthread;;;-lwx_baseu-3.1;-lwx_gtk3u_core-3.1;-lwx_gtk3u_html-3.1;-lwx_gtk3u_gl-3.1;/usr/lib64/libpng.so;/usr/lib64/libz.so;/usr/lib64/libexpat.so;/usr/lib64/librt.a
[    4s] -- Adding precompiled header pchheader.hpp to target libslic3r_gui.
[    4s] -- Found GTK3: /usr/include/gtk-3.0;/usr/include/pango-1.0;/usr/include/glib-2.0;/usr/lib64/glib-2.0/include;/usr/include/harfbuzz;/usr/include/freetype2;/usr/include/libmount;/usr/include/blkid;/usr/include/fribidi;/usr/include/uuid;/usr/include/cairo;/usr/include/pixman-1;/usr/include/libpng16;/usr/include/gdk-pixbuf-2.0;/usr/include/gio-unix-2.0;/usr/include/wayland;/usr/include/libxkbcommon;/usr/include/atk-1.0;/usr/include/at-spi2-atk/2.0;/usr/include/dbus-1.0;/usr/lib64/dbus-1.0/include;/usr/include/at-spi-2.0  
[    4s] -- Configuring done
[    4s] -- Generating done
[    4s] CMake Warning:
[    4s]   Manually-specified variables were not used by the project:
[    4s] 
[    4s]     BUILD_STATIC_LIBS
[    4s]     CMAKE_Fortran_FLAGS
[    4s]     CMAKE_INSTALL_DO_STRIP
[    4s]     CMAKE_MODULES_INSTALL_DIR
[    4s]     INCLUDE_INSTALL_DIR
[    4s]     LIB_INSTALL_DIR
[    4s]     LIB_SUFFIX
[    4s]     SHARE_INSTALL_PREFIX
[    4s]     SYSCONF_INSTALL_DIR
[    4s] 
[    4s] 
[    4s] -- Build files have been written to: /home/abuild/rpmbuild/BUILD/PrusaSlicer-version_2.3.3/build
...
[   49s] [ 33%] Building CXX object src/libslic3r/CMakeFiles/libslic3r.dir/cmake_pch.hxx.gch
[   49s] cd /home/abuild/rpmbuild/BUILD/PrusaSlicer-version_2.3.3/build/src/libslic3r && /usr/bin/c++ -DBOOST_ALL_NO_LIB -DBOOST_ATOMIC_DYN_LINK -DBOOST_CHRONO_DYN_LINK -DBOOST_DATE_TIME_DYN_LINK -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_IOSTREAMS_DYN_LINK -DBOOST_LOCALE_DYN_LINK -DBOOST_LOG_DYN_LINK -DBOOST_REGEX_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DBOOST_THREAD_DYN_LINK -DLIBNEST2D_GEOMETRIES_clipper -DLIBNEST2D_OPTIMIZER_nlopt -DLIBNEST2D_STATIC -DOPENVDB_ABI_VERSION_NUMBER=9 -DSLIC3R_GUI -DTBB_USE_CAPTURED_EXCEPTION=0 -DUNICODE -DUSE_TBB -DWXINTL_NO_GETTEXT_MACRO -D_UNICODE -DwxNO_UNSAFE_WXSTRING_CONV -DwxUSE_UNICODE -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/home/abuild/rpmbuild/BUILD/PrusaSlicer-version_2.3.3/src -I/home/abuild/rpmbuild/BUILD/PrusaSlicer-version_2.3.3/build/src/platform -I/home/abuild/rpmbuild/BUILD/PrusaSlicer-version_2.3.3/src/clipper -I/home/abuild/rpmbuild/BUILD/PrusaSlicer-version_2.3.3/src/polypartition -I/home/abuild/rpmbuild/BUILD/PrusaSlicer-version_2.3.3/src/libslic3r -I/home/abuild/rpmbuild/BUILD/PrusaSlicer-version_2.3.3/build/src/libslic3r -I/home/abuild/rpmbuild/BUILD/PrusaSlicer-version_2.3.3/src/libnest2d/include -I/home/abuild/rpmbuild/BUILD/PrusaSlicer-version_2.3.3/src/miniz -I/home/abuild/rpmbuild/BUILD/PrusaSlicer-version_2.3.3/src/glu-libtess/include -I/home/abuild/rpmbuild/BUILD/PrusaSlicer-version_2.3.3/src/qhull/src -isystem /usr/include/eigen3 -isystem /home/abuild/rpmbuild/BUILD/PrusaSlicer-version_2.3.3/src/libigl -isystem /usr/include/libpng16 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -DNDEBUG -fext-numeric-literals -Wall -Wno-reorder -O2 -g -DNDEBUG -fPIC -Werror=return-type -Wno-ignored-attributes -Wno-unknown-pragmas -std=gnu++17 -Winvalid-pch -x c++-header -include /home/abuild/rpmbuild/BUILD/PrusaSlicer-version_2.3.3/build/src/libslic3r/CMakeFiles/libslic3r.dir/cmake_pch.hxx -MD -MT src/libslic3r/CMakeFiles/libslic3r.dir/cmake_pch.hxx.gch -MF CMakeFiles/libslic3r.dir/cmake_pch.hxx.gch.d -o CMakeFiles/libslic3r.dir/cmake_pch.hxx.gch -c /home/abuild/rpmbuild/BUILD/PrusaSlicer-version_2.3.3/build/src/libslic3r/CMakeFiles/libslic3r.dir/cmake_pch.hxx.cxx
[   49s] In file included from /home/abuild/rpmbuild/BUILD/PrusaSlicer-version_2.3.3/build/src/libslic3r/CMakeFiles/libslic3r.dir/cmake_pch.hxx:5,
[   49s]                  from <command-line>:
[   49s] /home/abuild/rpmbuild/BUILD/PrusaSlicer-version_2.3.3/src/libslic3r/pchheader.hpp:96:10: fatal error: tbb/atomic.h: No such file or directory
[   49s]    96 | #include <tbb/atomic.h>
[   49s]       |          ^~~~~~~~~~~~~~
[   49s] compilation terminated.

This line is not in master anymore, so I suspect 2.4.0 will not have the problem.
Thanks to the git history I have found #6590. Maybe I can backport that to 2.3.3.

@bnavigator
Copy link
Contributor

Update: with above mentioned PR backported to 2.3.3, it builds.

@theofficialgman
Copy link
Author

theofficialgman commented Nov 23, 2021

Update: with above mentioned PR backported to 2.3.3, it builds.

yeah thats entirely expected. you won't be able to build with my PR here on 2.3.3. You need all the other changes after that for it to work. Its based on master.
tbb/atomic.h (as well as the other functions) have been removed entirely from new TBB versions

bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this pull request Nov 24, 2021
https://build.opensuse.org/request/show/933584
by user bnavigator + dimstar_suse
- Make compatible with TBB 2021
  * add FindTBB.cmake -- gh#prusa3d/PrusaSlicer#7332
  * add PrusaSlicer-pr6590-updateTBB.patch
    gh#prusa3d/PrusaSlicer#6590
@dragonnn
Copy link

I am trying to compile latested git on Arch Linux, that PR applied fine but the build still fails:

FAILED: src/libslic3r/CMakeFiles/libslic3r.dir/utils.cpp.o
/usr/bin/c++ -DBOOST_ALL_NO_LIB -DBOOST_ATOMIC_DYN_LINK -DBOOST_CHRONO_DYN_LINK -DBOOST_DATE_TIME_DYN_LINK -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_IOSTREAMS_DYN_LINK -DBOOST_LOCALE_DYN_LINK -DBOOST_LOG_DYN_LINK -DBOOST_REGEX_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DBOOST_THREAD_DYN_LINK -DLIBNEST2D_GEOMETRIES_libslic3r -DLIBNEST2D_OPTIMIZER_nlopt -DLIBNEST2D_STATIC -DLIBNEST2D_THREADING_tbb -DOPENVDB_ABI_VERSION_NUMBER=9 -DSLIC3R_GUI -DTBB_USE_CAPTURED_EXCEPTION=0 -DUNICODE -DUSE_TBB -DWXINTL_NO_GETTEXT_MACRO -D_UNICODE -DwxNO_UNSAFE_WXSTRING_CONV -DwxUSE_UNICODE -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/home/mateusz/Trash/prusa-slicer-git/src/PrusaSlicer/src -I/home/mateusz/Trash/prusa-slicer-git/src/PrusaSlicer/build/src/platform -I/home/mateusz/Trash/prusa-slicer-git/src/PrusaSlicer/src/libslic3r -I/home/mateusz/Trash/prusa-slicer-git/src/PrusaSlicer/build/src/libslic3r -I/home/mateusz/Trash/prusa-slicer-git/src/PrusaSlicer/src/libnest2d/include -I/home/mateusz/Trash/prusa-slicer-git/src/PrusaSlicer/src/miniz -I/home/mateusz/Trash/prusa-slicer-git/src/PrusaSlicer/src/glu-libtess/include -isystem /usr/include/eigen3 -D_FORTIFY_SOURCE=2 -march=x86-64-v3 -mtune=generic -O2 -pipe -fno-plt -fext-numeric-literals -Wall -Wno-reorder -O3 -DNDEBUG -fPIC -fsigned-char -Werror=return-type -Wno-ignored-attributes -Wno-unknown-pragmas -pthread -std=gnu++17 -Winvalid-pch -include /home/mateusz/Trash/prusa-slicer-git/src/PrusaSlicer/build/src/libslic3r/CMakeFiles/libslic3r.dir/cmake_pch.hxx -MD -MT src/libslic3r/CMakeFiles/libslic3r.dir/utils.cpp.o -MF src/libslic3r/CMakeFiles/libslic3r.dir/utils.cpp.o.d -o src/libslic3r/CMakeFiles/libslic3r.dir/utils.cpp.o -c /home/mateusz/Trash/prusa-slicer-git/src/PrusaSlicer/src/libslic3r/utils.cpp
/home/mateusz/Trash/prusa-slicer-git/src/PrusaSlicer/src/libslic3r/utils.cpp:53:14: fatal error: tbb/task_scheduler_init.h: No such file or directory
   53 |     #include <tbb/task_scheduler_init.h>
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
[10/19] Building CXX object src/libslic3r/CMakeFiles/libslic3r.dir/GCode.cpp.o
FAILED: src/libslic3r/CMakeFiles/libslic3r.dir/GCode.cpp.o
/usr/bin/c++ -DBOOST_ALL_NO_LIB -DBOOST_ATOMIC_DYN_LINK -DBOOST_CHRONO_DYN_LINK -DBOOST_DATE_TIME_DYN_LINK -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_IOSTREAMS_DYN_LINK -DBOOST_LOCALE_DYN_LINK -DBOOST_LOG_DYN_LINK -DBOOST_REGEX_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DBOOST_THREAD_DYN_LINK -DLIBNEST2D_GEOMETRIES_libslic3r -DLIBNEST2D_OPTIMIZER_nlopt -DLIBNEST2D_STATIC -DLIBNEST2D_THREADING_tbb -DOPENVDB_ABI_VERSION_NUMBER=9 -DSLIC3R_GUI -DTBB_USE_CAPTURED_EXCEPTION=0 -DUNICODE -DUSE_TBB -DWXINTL_NO_GETTEXT_MACRO -D_UNICODE -DwxNO_UNSAFE_WXSTRING_CONV -DwxUSE_UNICODE -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/home/mateusz/Trash/prusa-slicer-git/src/PrusaSlicer/src -I/home/mateusz/Trash/prusa-slicer-git/src/PrusaSlicer/build/src/platform -I/home/mateusz/Trash/prusa-slicer-git/src/PrusaSlicer/src/libslic3r -I/home/mateusz/Trash/prusa-slicer-git/src/PrusaSlicer/build/src/libslic3r -I/home/mateusz/Trash/prusa-slicer-git/src/PrusaSlicer/src/libnest2d/include -I/home/mateusz/Trash/prusa-slicer-git/src/PrusaSlicer/src/miniz -I/home/mateusz/Trash/prusa-slicer-git/src/PrusaSlicer/src/glu-libtess/include -isystem /usr/include/eigen3 -D_FORTIFY_SOURCE=2 -march=x86-64-v3 -mtune=generic -O2 -pipe -fno-plt -fext-numeric-literals -Wall -Wno-reorder -O3 -DNDEBUG -fPIC -fsigned-char -Werror=return-type -Wno-ignored-attributes -Wno-unknown-pragmas -pthread -std=gnu++17 -Winvalid-pch -include /home/mateusz/Trash/prusa-slicer-git/src/PrusaSlicer/build/src/libslic3r/CMakeFiles/libslic3r.dir/cmake_pch.hxx -MD -MT src/libslic3r/CMakeFiles/libslic3r.dir/GCode.cpp.o -MF src/libslic3r/CMakeFiles/libslic3r.dir/GCode.cpp.o.d -o src/libslic3r/CMakeFiles/libslic3r.dir/GCode.cpp.o -c /home/mateusz/Trash/prusa-slicer-git/src/PrusaSlicer/src/libslic3r/GCode.cpp
/home/mateusz/Trash/prusa-slicer-git/src/PrusaSlicer/src/libslic3r/GCode.cpp:38:10: fatal error: tbb/pipeline.h: No such file or directory
   38 | #include <tbb/pipeline.h>
      |          ^~~~~~~~~~~~~~~~
      ```
 Is they something more need to get it compiling?

@bubnikv
Copy link
Collaborator

bubnikv commented Dec 11, 2021

#include <tbb/pipeline.h>

I suppose you need a newer TBB. Static compilation against the dependencies produced by our deps script as described in our wiki should work.

@dragonnn
Copy link

https://archlinux.org/packages/extra/x86_64/tbb/
Looking at the upstream repo https://github.com/oneapi-src/oneTBB/releases I am running the latest version.

@bnavigator
Copy link
Contributor

It's the other way round, TBB 2021.4 does not have tbb/pipeline.h and tbb/task_scheduler_init.h.

For the latter, you are somehow in the wrong branch here:

// We are using quite an old TBB 2017 U7, which does not support global control API officially.
// Before we update our build servers, let's use the old API, which is deprecated in up to date TBB.
#ifdef TBB_HAS_GLOBAL_CONTROL
#include <tbb/global_control.h>
#else
#include <tbb/task_scheduler_init.h>
#endif

For the former, ae7d6db made PrusaSlicer incompatible with TBB 2021.

https://www.intel.com/content/www/us/en/developer/articles/technical/tbb-revamp.html
From the PDF:

Deprecated/removed TBB functionality Replacement
tbb::pipeline (incl. tbb::filter, tbb::thread_bound_filter) tbb::parallel_pipeline, tbb::flow::async_node, resumable tasks

@dragonnn
Copy link

I will just use latest AppImage for now and wait for the issue here to resolve, looks like the TBB stuff needs still some work. Thanks!

@twelho
Copy link

twelho commented Dec 12, 2021

I managed to make 2.4.0-beta4 compile on Arch using the FindTBB.cmake updates from this PR by making the following additional code changes:

diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp
index cddb506c2..7da94aeb4 100644
--- a/src/libslic3r/GCode.cpp
+++ b/src/libslic3r/GCode.cpp
@@ -35,7 +35,7 @@
 #include "SVG.hpp"
 
 #include <tbb/parallel_for.h>
-#include <tbb/pipeline.h>
+#include <tbb/parallel_pipeline.h>
 
 #include <Shiny/Shiny.h>
 
@@ -1500,7 +1500,7 @@ void GCode::process_layers(
 {
     // The pipeline is variable: The vase mode filter is optional.
     size_t layer_to_print_idx = 0;
-    const auto generator = tbb::make_filter<void, GCode::LayerResult>(tbb::filter::serial_in_order,
+    const auto generator = tbb::make_filter<void, GCode::LayerResult>(tbb::filter_mode::serial_in_order,
         [this, &print, &tool_ordering, &print_object_instances_ordering, &layers_to_print, &layer_to_print_idx](tbb::flow_control& fc) -> GCode::LayerResult {
             if (layer_to_print_idx == layers_to_print.size()) {
                 fc.stop();
@@ -1514,16 +1514,16 @@ void GCode::process_layers(
                 return this->process_layer(print, layer.second, layer_tools, &layer == &layers_to_print.back(), &print_object_instances_ordering, size_t(-1));
             }
         });
-    const auto spiral_vase = tbb::make_filter<GCode::LayerResult, GCode::LayerResult>(tbb::filter::serial_in_order,
+    const auto spiral_vase = tbb::make_filter<GCode::LayerResult, GCode::LayerResult>(tbb::filter_mode::serial_in_order,
         [&spiral_vase = *this->m_spiral_vase.get()](GCode::LayerResult in) -> GCode::LayerResult {
             spiral_vase.enable(in.spiral_vase_enable);
             return { spiral_vase.process_layer(std::move(in.gcode)), in.layer_id, in.spiral_vase_enable, in.cooling_buffer_flush };
         });
-    const auto cooling = tbb::make_filter<GCode::LayerResult, std::string>(tbb::filter::serial_in_order,
+    const auto cooling = tbb::make_filter<GCode::LayerResult, std::string>(tbb::filter_mode::serial_in_order,
         [&cooling_buffer = *this->m_cooling_buffer.get()](GCode::LayerResult in) -> std::string {
             return cooling_buffer.process_layer(std::move(in.gcode), in.layer_id, in.cooling_buffer_flush);
         });
-    const auto output = tbb::make_filter<std::string, void>(tbb::filter::serial_in_order,
+    const auto output = tbb::make_filter<std::string, void>(tbb::filter_mode::serial_in_order,
         [&output_stream](std::string s) { output_stream.write(s); }
     );
 
@@ -1546,7 +1546,7 @@ void GCode::process_layers(
 {
     // The pipeline is variable: The vase mode filter is optional.
     size_t layer_to_print_idx = 0;
-    const auto generator = tbb::make_filter<void, GCode::LayerResult>(tbb::filter::serial_in_order,
+    const auto generator = tbb::make_filter<void, GCode::LayerResult>(tbb::filter_mode::serial_in_order,
         [this, &print, &tool_ordering, &layers_to_print, &layer_to_print_idx, single_object_idx](tbb::flow_control& fc) -> GCode::LayerResult {
             if (layer_to_print_idx == layers_to_print.size()) {
                 fc.stop();
@@ -1557,16 +1557,16 @@ void GCode::process_layers(
                 return this->process_layer(print, { std::move(layer) }, tool_ordering.tools_for_layer(layer.print_z()), &layer == &layers_to_print.back(), nullptr, single_object_idx);
             }
         });
-    const auto spiral_vase = tbb::make_filter<GCode::LayerResult, GCode::LayerResult>(tbb::filter::serial_in_order,
+    const auto spiral_vase = tbb::make_filter<GCode::LayerResult, GCode::LayerResult>(tbb::filter_mode::serial_in_order,
         [&spiral_vase = *this->m_spiral_vase.get()](GCode::LayerResult in)->GCode::LayerResult {
             spiral_vase.enable(in.spiral_vase_enable);
             return { spiral_vase.process_layer(std::move(in.gcode)), in.layer_id, in.spiral_vase_enable, in.cooling_buffer_flush };
         });
-    const auto cooling = tbb::make_filter<GCode::LayerResult, std::string>(tbb::filter::serial_in_order,
+    const auto cooling = tbb::make_filter<GCode::LayerResult, std::string>(tbb::filter_mode::serial_in_order,
         [&cooling_buffer = *this->m_cooling_buffer.get()](GCode::LayerResult in)->std::string {
             return cooling_buffer.process_layer(std::move(in.gcode), in.layer_id, in.cooling_buffer_flush);
         });
-    const auto output = tbb::make_filter<std::string, void>(tbb::filter::serial_in_order,
+    const auto output = tbb::make_filter<std::string, void>(tbb::filter_mode::serial_in_order,
         [&output_stream](std::string s) { output_stream.write(s); }
     );
 
diff --git a/src/libslic3r/utils.cpp b/src/libslic3r/utils.cpp
index efffcfe24..7a8cfa0fe 100644
--- a/src/libslic3r/utils.cpp
+++ b/src/libslic3r/utils.cpp
@@ -45,6 +45,8 @@
 #include <boost/nowide/convert.hpp>
 #include <boost/nowide/cstdio.hpp>
 
+#define TBB_HAS_GLOBAL_CONTROL
+
 // We are using quite an old TBB 2017 U7, which does not support global control API officially.
 // Before we update our build servers, let's use the old API, which is deprecated in up to date TBB.
 #ifdef TBB_HAS_GLOBAL_CONTROL

Passes tests (now that #7291 is merged), and seems to launch and work just fine.

bubnikv added a commit that referenced this pull request Dec 12, 2021
some interfaces.
Implements some of TBB universal fix (2020/2021 fixes) #7332
@bubnikv
Copy link
Collaborator

bubnikv commented Dec 12, 2021

I have added a compile time switch for tbb::filter_mode
c772d28

bubnikv added a commit that referenced this pull request Dec 12, 2021
Support for oneTBB from oneAPI, where Intel reworked and deprecated
some interfaces.
Implements some of TBB universal fix (2020/2021 fixes) #7332
This one adds TBB_HAS_GLOBAL_CONTROL for the up to date oneTBB.
@bubnikv
Copy link
Collaborator

bubnikv commented Dec 12, 2021

This one 23e4ecd
adds a compile-time definintion of TBB_HAS_GLOBAL_CONTROL

@bubnikv
Copy link
Collaborator

bubnikv commented Dec 12, 2021

Unfortunately this script is not compatible with the old TBB. I am getting the following error when trying to run CMake on PrusaSlicer source base (this one was on Windows):

-- CMAKE_PREFIX_PATH: C:\data\src\slic3r-deps\usr\local\ (from cache or command line)
Building with Win10 Netfabb STL fixing service support
-- Found Boost: C:/data/src/slic3r-deps/usr/local/lib/cmake/Boost-1.75.0/BoostConfig.cmake (found suitable version "1.75.0", minimum required is "1.66.0") found components: system filesystem thread log locale regex chrono atomic date_time iostreams
-- Boost::boost exists
-- Could NOT find TBB (missing: TBB_DIR)
CMake Error at cmake/modules/FindTBB.cmake:166 (message):
  Required library TBB not found.
Call Stack (most recent call first):
  cmake/modules/FindTBB.cmake:421 (findpkg_finish)
  CMakeLists.txt:384 (find_package)

Thus we will not merge this pull request either until the issue is resolved or until we upgrade to oneTBB.

@bubnikv
Copy link
Collaborator

bubnikv commented Dec 14, 2021

Should be fixed for good by @tamasmeszaros, see
#6355 (comment)

@bubnikv bubnikv closed this Dec 14, 2021
@theofficialgman
Copy link
Author

theofficialgman commented Dec 15, 2021

@bubnikv @tamasmeszaros not fixed, as seen by my comment here: #6355 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants