#4849 closed Bugs (fixed)
MinGW-64: detail/interlocked.hpp chooses wrong prototypes for InterlockedCompareExchange et al
Reported by: | Owned by: | Anthony Williams | |
---|---|---|---|
Milestone: | Boost 1.55.0 | Component: | thread |
Version: | Boost 1.54.0 | Severity: | Problem |
Keywords: | mingw64 InterlockedCompareExchange once.hpp thread.cpp | Cc: | jim@…, sam@…, phprus@… |
Description
I see pdimov's name on detail/interlocked.hpp, so I'm filing this here...
MinGW-64/Win7 fails to compile thread.cpp, so all dependent regressions fail.
In file included from ../boost/thread/once.hpp:14, from ..\libs\thread\src\win32\thread.cpp:17: ../boost/thread/win32/once.hpp: In function 'void boost::call_once(boost::once_flag&, Function)': ../boost/thread/win32/once.hpp:136: error: '_InterlockedCompareExchange' is not a member of 'boost::detail' ../boost/thread/win32/once.hpp:152: error: '_InterlockedIncrement' is not a member of 'boost::detail' ../boost/thread/win32/once.hpp:155: error: '_InterlockedExchange' is not a member of 'boost::detail' ../boost/thread/win32/once.hpp:169: error: '_InterlockedExchange' is not a member of 'boost::detail' ../boost/thread/win32/once.hpp:184: error: '_InterlockedIncrement' is not a member of 'boost::detail'
If I modify detail/interlocked.hpp to choose it as BOOST_USE_WINDOWS_H, thread.cpp builds and dependent tests pass. It seems BOOST_USE_WINDOWS_H is special-purpose, so I'm not sure if this is the final fix.
#if defined( BOOST_USE_WINDOWS_H ) || defined(_WIN64)
Presently it's choosing this section (line 107):
#elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ )
This seems somewhat similar to Ticket #4217
Attachments (4)
Change History (28)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Cc: | added |
---|
comment:3 by , 12 years ago
I see that the "Win7-x64 jc-bell.com" regression tester doesn't have the issue, but this may be caused by a different version of windows.h. Either way, this is not (in my opinion) an issue with interlocked.hpp, it's caused by thread.cpp including windows.h before once.hpp. windows.h then (I assume) defines Interlocked* as macros to _Interlocked*. Putting the windows.h include last should solve the problem.
comment:4 by , 12 years ago
"Win7-x64 jc-bell.com" is my platform (still experimental), and it this works because I have a fix for it. It #undef's Interlocked... stuff after #include <windows.h>
by , 12 years ago
Attachment: | mingw64-thread.patch added |
---|
comment:7 by , 12 years ago
Yes. Moving #include <windows.h> below all other includes DOES correct the above "_Interlocked..." errors above.
I'm attaching a patch that shows this, and also a couple other related MinGW-64 patches that might be helpful. Review it carefully.
by , 12 years ago
Attachment: | mingw64-thread-2.patch added |
---|
comment:8 by , 12 years ago
Component: | smart_ptr → thread |
---|---|
Owner: | changed from | to
I'll reassign this to Anthony for now, he can bounce it back to me later. :-)
comment:9 by , 12 years ago
I'll just want to bump this since it wasn't fixed in the latest 1.46.1 release... if bumping is not usual in such bug-trackers I apologize for the inconvenience. ;)
comment:10 by , 12 years ago
Same. I met the issue on my build today. What would be the next delivery in an official build ?
comment:11 by , 12 years ago
One problem is that boost doesn't have a reliable mingw64 regression test for trunk and release. Mine's experimental, trunk-only, and doesn't get run often (to say the least). So the maintainer probably isn't going to take a chance on it.
Anyone want to run trunk and release regressions until this change gets shepherded through trunk and release branches? If so, we can at least try to get the maintainer's attention: I'll send him a polite e-mail about it. (No guarantee it'll get fixed even then.)
Until then, look at the attached patches and patch your distribution. Hate to say it, but that's the expedient fix.
comment:12 by , 12 years ago
Status: | new → assigned |
---|
I've applied the patch to trunk (revision 70383). If it doesn't cause any problems it can be merged to release.
comment:15 by , 11 years ago
i lost few days on investigate why mingw64 chokes compiling my code then i saw this
i patched my boost release to it and it works well
it be very nice if it can be merged to release branch
thank you mayburn11
comment:16 by , 11 years ago
This will be released in boost 1.47.0. See http://lists.boost.org/Archives/boost/2011/06/182834.php.
comment:17 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Closed as for the comments it seems this was committed in release branch.
comment:18 by , 9 years ago
Just hit this same issue building 1.54.0 with MinGW-builds-x64-4.8.1-posix-seh on Windows 7 x64:
C:\Users\Matt\Documents\git\tool-chain\third_party\source\http\boost_1_54_0>b2 t oolset=gcc variant=release link=shared threading=multi runtime-link=shared --pre fix=C:\boost-1.54.0 --with-thread -d+2 Building the Boost C++ Libraries. Component configuration: - atomic : not building - chrono : not building - context : not building - coroutine : not building - date_time : not building - exception : not building - filesystem : not building - graph : not building - graph_parallel : not building - iostreams : not building - locale : not building - log : not building - math : not building - mpi : not building - program_options : not building - python : not building - random : not building - regex : not building - serialization : not building - signals : not building - system : not building - test : not building - thread : building - timer : not building - wave : not building gcc.link.dll bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\li bboost_thread-mgw48-mt-1_54.dll.a "g++" "-Wl,--out-implib,bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\t hreading-multi\libboost_thread-mgw48-mt-1_54.dll.a" -o "bin.v2\libs\thread\build \gcc-mingw-4.8.1\release\threading-multi\libboost_thread-mgw48-mt-1_54.dll" -sh ared -Wl,--start-group "bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threadi ng-multi\win32\thread.o" "bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threa ding-multi\win32\tss_dll.o" "bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\th reading-multi\win32\tss_pe.o" "bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\ threading-multi\future.o" "bin.v2\libs\chrono\build\gcc-mingw-4.8.1\release\thre ading-multi\libboost_chrono-mgw48-mt-1_54.dll.a" "bin.v2\libs\system\build\gcc-m ingw-4.8.1\release\threading-multi\libboost_system-mgw48-mt-1_54.dll.a" -Wl,-Bs tatic -Wl,-Bdynamic -Wl,--end-group -mthreads bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x387): undefined reference to `InterlockedCompareExchange' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x3a4): undefined reference to `InterlockedCompareExchange' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x400): undefined reference to `InterlockedExchange' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x47e): undefined reference to `InterlockedIncrement' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x494): undefined reference to `InterlockedCompareExchange' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x781): undefined reference to `InterlockedIncrement' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x79c): undefined reference to `InterlockedCompareExchange' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x9a0): undefined reference to `InterlockedCompareExchange' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x9bd): undefined reference to `InterlockedCompareExchange' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0xa19): undefined reference to `InterlockedExchange' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0xa9f): undefined reference to `InterlockedIncrement' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0xab5): undefined reference to `InterlockedCompareExchange' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0xee2): undefined reference to `InterlockedIncrement' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0xefd): undefined reference to `InterlockedCompareExchange' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x1026): undefined reference to `InterlockedIncrement' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x10d9): undefined reference to `InterlockedIncrement' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x1159): undefined reference to `InterlockedDecrement' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x11e8): undefined reference to `InterlockedIncrement' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x1227): undefined reference to `InterlockedDecrement' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x1293): undefined reference to `InterlockedDecrement' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x1310): undefined reference to `InterlockedDecrement' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x13a9): undefined reference to `InterlockedDecrement' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x1445): undefined reference to `InterlockedDecrement' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x1a3d): undefined reference to `InterlockedCompareExchange' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x1a5a): undefined reference to `InterlockedCompareExchange' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x1ab6): undefined reference to `InterlockedExchange' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x1b21): undefined reference to `InterlockedIncrement' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x1b37): undefined reference to `InterlockedCompareExchange' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x1df1): undefined reference to `InterlockedIncrement' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x1e0c): undefined reference to `InterlockedCompareExchange' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x3212): undefined reference to `InterlockedDecrement' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x3328): undefined reference to `InterlockedDecrement' bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\win32\thread.o: thread.cpp:(.text+0x1130): undefined reference to `InterlockedIncrement' c:/users/matt/documents/git/tool-chain/third_party/mingw-builds/4.8.1/x64/posix/ seh/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw 32/bin/ld.exe: bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\ win32\thread.o: bad reloc address 0x8 in section `.data' collect2.exe: error: ld returned 1 exit status ...removing bin.v2\libs\thread\build\gcc-mingw-4.8.1\release\threading-multi\lib boost_thread-mgw48-mt-1_54.dll.a ...skipped <pstage\lib>libboost_thread-mgw48-mt-1_54.dll.a for lack of <pbin.v2\ libs\thread\build\gcc-mingw-4.8.1\release\threading-multi>libboost_thread-mgw48- mt-1_54.dll.a... ...skipped <pstage\lib>libboost_thread-mgw48-mt-1_54.dll for lack of <pbin.v2\li bs\thread\build\gcc-mingw-4.8.1\release\threading-multi>libboost_thread-mgw48-mt -1_54.dll... ...failed updating 2 targets...
I'm trying to figure out why the macros are not set to the correct symbols, if anyone has any pointers for me, I welcome a hint :)
comment:20 by , 9 years ago
@jim: I solved this by adding define=BOOST_USE_WINDOWS_H to fix the build. That forces the inclusion of windows.h
pulling in the correct definitions for the symbols. I went over the patches, they all seem to be in the trunk now, so was a little lost but found some more information around on Google about building Boost with MinGW x64.
comment:21 by , 9 years ago
It seems that there is a regression on mingw 64
See http://sourceforge.net/mailarchive/message.php?msg_id=31189847.
comment:22 by , 9 years ago
I have eventually fixed this issue without having to define BOOST_USE_WINDOWS_H (which causes issues when compiling with wxWidgets for example). The patch (https://svn.boost.org/trac/boost/attachment/ticket/4849/interlocked.diff) works with mingw-w64 targeting both i686 and x86_64. Hope this can be included in 1.55.0.
by , 9 years ago
Attachment: | interlocked.diff added |
---|
comment:23 by , 9 years ago
Milestone: | Boost 1.46.0 → Boost 1.55.0 |
---|---|
Version: | Boost Development Trunk → Boost 1.54.0 |
Have the same problem and made a patch. It deals with mingw64 in its own #elif and undoes BOOST_INTERLOCKED_IMPORT from mingw64-thread-2.patch Tested with mingw64 4.8.1 64 and 32 bits and threads compile and work.
by , 9 years ago
Attachment: | mingw64_iterlocked.patch added |
---|
BOOST_USE_WINDOWS_H is a user macro; it causes boost headers to include <windows.h>, which should never happen automatically.