Closed Facon closed 2 years ago
This command compiles your code: g++ test.cpp -lboost_fiber-mt -lboost_context-mt
@Biswa96
This command compiles your code:
g++ test.cpp -lboost_fiber-mt -lboost_context-mt
I get the following error:
User@DESKTOP-LC9EG87 MINGW32 /c/Users/User/Documents/Sources/testing/fibers/src
$ pacman -Ql mingw-w64-i686-boost | grep libboost
mingw-w64-i686-boost /mingw32/bin/libboost_atomic-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_chrono-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_container-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_context-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_contract-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_coroutine-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_date_time-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_filesystem-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_graph-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_iostreams-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_locale-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_log-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_log_setup-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_math_c99-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_math_c99f-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_math_c99l-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_math_tr1-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_math_tr1f-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_math_tr1l-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_nowide-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_numpy38-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_prg_exec_monitor-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_program_options-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_python38-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_random-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_regex-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_serialization-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_stacktrace_noop-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_stacktrace_windbg-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_system-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_thread-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_timer-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_type_erasure-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_unit_test_framework-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_wave-mt.dll
mingw-w64-i686-boost /mingw32/bin/libboost_wserialization-mt.dll
mingw-w64-i686-boost /mingw32/lib/libboost_atomic-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_atomic-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_chrono-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_chrono-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_container-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_container-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_context-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_context-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_contract-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_contract-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_coroutine-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_coroutine-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_date_time-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_date_time-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_exception-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_filesystem-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_filesystem-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_graph-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_graph-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_iostreams-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_iostreams-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_locale-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_locale-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_log-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_log-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_log_setup-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_log_setup-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_math_c99-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_math_c99-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_math_c99f-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_math_c99f-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_math_c99l-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_math_c99l-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_math_tr1-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_math_tr1-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_math_tr1f-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_math_tr1f-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_math_tr1l-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_math_tr1l-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_nowide-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_nowide-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_numpy38-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_numpy38-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_prg_exec_monitor-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_prg_exec_monitor-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_program_options-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_program_options-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_python38-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_python38-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_random-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_random-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_regex-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_regex-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_serialization-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_serialization-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_stacktrace_noop-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_stacktrace_noop-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_stacktrace_windbg-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_stacktrace_windbg-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_system-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_system-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_test_exec_monitor-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_thread-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_thread-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_timer-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_timer-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_type_erasure-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_type_erasure-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_unit_test_framework-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_unit_test_framework-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_wave-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_wave-mt.dll.a
mingw-w64-i686-boost /mingw32/lib/libboost_wserialization-mt.a
mingw-w64-i686-boost /mingw32/lib/libboost_wserialization-mt.dll.a
User@DESKTOP-LC9EG87 MINGW32 /c/Users/User/Documents/Sources/testing/fibers/src
$ g++ sample.cpp -lboost_fiber-mt -lboost_context-mt
C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/10.2.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lboost_fiber-mt
collect2.exe: error: ld returned 1 exit status
Diffing both packages shows libboost_fiber-mt.dll
and libboost_stacktrace_windbg_cached-mt.dll
are missing. No idea
thread local storage seems to be misdetected for the fiber library, if you remove the requirement check for it in libs/fiber/build/jamfile.v2 it builds no problem.
That sounds a bit like what happened with libstdc++ in #7043.
That may very well be the case aye.
In file included from libs\stacktrace\build\..\src\windbg_cached.cpp:10:
./boost/stacktrace/detail/frame_msvc.ipp:176:5: error: #error Your compiler does not support C++11 thread_local storage. It`s impossible to build with BOOST_STACKTRACE_USE_WINDBG_CACHED.
176 | # error Your compiler does not support C++11 thread_local storage. It`s impossible to build with BOOST_STACKTRACE_USE_WINDBG_CACHED.
damn...
google gives me this:
I guess confirming that the gcc bug still exists and report it in the bugtracker would be a good next step.
That would probably be a good idea, though from what i can read at the gcc bug thread they allready had some idea how to fix it (trampolines) but it newer seems to have been applied.
@Facon so looks like there is no easy fix. I'd advise you to work with the 64bit toolchain instead if possible.
I reported the bug is still active to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83562
I see during boost 32 bit configure:
- Boost.Config Feature Check: cxx11_template_aliases : yes
- Boost.Config Feature Check: cxx11_thread_local : no
- Boost.Config Feature Check: cxx11_variadic_templates : yes
In boost sources see:
#if (BOOST_GCC_VERSION < 40800) || !defined(BOOST_GCC_CXX11)
# define BOOST_NO_CXX11_ALIGNAS
# define BOOST_NO_CXX11_THREAD_LOCAL
# define BOOST_NO_CXX11_SFINAE_EXPR
#endif
...
#if defined(__MINGW32__) && !defined(__MINGW64__)
// Currently (March 2019) thread_local is broken on mingw for all current 32bit compiler releases, see
// https://sourceforge.net/p/mingw-w64/bugs/527/
// Not setting this causes program termination on thread exit.
#define BOOST_NO_CXX11_THREAD_LOCAL
#endif
So it related to https://sourceforge.net/p/mingw-w64/bugs/527/
Been like this since forever and still not fixed, if it was as easy as the commenter in the gcc bug thread said it would have worked a long time ago, so i doubt we will ever see a fix to it unless someone comes up with a patch (it does not seem to be a main agenda for the gcc devs, as long as it works on linux). Might be better to get boost building with mingw clang instead.
@revelator at least example from mingw-w64 bugreport dont crash for me
It appears that, despite commit messages to the contrary, the cxa_thread_atexit from mingw is being used rather than one from libstdc++, and this cxa_thread_atexit is defined to take a thiscall function pointer, not cdecl. https://sourceforge.net/p/mingw-w64/mingw-w64/ci/v8.0.0/tree/mingw-w64-crt/crt/cxa_thread_atexit.c#l7
So the boost workaround no longer appllies ?. In that case we could remove the BOOST_NO_CXX11_THREAD_LOCAL define and see how it goes from there.
I think @Alexpux is one step ahead of you there 😁 https://github.com/msys2/MINGW-packages/commit/c910889ba9a31af6fa93ac3d25ca42b11c558506#diff-78b35e86b9af9094b73ccbd0561f0910
If the mingw-w64 __cxa_thread_atexit()
uses __thiscall
calling convention, then the libstdc++ one should align with it. I think I can send a patch to GCC.
I haven't actually seen the destructor be called at thread exit, though. I stepped through the disassembly, and the tls value that mingw was storing its dtor list in was NULL at the time the tls_callback was called. I wonder if libgcc's was called first and cleaned up emutls before that.
EDIT: this appears to be the case (3 == DLL_THREAD_DETACH):
Thread 5 hit Breakpoint 2, 0x00406d70 in emutls_destroy ()
(gdb) c
Continuing.
Thread 5 hit Breakpoint 1, tls_callback (hDllHandle=0x400000, dwReason=3,
lpReserved=0x0)
at C:/_/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/tls_atexit.c:89
89 in C:/_/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/tls_atexit.c
Neat 👍
If you use clion, you can try change your toolchain to msys2 mingw. Don't use clion bundled mingw.
Workaround available https://github.com/msys2/MINGW-packages/issues/7071#issuecomment-702659710
Hello everyone,
I would like to know how can I link a very simple application with boost fibers.
I am getting linking errors that says that fiber references are missing. I confirm that doing objectdump on all *.a doesn't show any reference to fiber's classes.
I show below files that I'm using.
CMakeLists.txt
src/sample.cpp
Linking error