Dave Korn wrote:

I've been having some trouble building gcc 4.0.1 for mips target on a
mingw host

 No you aren't.  You're using a modified version of the gcc-4.0.1 sources
and you're targetting PSP.  That may be a MIPS backend, but it's a different
_target_.

:) fair enough, the patches are currently minimal for gcc though.

 Hmm.  Perhaps we have HOST_WIDE_INT problems for mingw host here?  If
cfun->machine->frame.var_size was a long long, and HOST_WIDE_INT_PRINT_DEC
for mingw is just "%d" or "%ld" rather than "%lld", that would push an extra
NULL word onto the stack that would be taken as the parameter for %s because
the "%d" wouldn't be advancing the varargs pointer past the whole of the
second format arg...

And that's exactly the problem.

in /gcc/config/i386/xm-mingw32.h we have

/* MSVCRT does not support the "ll" format specifier for printing
  "long long" values.  Instead, we use "I64".  */
#define HOST_LONG_LONG_FORMAT "I64"

then in gcc/hwint.h we have

/* The string that should be inserted into a printf style format to
  indicate a "long long" operand.  */
#ifndef HOST_LONG_LONG_FORMAT
#define HOST_LONG_LONG_FORMAT "ll"
#endif


and later in the same file

#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
# define HOST_WIDE_INT_PRINT "l"
# define HOST_WIDE_INT_PRINT_C "L"
 /* 'long' might be 32 or 64 bits, and the number of leading zeroes
    must be tweaked accordingly.  */
# if HOST_BITS_PER_WIDE_INT == 64
#  define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%016lx"
# else
#  define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%08lx"
# endif
#else
# define HOST_WIDE_INT_PRINT "ll"
# define HOST_WIDE_INT_PRINT_C "LL"
 /* We can assume that 'long long' is at least 64 bits.  */
# define HOST_WIDE_INT_PRINT_DOUBLE_HEX \
   "0x%" HOST_LONG_LONG_FORMAT "x%016" HOST_LONG_LONG_FORMAT "x"
#endif /* HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG */

so the HOST_WIDE_INT_PRINT ignores the mingw override.

I've currently patched as follows

diff -Naurb gcc-4.0.1/gcc/hwint.h gcc-4.0.1-new/gcc/hwint.h
--- gcc-4.0.1/gcc/hwint.h    Wed Nov 24 04:31:57 2004
+++ gcc-4.0.1-new/gcc/hwint.h    Thu Jul 21 14:37:06 2005
@@ -80,7 +80,7 @@
#  define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%08lx"
# endif
#else
-# define HOST_WIDE_INT_PRINT "ll"
+# define HOST_WIDE_INT_PRINT HOST_LONG_LONG_FORMAT
# define HOST_WIDE_INT_PRINT_C "LL"
  /* We can assume that 'long long' is at least 64 bits.  */
# define HOST_WIDE_INT_PRINT_DOUBLE_HEX \

This works for me and allows the build to complete. I'm not currently sure if HOST_WIDE_INT_PRINT_C needs similar treatment.

I've created PR22594 - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22594

Many thanks.

Dave

Reply via email to