Incompatible with tbb 2021.1.1

I am a nixpkgs maintainer, we recently tried to update tbb to 2021.1.1.

While doing so we found the following incompatibility with the last tbb version:

In file included from /tmp/nix-build-blender-2.91.0.drv-0/blender-2.91.0/intern/cycles/util/util_task.cpp:17:
In file included from /tmp/nix-build-blender-2.91.0.drv-0/blender-2.91.0/intern/cycles/util/../util/util_task.h:22:
/tmp/nix-build-blender-2.91.0.drv-0/blender-2.91.0/intern/cycles/util/../util/util_tbb.h:39:14: error: no member named 'self' in namespace 'tbb::v1::task'
  tbb::task::self().cancel_group_execution();
  ~~~~~~~~~~~^
/tmp/nix-build-blender-2.91.0.drv-0/blender-2.91.0/intern/cycles/util/util_task.cpp:65:20: error: no member named 'is_canceling' in 'tbb::detail::d1::task_group'
  return tbb_group.is_canceling();
         ~~~~~~~~~ ^
2 errors generated.
make[2]: *** [intern/cycles/util/CMakeFiles/cycles_util.dir/build.make:238: intern/cycles/util/CMakeFiles/cycles_util.dir/util_task.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:3722: intern/cycles/util/CMakeFiles/cycles_util.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

In short building blender against tbb 2021.1.1 fails because tbb no longer expose the is_canceling function.
It would be great if this could be resolved so we don’t have to provided a vendored version of tbb just for blender.
Here here is the corresponding nixpkgs issue: https://github.com/NixOS/nixpkgs/pull/109113

Cheers Mic92

Hi!

The is_canceling function is renamed to is_current_task_group_canceling

IIRC we would follow the VFX Platform for updates of TBB. The plan was to update the libraries to VFX platform 2021 for Blender 2.93. That means that we will update to Intel TBB 2020 Update 2. See https://vfxplatform.com/ and https://developer.blender.org/T83246
We should first see if the APIs are the same and otherwise decide if we would like to add compile directives for this.

We generally make Blender work with newer library versions to help distributions / packagers. This will come up for other Linux distributions sooner or later, and then it will be either us fixing it or every distribution maintaining a custom patch. So we might as well fix it ourselves.

Fix committed for Blender 2.92 in https://developer.blender.org/rB3732508.

is_current_task_group_canceling seems to already exist since TBB 2017 (and possibly older, did not check), so should be fine to use it without #ifdef.

4 Likes

I’m still getting the same error as the first one shown by @Mic92

intern/cycles/util/../util/util_tbb.h:39:14: error: no member named 'self' in namespace 'tbb::v1::task'
  tbb::task::self().cancel_group_execution();
  ~~~~~~~~~~~^
1 error generated.

If I build passed the cycles error I also get other errors that are tbb related

...source/blender/blenlib/intern/task_pool.cc:136:9: error: use of undeclared identifier 'my_context'; did you mean 'm_context'?
        my_context.set_priority(tbb::priority_low);
        ^~~~~~~~~~
        m_context
/usr/local/include/oneapi/tbb/task_group.h:375:24: note: 'm_context' declared here
    task_group_context m_context;
                       ^
...blenlib/intern/task_pool.cc:136:20: error: no member named 'set_priority' in 'tbb::detail::d1::task_group_context'
        my_context.set_priority(tbb::priority_low);
        ~~~~~~~~~~ ^
...source/blender/blenlib/intern/task_pool.cc:136:33: error: no member named 'priority_low' in namespace 'tbb'; did you mean 'priority'?
        my_context.set_priority(tbb::priority_low);
                                ^~~~~~~~~~~~~~~~~
                                priority

and repetitions of -

In file included from ...source/blender/blenkernel/intern/mesh_validate.cc:28:
In file included from ...source/blender/blenlib/BLI_task.hh:33:
In file included from /usr/local/include/tbb/tbb.h:17:
In file included from /usr/local/include/tbb/../oneapi/tbb.h:35:
In file included from /usr/local/include/oneapi/tbb/combinable.h:22:
In file included from /usr/local/include/oneapi/tbb/enumerable_thread_specific.h:26:
/usr/local/include/oneapi/tbb/concurrent_vector.h:233:44: error: reference to 'blocked_range' is ambiguous
    class generic_range_type : public tbb::blocked_range<Iterator> {
                                           ^
...source/blender/blenlib/BLI_index_range.hh:63:32: note: candidate found by name lookup is 'tbb::blocked_range'
template<typename Value> class blocked_range;
                               ^
/usr/local/include/oneapi/tbb/blocked_range.h:155:19: note: candidate found by name lookup is 'tbb::v1::blocked_range'
using detail::d1::blocked_range;
                  ^

Be sure you pull to get the latest code, also be sure to be building atleast one of the following branches since other will not have the fix.

This is building master I re-pulled just now at commit 41a945d7469f8135d8181bad9ec80037f0fbd069

I have oneTBB 2021.1.1 installed

Thanks for fixing this!

Ok, I actually tried building with TBB 2021 now and committed more fixes:
https://developer.blender.org/rBa1f44e4

I didn’t build with OpenVDB or USD though, since our current versions of those libraries are incompatible with TBB 2021. There may be more issues with their integration in Blender, but from the error log I don’t think it’s anything to fix on the Blender side.

1 Like