Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

Compile failed with clang on Linux

Harry_W_1
Beginner
393 Views

I cannot use tbb well on Linux when comes to LLVM/Clang. The problem I found is that, because I use clang with libstdc++ not libc++.

In this file 'tbb_config.h L164':

#define __TBB_CPP11_RVALUE_REF_PRESENT  (__has_feature(__cxx_ravlue_references__) && (__TBB_GCC_VERSION >= 40300 || _LIBCPP_VERSION))

I use clang 3.7.1, the __TBB_GCC_VERSION will give 40201, and __LIBCPP_VERSION is not defined, because I'm not using libc++. So this define is not valid, then cause compile failed.

0 Kudos
3 Replies
RafSchietekat
Valued Contributor III
393 Views

Did you see a compilation failure during "make all", and where, or only when you try to use rvalue references with TBB in your own code?

Does the problem go away if you change this to "#define __TBB_CPP11_RVALUE_REF_PRESENT 1"?

I don't know why __TBB_GCC_VERSION is being used here, because it always seems to be 40201 with Clang (well, I found one other mention of that somewhere). The macro to detect the version of libstdc++ seems to be __GLIBCXX__. I suggest you try to find some more information that might guide a revised configuration setting for TBB's use of rvalue references.

0 Kudos
Harry_W_1
Beginner
393 Views

Raf Schietekat wrote:

Did you see a compilation failure during "make all", and where, or only when you try to use rvalue references with TBB in your own code?

Does the problem go away if you change this to "#define __TBB_CPP11_RVALUE_REF_PRESENT 1"?

I don't know why __TBB_GCC_VERSION is being used here, because it always seems to be 40201 with Clang (well, I found one other mention of that somewhere). The macro to detect the version of libstdc++ seems to be __GLIBCXX__. I suggest you try to find some more information that might guide a revised configuration setting for TBB's use of rvalue references.

Hi, I don't compile TBB directly, but use it in my client code. I've use cache_aligned_allocator, but compile failed when it comes to construct method. Then I find that macro is not suit well.

In the tbb_config.h file, in the #if __clang__ section, I see some macros is checking _LIBCPP_VERSION (like __TBB_EXCEPTION_PTR_PRESEND and __TBB_CPP11_STD_BEGIN_END_PRESENT), while only __TBB_CPP11_RVALUE_REF_PRESENT checks both __GLIBCXX__ and __LIBCPP_VERSION. It's weird. All the methods related to those macros may not behave well when it comes to clang with libstdc++. I think the developer don't take the situation when someone use clang with libstdc++ in to account. It should not only check the _LIBCPP_VERSION when comes to clang.

What I have done to resolve this is to define _LIBCPP_VERSION macro and then it comes to be compiled well.

0 Kudos
RafSchietekat
Valued Contributor III
393 Views

Thanks for providing that information. Now let's hope somebody acts on it.

0 Kudos
Reply