Re: x3 linker error with separate TU

Olaf Peter <[email protected]>
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <[email protected]>
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. At this time I haven't access to my project 
but I will confirm if it works (or even not).

What is the reason for these linker error? Are there chances that the 
fix will be included into boost 1.65?

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:

 1.
    gdb ./calc9
 2.
    GNU gdb (GDB) Fedora 7.12.1-48.fc25
 3.
    [...]
 4.

 5.
    Using host libthread_db library "/lib64/libthread_db.so.1".
 6.
 7.
    Program received signal SIGSEGV, Segmentation fault.
 8.
    0x000000000042bcd8 in boost::shared_ptr<boost::spirit::x3::tst<char,
    client::ast::optoken> >::operator-> (this=0x10) at
    /usr/include/boost/smart_ptr/shared_ptr.hpp:693
 9.
    693       BOOST_ASSERT( px != 0 );
10.
    Missing separate debuginfos, use: dnf debuginfo-install
    boost-system-1.60.0-10.fc25.x86_64
11.
    (gdb) bt
12.
    #0  0x000000000042bcd8 in
    boost::shared_ptr<boost::spirit::x3::tst<char, client::ast::optoken>
     >::operator-> (this=0x10) at
    /usr/include/boost/smart_ptr/shared_ptr.hpp:693
13.
    #1  0x000000000042aed8 in
    boost::spirit::x3::symbols_parser<boost::spirit::char_encoding::standard,
    client::ast::optoken, boost::spirit::x3::tst<char,
    client::ast::optoken> >::adder::operator()<char [3]> (this=0x660a80
    <client::parser::logical_op>, s=...,
14.
    val=@0x7fffffffdb5c: client::ast::op_and) at
    /usr/include/boost/spirit/home/x3/string/symbols.hpp:262
15.
    #2  0x0000000000429342 in client::parser::add_keywords () at
    /home/olaf/work/CXX/ReferenceDesigns/x3_calc9/expression_def.hpp:46
16.
    #3  0x00000000004295c5 in client::expression () at
    /home/olaf/work/CXX/ReferenceDesigns/x3_calc9/expression_def.hpp:176
17.
    #4  0x0000000000413c23 in __static_initialization_and_destruction_0
    (__initialize_p=1, __priority=65535) at
    /home/olaf/work/CXX/ReferenceDesigns/x3_calc9/statement_def.hpp:42
18.
    #5  0x0000000000413d7b in _GLOBAL__sub_I__ZN6client9statementEv ()
    at /home/olaf/work/CXX/ReferenceDesigns/x3_calc9/statement.cpp:13
19.
    #6  0x000000000043ae9d in __libc_csu_init ()
20.
    #7  0x00007ffff6f8d390 in __libc_start_main () from /lib64/libc.so.6
21.
    #8  0x0000000000403bba in _start ()


Did I use X3 in way not intended to be used? Is this related to the 
linker error on topic here? 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.

Thanks,
Olaf

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

_______________________________________________
Spirit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-general
CMakeLists.txt (text/plain, 581 B)
cmake_minimum_required(VERSION 3.6)

project(calc9 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

find_package(Boost COMPONENTS system REQUIRED)

add_library(${PROJECT_NAME}_parser STATIC 
    expression.cpp
    statement.cpp
)

add_executable(${PROJECT_NAME} 
    compiler.cpp
    vm.cpp
    main.cpp
)

target_include_directories(${PROJECT_NAME}
    PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
)

target_link_libraries(${PROJECT_NAME}
    PRIVATE
    ${PROJECT_NAME}_parser
    ${Boost_SYSTEM_LIBRARY}
)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.