- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
In a suprising short time I get tbb compiled with clang and working, according to the tests. It seems clang fulfill the target to be compatible with gcc.
In a suprising short time I get tbb compiled with clang and working, according to the tests. It seems clang fulfill the target to be compatible with gcc.
I build the libraries and run the tests for ia32 and intel64.
The test results are the same that the ones I get when using the llvmgcc-4.2 compiler.
If the warnings patch included in my previous thread about "warnings missed by gcc" are applied, there are no compiler warnings at all when building or running the examples.
Changes needed
There are only two files which need a patch:
file:include/tbb/internal/_concurrent_queue_impl.h
apparentlyclang needs the public declaration inside ifdef "if __TBB_GCC_3_3_PROTECTED_BROKEN"
If the warnings patch included in my previous thread about "warnings missed by gcc" are applied, there are no compiler warnings at all when building or running the examples.
Changes needed
There are only two files which need a patch:
file:include/tbb/internal/_concurrent_queue_impl.h
apparentlyclang needs the public declaration inside ifdef "if __TBB_GCC_3_3_PROTECTED_BROKEN"
file:include/tbb/machine/linux_ia32.h
clang doesn't understand the mnemonics fildq and fistpq which must be replaced with fildll and fistpll
And the file macos.clang.inc must be added to build directory. macos.clang.inc it is a copy of macos.gcc.inc with minimal changes:
gcc changed to clang
g++ changed to clang++
compiler flag-fno-schedule-insns2 removed because clang don't understand.
Build data
TBB version: tbb40_20111130
Compiler version: (clang -v):
Apple clang version 3.0 (tags/Apple/clang-211.12) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin11.2.0
And the file macos.clang.inc must be added to build directory. macos.clang.inc it is a copy of macos.gcc.inc with minimal changes:
gcc changed to clang
g++ changed to clang++
compiler flag-fno-schedule-insns2 removed because clang don't understand.
Build data
TBB version: tbb40_20111130
Compiler version: (clang -v):
Apple clang version 3.0 (tags/Apple/clang-211.12) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin11.2.0
Thread model: posix
(darwin 11.2.0 corresponds to OS X 10.7.2)
(darwin 11.2.0 corresponds to OS X 10.7.2)
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for contributing this and other patches! Most of the changes were integrated into our mainline source code (with some rework, but the net effect should be the same), and will be released in a future update, sooner rather than later. Also, we enabled regular testing with Clang on OSX, so in future you should expect less warnings from this compiler. Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for integrating it.
As an opinion of someone who use microsoft, gcc and clang compilers usually, I think clang will be a very useful tool for development.
The quality of warning messages from clang are far away from gcc or msvc, complete and without false positives.
The difference seems to be that Clang uses a complete AST as an intemediate compiler product, whereas gcc and msvc don't have this step.
By the way, apparently Intel is already using LLVM, the backend of Clang, in several projects like OpenCL SDK or Array Building Blocks.
As an opinion of someone who use microsoft, gcc and clang compilers usually, I think clang will be a very useful tool for development.
The quality of warning messages from clang are far away from gcc or msvc, complete and without false positives.
The difference seems to be that Clang uses a complete AST as an intemediate compiler product, whereas gcc and msvc don't have this step.
By the way, apparently Intel is already using LLVM, the backend of Clang, in several projects like OpenCL SDK or Array Building Blocks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I hope it is ok if I reopen this thread instead of starting a new one.
I try to compile the latest tbb onMac OS X Lion 10.7.4 with clang and C++11 support using the libc++ Standard Library.
Using
[bash]make tbb compiler=clang CXXFLAGS="-stdlib=libc++ -std=c++11"[/bash]
fails with several compiler errors:
[bash]In file included from ../../src/tbb/private_server.cpp:34: In file included from ../../src/tbb/governor.h:141: In file included from ../../src/tbb/scheduler.h:32: In file included from ../../src/tbb/scheduler_common.h:51: In file included from ../../include/tbb/tbb_exception.h:41: In file included from /usr/bin/../lib/c++/v1/string:434: In file included from /usr/bin/../lib/c++/v1/algorithm:594: In file included from /usr/bin/../lib/c++/v1/memory:596: /usr/bin/../lib/c++/v1/iterator:1696:1: error: 'inline' can only appear on functions inline _LIBCPP_INLINE_VISIBILITY ^ /usr/bin/../lib/c++/v1/iterator:1698:1: error: variable 'begin' declared as a template begin(_T (&__array)[_N]) ^ /usr/bin/../lib/c++/v1/iterator:1698:12: error: use of undeclared identifier '__array' begin(_T (&__array)[_N]) ^ ../../src/tbb/itt_notify.h:70:32: note: expanded from macro '_T' #define _T(string_literal) string_literal ^ In file included from ../../src/tbb/private_server.cpp:34: In file included from ../../src/tbb/governor.h:141: In file included from ../../src/tbb/scheduler.h:32: In file included from ../../src/tbb/scheduler_common.h:51: In file included from ../../include/tbb/tbb_exception.h:41: In file included from /usr/bin/../lib/c++/v1/string:434: In file included from /usr/bin/../lib/c++/v1/algorithm:594: In file included from /usr/bin/../lib/c++/v1/memory:596: /usr/bin/../lib/c++/v1/iterator:1698:25: error: expected ';' at end of declaration begin(_T (&__array)[_N]) ^ ; /usr/bin/../lib/c++/v1/iterator:1699:1: error: expected unqualified-id { ^ 5 errors generated. make[1]: *** [private_server.o] Error 1 make: *** [tbb] Error 2 Zenitums-iMac:tbb40_20120408oss stefan$ make tbb compiler=clang CXXFLAGS="-stdlib=libc++ -std=c++11" Created ./build/macos_intel64_clang_cc4.2.1_os10.7.4_release and ..._debug directories make -C "./build/macos_intel64_clang_cc4.2.1_os10.7.4_debug" -r -f ../../build/Makefile.tbb cfg=debug tbb_root=../.. ../../build/Makefile.tbb:39: CONFIG: cfg=debug arch=intel64 compiler=clang os=macos runtime=cc4.2.1_os10.7.4 clang++ -c -MMD -g -O0 -DTBB_USE_DEBUG -DUSE_PTHREAD -m64 -fPIC -D__TBB_BUILD=1 -Wall -Wno-non-virtual-dtor -stdlib=libc++ -std=c++11 -I../../src -I../../src/rml/include -I../../include ../../src/tbb/private_server.cpp In file included from ../../src/tbb/private_server.cpp:34: In file included from ../../src/tbb/governor.h:141: In file included from ../../src/tbb/scheduler.h:32: In file included from ../../src/tbb/scheduler_common.h:51: In file included from ../../include/tbb/tbb_exception.h:41: In file included from /usr/bin/../lib/c++/v1/string:434: In file included from /usr/bin/../lib/c++/v1/algorithm:594: In file included from /usr/bin/../lib/c++/v1/memory:596: /usr/bin/../lib/c++/v1/iterator:1696:1: error: 'inline' can only appear on functions inline _LIBCPP_INLINE_VISIBILITY ^ /usr/bin/../lib/c++/v1/iterator:1698:1: error: variable 'begin' declared as a template begin(_T (&__array)[_N]) ^ /usr/bin/../lib/c++/v1/iterator:1698:12: error: use of undeclared identifier '__array' begin(_T (&__array)[_N]) ^ ../../src/tbb/itt_notify.h:70:32: note: expanded from macro '_T' #define _T(string_literal) string_literal ^ In file included from ../../src/tbb/private_server.cpp:34: In file included from ../../src/tbb/governor.h:141: In file included from ../../src/tbb/scheduler.h:32: In file included from ../../src/tbb/scheduler_common.h:51: In file included from ../../include/tbb/tbb_exception.h:41: In file included from /usr/bin/../lib/c++/v1/string:434: In file included from /usr/bin/../lib/c++/v1/algorithm:594: In file included from /usr/bin/../lib/c++/v1/memory:596: /usr/bin/../lib/c++/v1/iterator:1698:25: error: expected ';' at end of declaration begin(_T (&__array)[_N]) ^ ; /usr/bin/../lib/c++/v1/iterator:1699:1: error: expected unqualified-id { ^ In file included from ../../src/tbb/private_server.cpp:34: In file included from ../../src/tbb/governor.h:141: In file included from ../../src/tbb/scheduler.h:32: In file included from ../../src/tbb/scheduler_common.h:51: ../../include/tbb/tbb_exception.h:357:71: error: no member named 'copy_exception' in namespace 'std'; did you mean 'bad_exception'? ...( const captured_exception& src ) : my_ptr(std::copy_exception(src)) {} ~~~~~^ 6 errors generated. make[1]: *** [private_server.o] Error 1 make: *** [tbb] Error 2[/bash]I got around the last error by defining
[bash]make tbb compiler=clang CXXFLAGS="-stdlib=libc++ -std=c++11 -DTBB_USE_CAPTURED_EXCEPTION=1"[/bash]
Any ideas or suggestions on these issues? Is full clang support planed for the future?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hisboehm,
we have not test clang in c++11 mode yet, it looks that clang++ 3.1 from Late March command line tools does not have full support forexception_ptr.
../../include/tbb/tbb_exception.h:357:71:error:nomembernamed 'copy_exception'innamespace'std';didyoumean'bad_exception'? ...(constcaptured_exception&src):my_ptr(std::copy_exception(src)){}
defining of TBB_USE_CAPTURED_EXCEPTION is exactly the way to not useexception_ptr.
We are looking for a better support of c++11.
thanks for report of the issue.
--Vladimir
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page