Re: [Boost-bugs] [Boost C++ Libraries] #12233: boost::regex doesn't compile with clang on windows

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #12233: boost::regex doesn't compile with clang on windows
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-10-19 21:23:19


#12233: boost::regex doesn't compile with clang on windows
---------------------------------------+-------------------------
  Reporter: Ä°smail Dönmez <ismail@…> | Owner: johnmaddock
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: regex
   Version: Boost 1.61.0 | Severity: Problem
Resolution: | Keywords:
---------------------------------------+-------------------------

Comment (by adamf88@…):

 Hi eceryone,

 I found the same issue. I have boost compiled with MSVC toolset (2010) and
 I'm trying to link it to project with clang toolset.
 I have no problems with libraries like boost::filesystem. The regexp is
 the first one I found problem.

 I had some time (it took a while) to debug it, but finally I found the
 reason (if you want to read it in a nutshell then scroll down to point 5):
 1. The error message says than abstract_protected_call::execute() is
 missing from regex.cpp in the library. I checked the generated
 libboost_regex-vc100-mt-gd-1_62.lib file. This is true, this function is
 missing. But why MSVC compilation works and Clang doesn't ?
 2. To answer the question we have to look around. This function is guarded
 by define: BOOST_REGEX_HAS_MS_STACK_GUARD. If we get the things together
 then: on MSVC toolset BOOST_REGEX_HAS_MS_STACK_GUARD is undefined (because
 in lib is missing) and on clang the symbol is defined (because it looks
 for this function). Let's check it
 3. The symbol is defined in file regex\config.hxx. (line 370 in boost
 1.62.0). For tests I added pragma line above this definition: #pragma
 message("TEST") then we will get this message on clang build and during
 regex compilation with MSVC. (So the function execute should be available
 because the symbol is defined), but:
 4. In line 417 in file config.hpp we can find:

 {{{
 # ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
 # undef BOOST_REGEX_HAS_MS_STACK_GUARD
 # endif
 }}}
 Lets add #pragma message ("UNDEFINED") and check when it is executed.
 Finally:
 MSVC compilation boost::regexp library - we will get message UNDEFINED. So
 the symbol is undefined and our method is not available in static lib.
 Clang (test project compilation with regexp) - no message. So symbol
 BOOST_REGEX_HAS_MS_STACK_GUARD is still defined and clang tries to link
 this function (execute).
 5. Where is the difference ?
 In line 395 (regex/config.hpp) we can find define with statement (this
 statement enables undef code block execution):
 {{{
 !(defined(BOOST_MSVC) && (BOOST_MSVC >= 1400)
 }}}
 If we build sample project with Clang toolset then BOOST_MSVC is
 undefined. And it is the reason why the compilation fails. Why this symbol
 is undefined ? Clang should pretend to be MSVC perfectly ( really ? :) ).
 To answer this last question we should look into file:
 "config/select_compiler_config.hpp".
 Clang on windows defines symbols: __clang__ and _MSC_VER, but the check
 for clang is before check for MSVC and clang toolset was selected. So
 boost doesn't define BOOST_MSVC for clang toolset compilation.


 Unfortunately clang doesn't pretend to be MSVC perfectly and it caused the
 error. I hope it will help you to do the fix.


 My quick and dirty fix was in select_compiler_config.hpp file by adding on
 the end of clang toolset checking: && !defined(_MSC_VER). But I didn't run
 any other tests and I don't know if it doesn't cause any other issues. (
 My program now works :) )

 Dear boost support:
 Will you do any fix of this issue in the next versions of boost library ?
 Do you have any plans to support boost build with clang toolset on windows
 ?

 Regards,
 Adam

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12233#comment:10>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:20 UTC