Opened 10 years ago

Closed 10 years ago

Last modified 7 years ago

#7287 closed Bugs (wontfix)

[Context] Fix compatability with MinGW

Reported by: joshuadavidson@… Owned by: olli
Milestone: To Be Determined Component: context
Version: Boost 1.52.0 Severity: Problem
Keywords: Cc:

Description

Boost.Context doesn't build correctly on Windows when using MinGW-W64. Luke Elliot, provided a patch that is required.

*EDIT* I am unable to link to the original mailing list post since Trac is flagging the link as spam and is crashing when trying to load captcha so I can verify that I am in fact human. Therefore, I am attaching the patch to this ticket. All credit goes to Luke (thanks man!).

I would also ask that you reconsider the dependency on ml64 if not using MSVC.

Attachments (1)

link-hack.patch (4.7 KB ) - added by joshuadavidson@… 10 years ago.
Patch provided by Luke Elliot to support linking in MinGW

Download all attachments as: .zip

Change History (6)

by joshuadavidson@…, 10 years ago

Attachment: link-hack.patch added

Patch provided by Luke Elliot to support linking in MinGW

comment:1 by viboes, 10 years ago

Component: Nonecontext
Owner: set to olli

comment:2 by Lucas Clemente Vella <lvella@…>, 10 years ago

The patch won't apply in latest trunk, and even if it did, it would probably break other platforms, so it would not be acceptable. Since the issue is with GCC, a better approach would be to provide a specific assembly implementation for MinGW's gnu-as alongside MASM's, to be used when building with GCC. But ideally the issue should be addressed by either MinGW team or MASM team; has this issue been reported to them?

comment:3 by olli, 10 years ago

Resolution: wontfix
Status: newclosed

seems a bug in wingw -> exporting symbols with MASM's EXPORT keyword no handled by mingw

comment:4 by Gilles Mouchard, 7 years ago

Below a patch I apply to boost 1_60_0 to make it compile with mingw (both mingw32 and mingw-w64). It is derived from fedora patches. The patch forces compiling for NT and adds extra assembly directive for gas. The only stuff that doesn't seem to work is exception handling: a throw in a coroutine, for example, invariably results in a call to terminate().

diff -Naur boost_1_60_0/libs/context/build/Jamfile.v2 boost_1_60_0-mingw/libs/context/build/Jamfile.v2
--- boost_1_60_0/libs/context/build/Jamfile.v2	2015-10-21 15:15:01.000000000 +0200
+++ boost_1_60_0-mingw/libs/context/build/Jamfile.v2	2016-03-24 19:15:24.057184520 +0100
@@ -45,10 +45,11 @@
 local rule default_binary_format ( )
 {
     local tmp = elf ;
-    if [ os.name ] = "NT" { tmp = pe ; }
-    else if [ os.name ] = "CYGWIN" { tmp = pe ; }
-    else if [ os.name ] = "AIX" { tmp = xcoff ; }
-    else if [ os.name ] = "MACOSX" { tmp = mach-o ; }
+#     if [ os.name ] = "NT" { tmp = pe ; }
+#     else if [ os.name ] = "CYGWIN" { tmp = pe ; }
+#     else if [ os.name ] = "AIX" { tmp = xcoff ; }
+#     else if [ os.name ] = "MACOSX" { tmp = mach-o ; }
+    tmp = pe ;
     return $(tmp) ;
 }
 
@@ -65,10 +66,11 @@
 local rule default_abi ( )
 {
     local tmp = sysv ;
-    if [ os.name ] = "NT" { tmp = ms ; }
-    else if [ os.name ] = "CYGWIN" { tmp = ms ; }
-    else if [ os.platform ] = "ARM" { tmp = aapcs ; }
-    else if [ os.platform ] = "MIPS" { tmp = o32 ; }
+#     if [ os.name ] = "NT" { tmp = ms ; }
+#     else if [ os.name ] = "CYGWIN" { tmp = ms ; }
+#     else if [ os.platform ] = "ARM" { tmp = aapcs ; }
+#     else if [ os.platform ] = "MIPS" { tmp = o32 ; }
+    tmp = ms ;
     return $(tmp) ;
 }
 
diff -Naur boost_1_60_0/libs/context/src/asm/jump_i386_ms_pe_gas.asm boost_1_60_0-mingw/libs/context/src/asm/jump_i386_ms_pe_gas.asm
--- boost_1_60_0/libs/context/src/asm/jump_i386_ms_pe_gas.asm	2015-10-21 15:15:01.000000000 +0200
+++ boost_1_60_0-mingw/libs/context/src/asm/jump_i386_ms_pe_gas.asm	2016-03-24 19:15:09.683364218 +0100
@@ -138,3 +138,6 @@
 
     /* indirect jump to context */
     jmp  *%edx
+
+.section .drectve
+.ascii " -export:\"jump_fcontext\""
diff -Naur boost_1_60_0/libs/context/src/asm/jump_x86_64_ms_pe_gas.asm boost_1_60_0-mingw/libs/context/src/asm/jump_x86_64_ms_pe_gas.asm
--- boost_1_60_0/libs/context/src/asm/jump_x86_64_ms_pe_gas.asm	2015-10-21 15:15:01.000000000 +0200
+++ boost_1_60_0-mingw/libs/context/src/asm/jump_x86_64_ms_pe_gas.asm	2016-03-24 19:15:16.656277044 +0100
@@ -223,3 +223,6 @@
     /* indirect jump to context */
     jmp  *%r10
 .seh_endproc
+
+.section .drectve
+.ascii " -export:\"jump_fcontext\""
diff -Naur boost_1_60_0/libs/context/src/asm/make_i386_ms_pe_gas.asm boost_1_60_0-mingw/libs/context/src/asm/make_i386_ms_pe_gas.asm
--- boost_1_60_0/libs/context/src/asm/make_i386_ms_pe_gas.asm	2015-10-21 15:15:01.000000000 +0200
+++ boost_1_60_0-mingw/libs/context/src/asm/make_i386_ms_pe_gas.asm	2016-03-24 19:15:30.444104673 +0100
@@ -122,3 +122,6 @@
     hlt
 
 .def	__exit;	.scl	2;	.type	32;	.endef  /* standard C library function */
+
+.section .drectve
+.ascii " -export:\"make_fcontext\""
diff -Naur boost_1_60_0/libs/context/src/asm/make_x86_64_ms_pe_gas.asm boost_1_60_0-mingw/libs/context/src/asm/make_x86_64_ms_pe_gas.asm
--- boost_1_60_0/libs/context/src/asm/make_x86_64_ms_pe_gas.asm	2015-10-21 15:15:01.000000000 +0200
+++ boost_1_60_0-mingw/libs/context/src/asm/make_x86_64_ms_pe_gas.asm	2016-03-24 19:15:38.969998085 +0100
@@ -149,3 +149,6 @@
 .seh_endproc
 
 .def	_exit;	.scl	2;	.type	32;	.endef  /* standard C library function */
+
+.section .drectve
+.ascii " -export:\"make_fcontext\""

in reply to:  4 comment:5 by anonymous, 7 years ago

In fact, throw/catch within a coroutine work with mingw32 (libgcc_s_dw2-1.dll) but not mingw32-w64 (libgcc_s_sjlj-1.dll).

Replying to Gilles Mouchard:

Below a patch I apply to boost 1_60_0 to make it compile with mingw (both mingw32 and mingw-w64). It is derived from fedora patches. The patch forces compiling for NT and adds extra assembly directive for gas. The only stuff that doesn't seem to work is exception handling: a throw in a coroutine, for example, invariably results in a call to terminate().

diff -Naur boost_1_60_0/libs/context/build/Jamfile.v2 boost_1_60_0-mingw/libs/context/build/Jamfile.v2
--- boost_1_60_0/libs/context/build/Jamfile.v2	2015-10-21 15:15:01.000000000 +0200
+++ boost_1_60_0-mingw/libs/context/build/Jamfile.v2	2016-03-24 19:15:24.057184520 +0100
@@ -45,10 +45,11 @@
 local rule default_binary_format ( )
 {
     local tmp = elf ;
-    if [ os.name ] = "NT" { tmp = pe ; }
-    else if [ os.name ] = "CYGWIN" { tmp = pe ; }
-    else if [ os.name ] = "AIX" { tmp = xcoff ; }
-    else if [ os.name ] = "MACOSX" { tmp = mach-o ; }
+#     if [ os.name ] = "NT" { tmp = pe ; }
+#     else if [ os.name ] = "CYGWIN" { tmp = pe ; }
+#     else if [ os.name ] = "AIX" { tmp = xcoff ; }
+#     else if [ os.name ] = "MACOSX" { tmp = mach-o ; }
+    tmp = pe ;
     return $(tmp) ;
 }
 
@@ -65,10 +66,11 @@
 local rule default_abi ( )
 {
     local tmp = sysv ;
-    if [ os.name ] = "NT" { tmp = ms ; }
-    else if [ os.name ] = "CYGWIN" { tmp = ms ; }
-    else if [ os.platform ] = "ARM" { tmp = aapcs ; }
-    else if [ os.platform ] = "MIPS" { tmp = o32 ; }
+#     if [ os.name ] = "NT" { tmp = ms ; }
+#     else if [ os.name ] = "CYGWIN" { tmp = ms ; }
+#     else if [ os.platform ] = "ARM" { tmp = aapcs ; }
+#     else if [ os.platform ] = "MIPS" { tmp = o32 ; }
+    tmp = ms ;
     return $(tmp) ;
 }
 
diff -Naur boost_1_60_0/libs/context/src/asm/jump_i386_ms_pe_gas.asm boost_1_60_0-mingw/libs/context/src/asm/jump_i386_ms_pe_gas.asm
--- boost_1_60_0/libs/context/src/asm/jump_i386_ms_pe_gas.asm	2015-10-21 15:15:01.000000000 +0200
+++ boost_1_60_0-mingw/libs/context/src/asm/jump_i386_ms_pe_gas.asm	2016-03-24 19:15:09.683364218 +0100
@@ -138,3 +138,6 @@
 
     /* indirect jump to context */
     jmp  *%edx
+
+.section .drectve
+.ascii " -export:\"jump_fcontext\""
diff -Naur boost_1_60_0/libs/context/src/asm/jump_x86_64_ms_pe_gas.asm boost_1_60_0-mingw/libs/context/src/asm/jump_x86_64_ms_pe_gas.asm
--- boost_1_60_0/libs/context/src/asm/jump_x86_64_ms_pe_gas.asm	2015-10-21 15:15:01.000000000 +0200
+++ boost_1_60_0-mingw/libs/context/src/asm/jump_x86_64_ms_pe_gas.asm	2016-03-24 19:15:16.656277044 +0100
@@ -223,3 +223,6 @@
     /* indirect jump to context */
     jmp  *%r10
 .seh_endproc
+
+.section .drectve
+.ascii " -export:\"jump_fcontext\""
diff -Naur boost_1_60_0/libs/context/src/asm/make_i386_ms_pe_gas.asm boost_1_60_0-mingw/libs/context/src/asm/make_i386_ms_pe_gas.asm
--- boost_1_60_0/libs/context/src/asm/make_i386_ms_pe_gas.asm	2015-10-21 15:15:01.000000000 +0200
+++ boost_1_60_0-mingw/libs/context/src/asm/make_i386_ms_pe_gas.asm	2016-03-24 19:15:30.444104673 +0100
@@ -122,3 +122,6 @@
     hlt
 
 .def	__exit;	.scl	2;	.type	32;	.endef  /* standard C library function */
+
+.section .drectve
+.ascii " -export:\"make_fcontext\""
diff -Naur boost_1_60_0/libs/context/src/asm/make_x86_64_ms_pe_gas.asm boost_1_60_0-mingw/libs/context/src/asm/make_x86_64_ms_pe_gas.asm
--- boost_1_60_0/libs/context/src/asm/make_x86_64_ms_pe_gas.asm	2015-10-21 15:15:01.000000000 +0200
+++ boost_1_60_0-mingw/libs/context/src/asm/make_x86_64_ms_pe_gas.asm	2016-03-24 19:15:38.969998085 +0100
@@ -149,3 +149,6 @@
 .seh_endproc
 
 .def	_exit;	.scl	2;	.type	32;	.endef  /* standard C library function */
+
+.section .drectve
+.ascii " -export:\"make_fcontext\""
Note: See TracTickets for help on using tickets.