06 October 2014

How to enable GCC i686-w64-mingw32 multilib

I always opt i686-w64-mingw32 multilib when building GCC. That mean 32bit by default and 64bit via -m64. in GCC 4.9 (or since GCC 4.8 SEH introduction) this configuration seems to be broken / unsupported. By common sense if x86_64 multilib is supported then the inverse should be possible too.

Here is the patch:

--- D:/Tarball/gcc49s/libgcc/config.host.bak Thu Mar 27 22:40:31 2014
+++ D:/Tarball/gcc49s/libgcc/config.host Sun Sep 28 14:24:20 2014
@@ -646,8 +646,20 @@
  if test x$enable_sjlj_exceptions = xyes; then
-  tmake_eh_file="i386/t-dw2-eh"
-  md_unwind_header=i386/w32-unwind.h
+  case ${host} in
+    i[34567]86-w64-mingw*)
+      if [ "${enable_multilib}" = yes ]; then
+        tmake_eh_file="i386/t-seh-eh"
+      else
+        tmake_eh_file="i386/t-dw2-eh"
+        md_unwind_header=i386/w32-unwind.h
+      fi
+      ;;
+    i[34567]86-pc-mingw*)
+      tmake_eh_file="i386/t-dw2-eh"
+      md_unwind_header=i386/w32-unwind.h
+      ;;
+  esac
  # Shared libgcc DLL install dir depends on cross/native build.
  if test x${build} = x${host} ; then

Might be a bit ugly but still make sense and works! Overall that's just a naming/convention mess. With the patch we should have SJLJ in 32bit and SEH exception in 64bit mode by default (a.k.a no exception handling specified at configure).


  1. How to build mingw core with msvcr90 or msvcr100.dll dependency(instead msvcrt.dll)? I want mingw produced dlls to use chosen msvcrXXX.dll runtime(to avoid possible crashes/bugs).

    1. I would like to post about it as part Moluccas continuation...but it still put on hold because GCC 4.8 and later has broken LTO and I don't wish such huge regression at the cost of newer features for the next Moluccas...

      by the way GCC 4.9 has rudimentary "default manifest" for non-specific purpose that help msvcr90/msvcr80 target, see gcc\config\i386\mingw32.h file.