tag 317146 + patch
thanks

I have now tested the patch from Launchpad[0] and can report a partial
success! libgcc works:

        $ i586-mingw32msvc-g++ -shared-libgcc -o shared.exe hi.cpp
        $ i586-mingw32msvc-objdump -p shared.exe | grep 'DLL Name'
                DLL Name: KERNEL32.dll
                DLL Name: msvcrt.dll
                DLL Name: msvcrt.dll
                DLL Name: libgcc_sjlj_1.dll
        $ wine shared.exe
        hi

But libstdc++ does not:

        $ i586-mingw32msvc-g++ -shared-libgcc -o shared.exe hi.cpp -lstdc++_s
        $ i586-mingw32msvc-objdump -p shared.exe | grep 'DLL Name'
                DLL Name: KERNEL32.dll
                DLL Name: msvcrt.dll
                DLL Name: libstdc++_sjlj_6.dll
        $ wine shared.exe 
        wine: Unhandled page fault on read access to 0xfffffff4 at address 
0x6ce4f585 (thread 0009), starting debugger...
        Usage:
                winedbg [ [ --gdb ] [ prog-name [ prog-args ] | <num> | 
file.mdmp | --help ]

I have attached the debdiff (modified to apply to the current package in
Debian) to this message.

I have also attached a test case to demonstrate that the patch works. If
you have the patched mingw32 package installed then you can simply run
'make' and then run both of the generated exe files under wine. Without
the patched package, you can only build the static exe with 'make
main-static.exe'.

[0] https://bugs.launchpad.net/debian/+source/mingw32/+bug/195407

-- 
Sam Morris
https://robots.org.uk/

PGP key id 1024D/5EA01078
3412 EA18 1277 354B 991B  C869 B219 7FDB 5EA0 1078
diff -u mingw32-4.2.1.dfsg/debian/changelog mingw32-4.2.1.dfsg/debian/changelog
--- mingw32-4.2.1.dfsg/debian/changelog
+++ mingw32-4.2.1.dfsg/debian/changelog
@@ -1,3 +1,11 @@
+mingw32 (4.2.1.dfsg-1.1) UNRELEASED; urgency=low
+
+  * Build shared libgcc and libstdc++ libraries. Patch taken from
+    <https://bugs.launchpad.net/ubuntu/+source/mingw32/+bug/195407>; thanks,
+    Michael Hofmann. Closes: #451438.
+
+ -- Michael Hofmann <[email protected]>  Mon, 25 Feb 2008 12:47:05 +0100
+
 mingw32 (4.2.1.dfsg-1) unstable; urgency=low
 
   * New upstream.  Unfortunately this one was a monolithic blob made on a
diff -u mingw32-4.2.1.dfsg/debian/rules mingw32-4.2.1.dfsg/debian/rules
--- mingw32-4.2.1.dfsg/debian/rules
+++ mingw32-4.2.1.dfsg/debian/rules
@@ -68,6 +68,16 @@
 		&& $(MAKE) install prefix=$(top_dir)/debian/$(package)/usr		\
 				   mandir=$(top_dir)/debian/$(package)/usr/share/man
 
+	cd $(build_objs)								\
+		&& $(MAKE) install-shared-libgcc -C gcc					\
+				   prefix=$(top_dir)/debian/$(package)/usr		\
+				   mandir=$(top_dir)/debian/$(package)/usr/share/man
+
+	cd $(build_objs)								\
+		&& $(MAKE) install-shared-libstdc++ -C $(target)/libstdc++-v3		\
+				   prefix=$(top_dir)/debian/$(package)/usr		\
+				   mandir=$(top_dir)/debian/$(package)/usr/share/man
+
 	# remove some non-cross stuff that will clash with other packages
 	# and shuffle things about as required.
 	rm -rf debian/$(package)/usr/include
only in patch2:
unchanged:
--- mingw32-4.2.1.dfsg.orig/debian/patches/01-shared-libgcc-libc++.patch
+++ mingw32-4.2.1.dfsg/debian/patches/01-shared-libgcc-libc++.patch
@@ -0,0 +1,49 @@
+diff -ur gcc-4.2.1-2-dfsg/gcc/config/i386/t-mingw32 gcc-4.2.1-2-dfsg/gcc/config/i386/t-mingw32
+--- gcc-4.2.1-2-dfsg/gcc/config/i386/t-mingw32	2007-08-13 09:48:03.000000000 +0200
++++ gcc-4.2.1-2-dfsg/gcc/config/i386/t-mingw32	2008-02-25 12:41:08.000000000 +0100
+@@ -5,15 +5,15 @@
+ shared-libgcc: libgcc_s.a libgcc_sjlj_1.dll
+ libgcc_s.a libgcc_sjlj_1.dll: libgcc.a
+ 	cp -f libgcc.a libgcc_t.a
+-	$(AR) -d libgcc_t.a _chkstk.o _ctors.o
+-	dlltool --output-def libgcc_s.def --export-all libgcc_t.a	
++	i586-mingw32msvc-ar -d libgcc_t.a _chkstk.o _ctors.o
++	i586-mingw32msvc-dlltool --output-def libgcc_s.def --export-all libgcc_t.a	
+ 	$(GCC_FOR_TARGET)  -shared -fno-exceptions -o libgcc_sjlj_1.dll  -Wl,--out-implib,libgcc_s.a libgcc_s.def libgcc_t.a
+-	$(AR) -r  libgcc_s.a libgcc/_chkstk.o libgcc/_ctors.o
++	i586-mingw32msvc-ar -r  libgcc_s.a libgcc/_chkstk.o libgcc/_ctors.o
+ 	rm -f libgcc_t.a _chkstk.o _ctors.o libgcc_s.def
+ 
+ install-shared-libgcc: installdirs shared-libgcc
+ 	$(INSTALL_DATA) libgcc_s.a $(DESTDIR)$(libsubdir)/
+-	$(INSTALL_PROGRAM) libgcc_sjlj_1.dll $(DESTDIR)$(bindir)/
++	$(INSTALL_DATA) libgcc_sjlj_1.dll $(DESTDIR)$(libsubdir)/
+ 
+ clean-shared-libgcc:
+ 	rm -f libgcc_s.a libgcc_sjlj_1.dll
+diff -ur gcc-4.2.1-2-dfsg/libstdc++-v3/config/os/mingw32/x-mingw32 gcc-4.2.1-2-dfsg/libstdc++-v3/config/os/mingw32/x-mingw32
+--- gcc-4.2.1-2-dfsg/libstdc++-v3/config/os/mingw32/x-mingw32	2007-08-13 09:48:03.000000000 +0200
++++ gcc-4.2.1-2-dfsg/libstdc++-v3/config/os/mingw32/x-mingw32	2008-02-25 12:43:58.000000000 +0100
+@@ -1,17 +1,17 @@
+ shared-libstdc++: src/.libs/libstdc++_sjlj_6.dll src/.libs/libstdc++_s.a
+ src/.libs/libstdc++_sjlj_6.dll src/.libs/libstdc++_s.a: $(libstdc___la_OBJECTS) $(libstdc___la_DEPENDENCIES)
+ 	cp -f src/.libs/libstdc++.a libstdc++_t.a
+-	ar -x libstdc++_t.a tinfo.o tinfo2.o
+-	ar -d libstdc++_t.a tinfo.o tinfo2.o
+-	dlltool --export-all --output-def=libstdc++.def libstdc++_t.a
++	i586-mingw32msvc-ar -x libstdc++_t.a tinfo.o tinfo2.o
++	i586-mingw32msvc-ar -d libstdc++_t.a tinfo.o tinfo2.o
++	i586-mingw32msvc-dlltool --export-all --output-def=libstdc++.def libstdc++_t.a
+ 	$(CC) -shared -shared-libgcc -o  src/.libs/libstdc++_sjlj_6.dll -Wl,--out-implib,src/.libs/libstdc++_s.a \
+ 	  libstdc++.def src/.libs/libstdc++.a
+-	ar -rs src/.libs/libstdc++_s.a tinfo.o tinfo2.o
++	i586-mingw32msvc-ar -rs src/.libs/libstdc++_s.a tinfo.o tinfo2.o
+ 	rm -f libstdc++_t.a tinfo.o tinfo2.o
+ 
+ install-shared-libstdc++: installdirs shared-libstdc++
+ 	$(INSTALL_DATA) src/.libs/libstdc++_s.a $(DESTDIR)$(glibcxx_toolexeclibdir)/
+-	$(INSTALL_PROGRAM) src/.libs/libstdc++_sjlj_6.dll $(DESTDIR)$(bindir)/
++	$(INSTALL_DATA) src/.libs/libstdc++_sjlj_6.dll $(DESTDIR)$(glibcxx_toolexeclibdir)/
+ 
+ clean-shared-libstdc++:
+ 	rm -f src/.libs/libstdc++_sjlj_6.dll src/.libs/libstdc++_s.a

Attachment: mingw-shared-test.tar.gz
Description: application/compressed-tar

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to