[context] build and warning fixes for gcc on Windows

Hello Posting here as there's no context component in trac yet. This specifically relates to boost.context and cygwin's mingw64-x64_64_gcc toolchain with ml and ml64 from Visual Studio 2010. The patch attached is against trunk (rev 78752) for the following warnings: * ..\..\../boost/context/detail/fcontext_x86_64_win.hpp:20:0: warning: ignoring #pragma warning * ..\src\seh.cpp:36:87: warning: format %08lX expects type long unsigned int, but argument 5 has type ULONG_PTR (I'm guessing %p used in the patch is probably not the best solution for cross-platformness) * ..\src\seh.cpp:39:53: warning: deprecated conversion from string constant to char* The last issue I've had is with jump_fcontext and make_fcontext exports: Warning: .drectve `/EXPORT:jump_fcontext /EXPORT:make_fcontext 3' unrecognized Which seems to cause: collect2: ld terminated with signal 6 [Aborted], core dumped Removing the EXPORT directive in the asm file results in a successful build, but naturally the symbols aren't exported. I hacked around this by changing the asm functions to jump_fcontext_impl and make_fcontext_impl, and provided an extern C jump_fcontext and make_fcontext in fcontext.cpp that forward to them. I'm sure there are far nicer ways to force the symbols to be exported so I've not attached the patch for this. With these changes, I can more-or-less successfully use context which is great! (A slight issue with exceptions; possibly crossing dll boundaries and/or due to this gcc's exception implementation using setjmp/longjmp.) Finally, is there any technical reason why gas assembly couldn't be provided for use with gcc on Windows? Having to have masm available seems a shame, aside from the issues above. I had a very quick go at it without success but could possibly have another attempt ... Thanks for the library and regards, Luke Elliott.

Hello Luke,
This specifically relates to boost.context and cygwin's mingw64-x64_64_gcc toolchain with ml and ml64 from Visual Studio 2010.
The patch attached is against trunk (rev 78752) for the following warnings:
<snip> thank you for your contribution - I'll add your patch soon.
The last issue I've had is with jump_fcontext and make_fcontext exports:
Warning: .drectve `/EXPORT:jump_fcontext /EXPORT:make_fcontext 3' unrecognized
<snip>
Finally, is there any technical reason why gas assembly couldn't be provided for use with gcc on Windows? Having to have masm available seems a shame, aside from the issues above.
the assemler code for Windows platforms is only provided for MASM because I want to support only a standard assembler tool for each platform. MASM is provided by Microsoft and distributed with MS's SDKs, therfore it was used.
I had avery quick go at it without success but could possibly have another attempt ...
the unit-tests on 32it/64bit Windows work for me?! do you have ml.exe/ml64.exe in the search path? regards, Oliver -- NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone! Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a

On 08/06/12 07:53, Oliver Kowalke wrote:
Hello Luke,
This specifically relates to boost.context and cygwin's mingw64-x64_64_gcc toolchain with ml and ml64 from Visual Studio 2010.
The patch attached is against trunk (rev 78752) for the following warnings:
<snip> thank you for your contribution - I'll add your patch soon.
The last issue I've had is with jump_fcontext and make_fcontext exports:
Warning: .drectve `/EXPORT:jump_fcontext /EXPORT:make_fcontext 3' unrecognized
<snip>
Finally, is there any technical reason why gas assembly couldn't be provided for use with gcc on Windows? Having to have masm available seems a shame, aside from the issues above.
the assemler code for Windows platforms is only provided for MASM because I want to support only a standard assembler tool for each platform. MASM is provided by Microsoft and distributed with MS's SDKs, therfore it was used.
I had avery quick go at it without success but could possibly have another attempt ...
the unit-tests on 32it/64bit Windows work for me?! do you have ml.exe/ml64.exe in the search path?
Maybe a misunderstanding - I was referring to my failed attempt at hacking together a gas version of the masm assembly. Using the masm assembly works for me, aside from the export issue.
regards, Oliver

I had avery quick go at it without success but could possibly have another attempt ...
the unit-tests on 32it/64bit Windows work for me?! do you have ml.exe/ml64.exe in the search path?
Maybe a misunderstanding - I was referring to my failed attempt at hacking together a gas version of the masm assembly.
OK :)
Using the masm assembly works for me, aside from the export issue.
keyword EXPORT in the Windows asm is MASM specific regards, Oliver -- NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone! Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a

On 08/06/2012 08:54, Oliver Kowalke wrote:
I had avery quick go at it without success but could possibly have another attempt ...
the unit-tests on 32it/64bit Windows work for me?! do you have ml.exe/ml64.exe in the search path?
Maybe a misunderstanding - I was referring to my failed attempt at hacking together a gas version of the masm assembly.
OK :)
Using the masm assembly works for me, aside from the export issue.
keyword EXPORT in the Windows asm is MASM specific
Sure but maybe still some misunderstanding :) I wasn't trying to use the .asm files with the gas assembler... My queries about gas were just an aside really. masm assembles fine for me. But at link time (with the gnu linker): Warning: .drectve `/EXPORT:jump_fcontext /EXPORT:make_fcontext 3' unrecognized And then the linker dies: collect2: ld terminated with signal 6 [Aborted], core dumped I worked around it as mentioned in the initial post, though I'm sure there are better solutions!
regards, Oliver

On 08/06/2012 08:54, Oliver Kowalke wrote:
I had avery quick go at it without success but could possibly have another attempt ...
the unit-tests on 32it/64bit Windows work for me?! do you have ml.exe/ml64.exe in the search path?
Maybe a misunderstanding - I was referring to my failed attempt at hacking together a gas version of the masm assembly.
OK :)
Using the masm assembly works for me, aside from the export issue.
keyword EXPORT in the Windows asm is MASM specific
regards, Oliver
Hello Oliver I see you have committed some warning fixes. I just wanted to mention the reinterpret_cast<void *> in seh.cpp was there to avoid GCC being too clever for its own good: ..\..\..\libs\context\src\seh.cpp: In function const char* exception_description(const _EXCEPTION_RECORD*, char*, size_t): ..\..\..\libs\context\src\seh.cpp:36:82: warning: format %p expects type void*, but argument 5 has type ULONG_PTR Any thoughts on the build failure though? Just to clarify: I'm using Cygwin's x86_64-w64-mingw32-g++ GCC and MASM from VS2010. My user-config.jam has: using gcc : 4.5 : c:\\cygwin\\bin\\x86_64-w64-mingw32-g++ ; Then compiling with bjam --toolset=gcc from a VS2010 x64 environment: Performing configuration checks - 32-bit : no - 64-bit : yes - x86 : yes ...patience... ...found 374 targets... ...updating 7 targets... Jamfile</D:/dev/checkouts/boost-trunk/libs/context/build>.masm64 ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\address-model-64\architecture-x86\asm\fcontext_x86_64_ms_pe_masm.o Assembling: ..\..\..\libs\context\src\asm\fcontext_x86_64_ms_pe_masm.asm Microsoft (R) Macro Assembler (x64) Version 10.00.40219.01 Copyright (C) Microsoft Corporation. All rights reserved. gcc.compile.c++ ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\fcontext.o gcc.compile.c++ ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\seh.o ..\..\..\libs\context\src\seh.cpp: In function ÔÇÿconst char* exception_description(const _EXCEPTION_RECORD*, char*, size_t): ..\..\..\libs\context\src\seh.cpp:36:82: warning: format %p expects type void*, but argument 5 has type ULONG_PTR gcc.compile.c++ ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\stack_allocator_windows.o gcc.compile.c++ ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\stack_utils_windows.o gcc.link.dll ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\libboost_context-mgw45-d-1_50.dll.a collect2: ld terminated with signal 6 [Aborted], core dumped Warning: .drectve `/EXPORT:jump_fcontext /EXPORT:make_fcontext 3' unrecognized "c:\cygwin\bin\x86_64-w64-mingw32-g++" "-Wl,--out-implib,..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\libboost_context-mgw45-d-1_50.dll.a" -o "..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\libboost_context-mgw45-d-1_50.dll" -shared -Wl,--start-group "..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\address-model-64\architecture-x86\asm\fcontext_x86_64_ms_pe_masm.o" "..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\fcontext.o" "..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\seh.o" "..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\stack_allocator_windows.o" "..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\stack_utils_windows.o" -Wl,-Bstatic -Wl,-Bdynamic -Wl,--end-group -g ...failed gcc.link.dll ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\libboost_context-mgw45-d-1_50.dll.a ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\libboost_context-mgw45-d-1_50.dll... ...failed updating 2 targets... ...updated 5 targets... Regards Luke.

Am 15.06.2012 18:24, schrieb news.gmane.org:
Any thoughts on the build failure though? Just to clarify: I'm using Cygwin's x86_64-w64-mingw32-g++ GCC and MASM from VS2010. My user-config.jam has:
using gcc : 4.5 : c:\\cygwin\\bin\\x86_64-w64-mingw32-g++ ;
Then compiling with bjam --toolset=gcc from a VS2010 x64 environment:
Performing configuration checks
- 32-bit : no - 64-bit : yes - x86 : yes ...patience... ...found 374 targets... ...updating 7 targets... Jamfile</D:/dev/checkouts/boost-trunk/libs/context/build>.masm64 ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\address-model-64\architecture-x86\asm\fcontext_x86_64_ms_pe_masm.o Assembling: ..\..\..\libs\context\src\asm\fcontext_x86_64_ms_pe_masm.asm Microsoft (R) Macro Assembler (x64) Version 10.00.40219.01 Copyright (C) Microsoft Corporation. All rights reserved.
gcc.compile.c++ ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\fcontext.o gcc.compile.c++ ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\seh.o ..\..\..\libs\context\src\seh.cpp: In function ÔÇÿconst char* exception_description(const _EXCEPTION_RECORD*, char*, size_t): ..\..\..\libs\context\src\seh.cpp:36:82: warning: format %p expects type void*, but argument 5 has type ULONG_PTR gcc.compile.c++ ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\stack_allocator_windows.o gcc.compile.c++ ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\stack_utils_windows.o gcc.link.dll ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\libboost_context-mgw45-d-1_50.dll.a collect2: ld terminated with signal 6 [Aborted], core dumped Warning: .drectve `/EXPORT:jump_fcontext /EXPORT:make_fcontext 3' unrecognized
"c:\cygwin\bin\x86_64-w64-mingw32-g++" "-Wl,--out-implib,..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\libboost_context-mgw45-d-1_50.dll.a" -o "..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\libboost_context-mgw45-d-1_50.dll" -shared -Wl,--start-group "..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\address-model-64\architecture-x86\asm\fcontext_x86_64_ms_pe_masm.o" "..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\fcontext.o" "..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\seh.o" "..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\stack_allocator_windows.o" "..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\stack_utils_windows.o" -Wl,-Bstatic -Wl,-Bdynamic -Wl,--end-group -g
...failed gcc.link.dll ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\libboost_context-mgw45-d-1_50.dll.a ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\libboost_context-mgw45-d-1_50.dll...MS Win64 object format ...failed updating 2 targets... ...updated 5 targets...
maybe the cygwin-linker doesn't like object files in MS Win64 object format (generated by ml64). are you sure that you compile for 64bit (as MASM64 does)? Oliver

On 16/06/2012 09:17, Oliver Kowalke wrote:
Performing configuration checks
- 32-bit : no - 64-bit : yes - x86 : yes ...patience... ...found 374 targets... ...updating 7 targets... Jamfile</D:/dev/checkouts/boost-trunk/libs/context/build>.masm64 ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\address-model-64\architecture-x86\asm\fcontext_x86_64_ms_pe_masm.o
Assembling: ..\..\..\libs\context\src\asm\fcontext_x86_64_ms_pe_masm.asm Microsoft (R) Macro Assembler (x64) Version 10.00.40219.01 Copyright (C) Microsoft Corporation. All rights reserved.
collect2: ld terminated with signal 6 [Aborted], core dumped Warning: .drectve `/EXPORT:jump_fcontext /EXPORT:make_fcontext 3' unrecognized
maybe the cygwin-linker doesn't like object files in MS Win64 object format (generated by ml64).
It doesn't seem to like the whatever the EXPORT keyword is generating... I've attached the patch I mentioned in my original post, in case it's of any use (obviously it breaks everything else as I only touched the Windows assembly). Maybe a def file for jump_fcontext and make_fcontext is a better solution, but how that is done with bjam I don't know. Anyway, with that patch all is well: Performing configuration checks - 32-bit : no - 64-bit : yes - x86 : yes ...patience... ...found 374 targets... ...updating 7 targets... Jamfile</D:/dev/checkouts/boost-trunk/libs/context/build>.masm64 ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\address-model-64\architecture-x86\asm\fcontext_x86_64_ms_pe_masm.o Assembling: ..\..\..\libs\context\src\asm\fcontext_x86_64_ms_pe_masm.asm Microsoft (R) Macro Assembler (x64) Version 10.00.40219.01 Copyright (C) Microsoft Corporation. All rights reserved. gcc.compile.c++ ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\fcontext.o gcc.compile.c++ ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\seh.o gcc.compile.c++ ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\stack_allocator_windows.o gcc.compile.c++ ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\stack_utils_windows.o gcc.link.dll ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\libboost_context-mgw45-d-1_50.dll.a Creating library file: ..\..\..\bin.v2\libs\context\build\gcc-mingw-4.5\debug\libboost_context-mgw45-d-1_50.dll.a ...updated 7 targets... dumpbin /exports libboost_context-mgw45-d-1_50.dll <snip> 10 9 00001626 jump_fcontext 11 A 00001660 make_fcontext Regards Luke.
participants (3)
-
Luke Elliott
-
news.gmane.org
-
Oliver Kowalke