On Linux, if a user even dares to install tbb:
sudo apt install libtbb-dev
It completely destroys the std library and with it Swift/C++ interop with the following error:
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/stdlib.h:36:11: error: cyclic dependency in module 'std': std -> _Builtin_intrinsics -> std
# include <cstdlib>
Why is the cstdlib polluted with an external dependencies garbage (in this case tbb)?
This is the ridiculous workaround [building TBB from source, to change its include path to anything unexpected] needed to use TBB in any capacity with Swift/C++ interop as a result (doing everything in your power to ensure preprocessor conditions like these #if __has_include(<tbb/blocked_range.h>)
in the std lib always fails, else you get the error above.)
NOTE: this issue affects only Linux, macOS and Windows have no issue here.
If additional proof is necessary, please review these GitHub Actions workflows and their respective commits here.
Specifically this failed run compared to this successful run, comparing this diff.
I'm unsure the rationale behind having TBB related dependencies in the cstdlib headers, if it's simply for adding intrinsics, those can be added manually by the user using clang's target attributes (ex. __attribute__((target("avx")))
).
Like I did here.