[shared_ptr] Clang with Microsoft CodeGen in VS 2015 Update 1
See http://blogs.msdn.com/b/vcblog/archive/2015/12/04/introducing-clang-with-mic... I tried building the Boost.Filesystem DLL with clang/c2 using the Visual Studio solution from libs/filesystem/test/msvc. As indicated the blog post, the following changes were needed in the project's properties: Configuration Properties General Platform Toolset : Clang 3.7 with Microsoft CodeGen (v140_clang_3_7) C/C++ General Warning Level : EnableAllWarnings (-Wall) Code Generation Enable C++ Exceptions: Yes (-fexceptions) Language Enable Run-Time Type Information: Yes (-frtti) Precompiled Headers Precompiled Header: Not using Precompiled Headers The operations.cpp compile failed with the following errors: 2> operations.cpp 2> In file included from ..\..\..\src\operations.cpp:44: 2> In file included from ../../../../..\boost/filesystem/operations.hpp:25: 2> In file included from ../../../../..\boost/filesystem/path.hpp:29: 2> In file included from ../../../../..\boost/shared_ptr.hpp:17: 2> In file included from ../../../../..\boost/smart_ptr/shared_ptr.hpp:28: 2> In file included from ../../../../..\boost/smart_ptr/detail/shared_count.hpp:29: 2> In file included from ../../../../..\boost/smart_ptr/detail/sp_counted_base.hpp:45: 2>../../../../..\boost/smart_ptr/detail/sp_counted_base_clang.hpp(29,1): error : cannot mangle this C11 atomic type yet 2> inline void atomic_increment( atomic_int_least32_t * pw ) 2> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2>../../../../..\boost/smart_ptr/detail/sp_counted_base_clang.hpp(34,1): error : cannot mangle this C11 atomic type yet 2> inline boost::int_least32_t atomic_decrement( atomic_int_least32_t * pw ) 2> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2>../../../../..\boost/smart_ptr/detail/sp_counted_base_clang.hpp(39,1): error : cannot mangle this C11 atomic type yet 2> inline boost::int_least32_t atomic_conditional_increment( atomic_int_least32_t * pw ) 2> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ So it looks like the clang/c2 toolset doesn't support atomics yet. The __c2__ and __c2_version__ macros allow detection of the clang/c2 toolset, could a workaround be added to shared_ptr? I know we don't usually worry about workarounds for preview (i.e. early beta) compiler releases, but the ability to add the clang/c2 toolset to local tests for library developers working on Windows will be a big plus IMO. --Beman PS: Has anyone figured out how to invoke clang/c2 from the command line?
Beman Dawes wrote:
So it looks like the clang/c2 toolset doesn't support atomics yet. The __c2__ and __c2_version__ macros allow detection of the clang/c2 toolset, could a workaround be added to shared_ptr?
If you change #if defined( __clang__ ) && defined( __has_extension ) # if __has_extension( __c_atomic__ ) # define BOOST_SP_HAS_CLANG_C11_ATOMICS # endif #endif in sp_counted_base.hpp to #if defined( __clang__ ) && defined( __has_extension ) && !defined( __c2__ ) # if __has_extension( __c_atomic__ ) # define BOOST_SP_HAS_CLANG_C11_ATOMICS # endif #endif does it work then?
On Tue, Dec 8, 2015 at 10:55 AM, Peter Dimov
Beman Dawes wrote:
So it looks like the clang/c2 toolset doesn't support atomics yet. The
__c2__ and __c2_version__ macros allow detection of the clang/c2 toolset, could a workaround be added to shared_ptr?
If you change
#if defined( __clang__ ) && defined( __has_extension ) # if __has_extension( __c_atomic__ ) # define BOOST_SP_HAS_CLANG_C11_ATOMICS # endif #endif
in sp_counted_base.hpp to
#if defined( __clang__ ) && defined( __has_extension ) && !defined( __c2__ ) # if __has_extension( __c_atomic__ ) # define BOOST_SP_HAS_CLANG_C11_ATOMICS # endif #endif
does it work then?
I also had to do the same for two other cases, but in the end sp_counted_base_w32.hpp worked and the entire filesystem dll built OK. Furthermore, all the test programs are passing! The test programs were compiled with the regular msvc compiler and then linked against the clang compiled dll. Turns out all that has to be done to call clang from the command line is to add "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\Clang 3.7\bin\x86" to the path, so it should be easy to see if Boost.Build will work. --Beman
Beman Dawes wrote
On Tue, Dec 8, 2015 at 10:55 AM, Peter Dimov <
lists@
> wrote:
Beman Dawes wrote:
So it looks like the clang/c2 toolset doesn't support atomics yet. The
__c2__ and __c2_version__ macros allow detection of the clang/c2 toolset, could a workaround be added to shared_ptr?
If you change
#if defined( __clang__ ) && defined( __has_extension ) # if __has_extension( __c_atomic__ ) # define BOOST_SP_HAS_CLANG_C11_ATOMICS # endif #endif
in sp_counted_base.hpp to
#if defined( __clang__ ) && defined( __has_extension ) && !defined( __c2__ ) # if __has_extension( __c_atomic__ ) # define BOOST_SP_HAS_CLANG_C11_ATOMICS # endif #endif
does it work then?
I also had to do the same for two other cases, but in the end sp_counted_base_w32.hpp worked and the entire filesystem dll built OK.
The same problem occurs with clang-cl, which defines _MSC_VER instead of __GNUC__. Could that be fixed too please? clang/c2 defines __GNUC__ but doesn't support GCC inline assembly, so sp_counted_base_gcc_x86.hpp also has to be excluded for __c2__. -- View this message in context: http://boost.2283326.n4.nabble.com/shared-ptr-Clang-with-Microsoft-CodeGen-i... Sent from the Boost - Dev mailing list archive at Nabble.com.
Marcel Raad wrote:
The same problem occurs with clang-cl, which defines _MSC_VER instead of __GNUC__. Could that be fixed too please?
clang/c2 defines __GNUC__ but doesn't support GCC inline assembly, so sp_counted_base_gcc_x86.hpp also has to be excluded for __c2__.
With all those subtly different clangs, things are getting a bit ridiculous. Does #define BOOST_SP_USE_STD_ATOMIC work for clang-cl and clang/c2?
Peter Dimov-2 wrote
Does #define BOOST_SP_USE_STD_ATOMIC work for clang-cl and clang/c2?
Yes, it works with clang/c2 and with all clang-cl toolsets. -- View this message in context: http://boost.2283326.n4.nabble.com/shared-ptr-Clang-with-Microsoft-CodeGen-i... Sent from the Boost - Dev mailing list archive at Nabble.com.
On Wed, Dec 9, 2015 at 12:26 PM, Peter Dimov
Marcel Raad wrote:
The same problem occurs with clang-cl, which defines _MSC_VER instead of
__GNUC__. Could that be fixed too please?
clang/c2 defines __GNUC__ but doesn't support GCC inline assembly, so sp_counted_base_gcc_x86.hpp also has to be excluded for __c2__.
With all those subtly different clangs, things are getting a bit ridiculous.
Yes, but do remember that clang/c2 in Update 1 is just a preview release. They want it to work on the Boost codebase, are clearly putting more resources into C++ than in the past, and fixing bugs much more quickly. --Beman
participants (3)
-
Beman Dawes
-
Marcel Raad
-
Peter Dimov