Re: x3 linker error with separate TU
Larry Evans <[email protected]>
| Newsgroups | gmane.comp.parsers.spirit.general |
|---|---|
| Message-ID | <[email protected]> |
On 05/26/2017 12:47 PM, Olaf Peter wrote:
> Hello Larry,
>> On 05/22/2017 11:10 AM, Olaf Peter wrote:
>>> Hello,
>>>
>>> this refers to a question at stackoverflow, where since 14 days no
>>> answer is known. From my side I've checked the related answers on
>>> stackoverflow but there seems to be no solution:
>>> https://stackoverflow.com/questions/43791079/x3-linker-error-with-separate-tu
>>>
>>>
>>>
>>> Maybe here is a better place to get an answer since the rule count rises
>>> and the compile time increases ... The problems stays with boost 1.64.0
>>> and gcc-7.10/clang-3.91 too.
>>>
>>>
>> It seems to work with:
>>
>> https://github.com/cppljevans/spirit/tree/get_rhs
>>
>> at least based on the attached compilation.out and a
>> slight change to the source, main.cpp, where:
>>
>> #define BOOST_ERROR_CODE_HEADER_ONLY
>>
>> was added at the top.
> Thank you for investigating.
You're welcome
? At this time I haven't access to my project
> but I will confirm if it works (or even not).
Thanks.
>
> What is the reason for these linker error?
Possibly the reason is as explained by Seth here:
http://boost.2283326.n4.nabble.com/Linking-error-when-changing-gt-to-gt-gt-tt4689820.html#a4689860
and I *guess* the attribute transform Seth talked about was that
encapsulated in rule_attr_transform here:
https://github.com/cppljevans/spirit/blob/get_rhs/include/boost/spirit/home/x3/nonterminal/detail/rule.hpp#L311
and where rule_attr_transform is done is governed by the macro:
BOOST_SPIRIT_DISABLE_RULE_ATTR_XFORM
IIRC, Seth mentioned something about a solution by keeping the attribute
"synchronized" with what's required the parse function and,
somehow, when BOOST_SPIRIT_DEFINE is use, it's "synchronized",
but when BOOST_SPIRIT_DECLARE and BOOST_SPIRIT_INSTANTIATE are used,
it, for some reason, get's "out-of-sync".
I'm still trying to understand how it works :(
> Are there chances that the
> fix will be included into boost 1.65?
I could do a pull request now. Does that sound OK Joel?
>
> BTW, during investigating I played with x3's calc9 and wrote a CMake
> file, where a static link library was created. The resulting exe crashed:
[snip]
> 11.
> (gdb) bt
> 12.
> #0 0x000000000042bcd8 in
> boost::shared_ptr<boost::spirit::x3::tst<char, client::ast::optoken>
> >::operator-> (this=0x10) at
^^^^ highly suspicious! I doubt 0x10
is a valid address.
> /usr/include/boost/smart_ptr/shared_ptr.hpp:693
[snip]
>
> Did I use X3 in way not intended to be used? Is this related to the
> linker error on topic here?
Sorry, I've no idea.
> Note, no BOOST_SPIRIT_X3_DEBUG is defined
> where rise other problems too (following this ML and SO).
>
> Using a single pass (g++ -I . expression.cpp statement.cpp compiler.cpp
> vm.cpp main.cpp -o ../x3_calc9_BUILD/calc9 -lboost_system) the exe was
> functional.
Strange!
>
> Thanks,
> Olaf
>
Sure. Sorry I couldn't be more help. Will study problem further.
-regards,
Larry
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot