build: Tell .NET compiler to target the generated assemblies to 32-bit

The default value for the "platform" parameter is anycpu, which allows
the runtime to use the 64-bit mode on x86_64. This means that any
P/Invoke will only work with 64-bit native libraries.

The recommended version of native Windows binaries provided by the GTK+
project are 32-bit, so a Gtk# app running on 64-bit Windows will fail to
load them, causing a BadImageFormatException at runtime.

Using "-platform:x86" instructs the csc compiler to set a flag in the
generated assembly that instructs the runtime to use only 32-bit mode.

Please note that there are 64-bit GTK+ Windows binaries, but they are
marked as experimental, and we probably don't want explore this right
now.

Also pass the "nologo" parameter so that it doesn't output several
useless line when it is invoked.
This commit is contained in:
Bertrand Lorentz 2014-02-23 17:53:07 +01:00
parent a531510431
commit 398dc4aaf7

View file

@ -140,6 +140,7 @@ dnl End of has_mono = true
else else
dnl Check for .NET Framework dnl Check for .NET Framework
AC_PATH_PROG(CSC, csc.exe, no) AC_PATH_PROG(CSC, csc.exe, no)
CSFLAGS="-nologo -platform:x86"
GACUTIL_FLAGS= GACUTIL_FLAGS=
GENERATED_SOURCES=generated\\\\*.cs GENERATED_SOURCES=generated\\\\*.cs
AM_CONDITIONAL(ENABLE_THREADCHECK, false) AM_CONDITIONAL(ENABLE_THREADCHECK, false)
@ -174,14 +175,15 @@ PKG_CHECK_MODULES(GIO, gio-2.0 >= $GLIB_REQUIRED_VERSION)
AC_SUBST(GIO_CFLAGS) AC_SUBST(GIO_CFLAGS)
AC_SUBST(GIO_LIBS) AC_SUBST(GIO_LIBS)
CSFLAGS="$DEBUG_FLAGS $WIN64DEFINES" CSFLAGS="$CSFLAGS $DEBUG_FLAGS $WIN64DEFINES"
AC_SUBST(CSFLAGS)
PKG_CHECK_MODULES(GLIB_2_31, PKG_CHECK_MODULES(GLIB_2_31,
glib-2.0 >= 2.31, glib-2.0 >= 2.31,
HAVE_GLIB_2_31_OR_HIGHER=yes, HAVE_GLIB_2_31_OR_HIGHER=no) HAVE_GLIB_2_31_OR_HIGHER=yes, HAVE_GLIB_2_31_OR_HIGHER=no)
if test "x$HAVE_GLIB_2_31_OR_HIGHER" = "xno" ; then if test "x$HAVE_GLIB_2_31_OR_HIGHER" = "xno" ; then
CSFLAGS="$CSFLAGS -define:ENABLE_GTHREAD_INIT" CSFLAGS="$CSFLAGS -define:ENABLE_GTHREAD_INIT"
fi fi
AC_SUBST(CSFLAGS)
PKG_CHECK_MODULES(PANGO, pango) PKG_CHECK_MODULES(PANGO, pango)
AC_SUBST(PANGO_CFLAGS) AC_SUBST(PANGO_CFLAGS)