Building PS2 Toolchains In MinGW

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

ragnarok2040
Posts: 202
Joined: Wed Aug 09, 2006 1:00 am

Post by ragnarok2040 »

I have the archlinux distro installed on my other harddrive, so I could just go into that if it becomes necessary.

The Ogre3D MinGW Toolkit didn't work when compiling the toolchain, either. I'll go digging around.

I managed to grab a log of all the warning messages when building gcc. Perhaps something in there will lead to the answer. I haven't built a toolchain on cygwin in forever, but I don't remember getting those Assembler messages, so maybe the problem lies in gas in binutils? I get those Assembler messages while building FCEUltra as well on the MinGW toolchain but not on the Cygwin toolchain.

http://www.nopaste.com/p/aS6aNJ42V

I tried changing 1 in the GIF_TAG to 1UL, but the shift was still ignored.
radad
Posts: 246
Joined: Wed May 19, 2004 4:54 pm
Location: Melbourne, Australia

Post by radad »

This really only confirms what has already been said but with this program:

Code: Select all

#include <stdio.h>

int main&#40;int argc, char* argv&#91;&#93;&#41;
&#123;
    u64 st = &#40;&#40;&#40;u64&#41;&#40;1&#41;&#41;	<< 32&#41;;
    printf&#40;"test = 0x%016lX\n", st&#41;;
    return 0;
&#125;
I get this output from cygwin:

Code: Select all

00000000 <main>&#58;
   0&#58;	3c040000 	lui	a0,0x0
   4&#58;	27bdfff0 	addiu	sp,sp,-16
   8&#58;	34058000 	li	a1,0x8000
   c&#58;	00052c78 	dsll	a1,a1,0x11
  10&#58;	ffbf0000 	sd	ra,0&#40;sp&#41;
  14&#58;	0c000000 	jal	0 <main>
  18&#58;	24840000 	addiu	a0,a0,0
  1c&#58;	dfbf0000 	ld	ra,0&#40;sp&#41;
  20&#58;	0000102d 	move	v0,zero
  24&#58;	03e00008 	jr	ra
  28&#58;	27bd0010 	addiu	sp,sp,16
  2c&#58;	00000000 	nop
And this output from mingw:

Code: Select all

00000000 <main>&#58;
   0&#58;	3c040000 	lui	a0,0x0
   4&#58;	27bdfff0 	addiu	sp,sp,-16
   8&#58;	24050000 	li	a1,0
   c&#58;	ffbf0000 	sd	ra,0&#40;sp&#41;
  10&#58;	0c000000 	jal	0 <main>
  14&#58;	24840000 	addiu	a0,a0,0
  18&#58;	dfbf0000 	ld	ra,0&#40;sp&#41;
  1c&#58;	0000102d 	move	v0,zero
  20&#58;	03e00008 	jr	ra
  24&#58;	27bd0010 	addiu	sp,sp,16
Interestingly though this program gives the correct output in both compilers:

Code: Select all

#include <stdio.h>

int main&#40;int argc, char* argv&#91;&#93;&#41;
&#123;
    int i;
    u64 u;
    
    for &#40;i = 0; i < 64; ++i&#41;
    &#123;
        u = &#40;&#40;u64&#41; &#40;1&#41; << i&#41;;
        printf&#40;"0x%016lX\n", u&#41;;
    &#125;
    
    return 0;
&#125;
So it appears that it is only shifts expanded by the compiler to a constant which causes the problem.
ragnarok2040
Posts: 202
Joined: Wed Aug 09, 2006 1:00 am

Post by ragnarok2040 »

I've found the parts in gcc where it starts type checking the operands, type conversion, and etc. I've started adding warning messages inside the conditional statements to see how exactly the left shift expression is evaluated. I'll post the relevant files/lines I think are interesting in case someone else wants to go through it themselves. I'm pretty sure the assembly generated is correct depending on what operands gcc gives out, so I don't think the problem lies in mips.md or etc.

mips.c line 2680
mips_move_2words is what I believe gcc calls when moving the bits for the shift

c-typeck.c line 2139
This is where gcc typechecks the operands prior to compiling the leftshift.

convert.c line 228
I'm not exactly sure here, as the code relies heavily on tree nodes and such, but I think this is where it optimizes/truncates leftshifts. I'm pretty sure 32 passes the first if statement. I haven't gone through after that.

Edit:
op1 passes the typecheck, but I'm not sure if it's actually describing 32 or another number, like 0. Nothing triggered under the LSHIFT_EXPR case in convert.c. I forgot to check about integer constants though.

Doc on gcc internals:
http://gcc.gnu.org/onlinedocs/gccint/index.html
radad
Posts: 246
Joined: Wed May 19, 2004 4:54 pm
Location: Melbourne, Australia

Post by radad »

Not sure how relevant this is but this program:

Code: Select all

#include <stdio.h>

typedef unsigned long long	u64;

int main&#40;int argc, char* argv&#91;&#93;&#41;
&#123;
    u64 st = &#40;&#40;&#40;u64&#41;&#40;1&#41;&#41;   << 32&#41;;
    printf&#40;"test = 0x%016lX\n", st&#41;;
    return 0;
&#125;
fails under mingw itself (nothing to do with ps2 stuff). It did give a warning for the printf - is that format string correct?
ragnarok2040
Posts: 202
Joined: Wed Aug 09, 2006 1:00 am

Post by ragnarok2040 »

Code: Select all

#include <stdio.h>

typedef unsigned long long   u64;

int main&#40;int argc, char* argv&#91;&#93;&#41;
&#123;
    u64 st = &#40;&#40;&#40;u64&#41;&#40;1&#41;&#41;   << 32&#41;;
    //printf&#40;"test = %ulld\n", st&#41;;
    printf&#40;"%I64u\n",st&#41;;
    return 0;
&#125;
%llu which is normally used to print long long unsigned (64-bit) integers on unix/posix systems prints out 0. MingW uses the msvcrt.dll printf() which uses %I64u to print 64-bit unsigned integers. The shift is still occurring, though. I'm pretty sure that this wouldn't have an effect when compiling a cross-compiler though... unless for some odd reason, there was a test or conversion or something that relied on a msvcrt function or the msvcrt string format modifier for 64-bit integers...

http://www.mingw.org/MinGWiki/index.php/long%20long

Edit:
It is pretty strange that the problem of %llu simulates what we're getting from the shift, 0. I notice a lot of strings used for outputting the assembly, with format modifiers like %M %H %L, which I'll have to look up to see if these have a problem. Since, we're compiling the compiler as a windows runtime, I'm pretty sure these format modifiers would get compiled using the msvcrt format, though I'm not sure if just any string does. I'm going to look at the file that defines format modifiers for the host of a cross compiler to see if it has %ll defined somewhere.

Edit2:
Just found this, which explains the above, I believe.
http://www.gnu.org/software/gettext/man ... 002dformat

Edit3:
I'm going to try to define the msvcrt format modifiers to the mingw32 host file: gcc-3.2.2\gcc\config\i386\xm-mingw32.h, and see if it works...

Edit4:
Ok, I've compiled gcc with the new format modifiers, but the shift still doesn't happen. I didn't start from scratch, so I'll see if binutils needs fixing for mingw32, then add the changes to gcc and compile again.

Edit5:
Here's my modified hwint.h: http://rafb.net/p/xypRNP40.html
It would probably be easier defining them in xm-mingw32.h but this works as well. I've gotten to the newlib stage, and installed it. Compiled the val64.c program with the ps2sdk from cygwin, and it's shifting correctly. I take this as a good sign.

Edit6:
Sorry for all the edits, but the mingw toolchain is now working correctly. Thanks, radad ^_^, I wouldn't have guessed a gnu toolchain would use non-ISO format modifiers. Anything long long would return 0 inside a string like for code inside an object file or assembly but since 0 is an integer it wouldn't look wrong. All you need to do is plugin hwint.h above, or define the macros with "%I64" with HOST_WIDEST_INT __int64; in gcc/config/xm-mingw32.h. After doing that, configuring gcc noticeably took a little longer. In binutils-2.14, I also added two lines in _doprnt.c after line 291 to check %I64d. I don't think it changed anything in binutils, though.
Last edited by ragnarok2040 on Wed Jul 25, 2007 10:01 pm, edited 1 time in total.
User avatar
Lukasz
Posts: 248
Joined: Mon Jan 19, 2004 8:37 pm
Location: Denmark
Contact:

Post by Lukasz »

ragnarok2040 & radad: Good work figuring this out and providing a solution!

ragnarok2040: You mention something about patching the gcc source (xm-mingw.h) in order to build the toolchains in mingw correctly. Could you supply a full patch for gcc? Then we could add this to the existing ps2 gcc patch and avoid having additional instructions for building the toolchains in MinGW.
ragnarok2040
Posts: 202
Joined: Wed Aug 09, 2006 1:00 am

Post by ragnarok2040 »

Ok, I will, shouldn't take that long. Be back in a few.

Edit:
Here it is: http://nopaste.de/p/aL0jnueIB
Did you want me to submit just the patch for xm-mingw32.h? I posted the whole thing :S.

Oh yeah, before I forget, adding those definitions made configure act a little weird, like it was adding fastjar and gcc/f (the fortran frontend) to the build. After configuring again, it stopped, so maybe I left a dash or something out somewhere. Fixinc might work again... I saw it build during the stage2 build, anyways.

Edit:
http://jul25b.imghost.us/MTrI.bmp
^_^
ooPo
Site Admin
Posts: 2023
Joined: Sat Jan 17, 2004 9:56 am
Location: Canada
Contact:

Post by ooPo »

Nice work, but I'm having troubles with the patch. I don't like to replace the entire patch with a new one like this and it isn't applying cleanly anyway.

Can you generate a patch against gcc that's already had the ps2dev patch applied? It is a lot easier to see what's changed.
ragnarok2040
Posts: 202
Joined: Wed Aug 09, 2006 1:00 am

Post by ragnarok2040 »

Hrmm, somehow a copy of the rev1.patch got placed in the newer source folder and diff added it to the patch. Here's the patch just comparing the old ps2dev patched gcc vs. gcc patched + my changes.

Code: Select all

diff -burN gcc-3.2.2/gcc/config/i386/xm-mingw32.h gcc-3.2.2-ps2/gcc/config/i386/xm-mingw32.h
--- gcc-3.2.2/gcc/config/i386/xm-mingw32.h	Thu Jan 10 17&#58;21&#58;39 2002
+++ gcc-3.2.2-ps2/gcc/config/i386/xm-mingw32.h	Wed Jul 25 08&#58;20&#58;51 2007
@@ -31,3 +31,8 @@
 
 #undef PATH_SEPARATOR
 #define PATH_SEPARATOR ';'
+
+#define HOST_WIDEST_INT __int64
+#define HOST_WIDEST_INT_PRINT_DEC "%I64d"
+#define HOST_WIDEST_INT_PRINT_UNSIGNED "%I64u"
+#define HOST_WIDEST_INT_PRINT_HEX "0x%I64x"
http://rafb.net/p/Fg99OW72.html

Here's the whole thing again, this time making sure that a patch wasn't hiding somewhere in it. This doesn't fix long doubles, but I don't think the PS2 can use them. I remember reading that somewhere.

Binaries of the tools, doesn't include ps2sdk's crt0.o:
http://www.usaupload.net/d/t057vv6aukn
radad
Posts: 246
Joined: Wed May 19, 2004 4:54 pm
Location: Melbourne, Australia

Post by radad »

Great work guys.
ooPo
Site Admin
Posts: 2023
Joined: Sat Jan 17, 2004 9:56 am
Location: Canada
Contact:

Post by ooPo »

Code: Select all

gcc-3.2.2$ cat /tmp/patch.txt | patch -p1 --dry-run
patching file README.PS2
patching file config.sub
patching file configure
patching file configure.in
patching file gcc/Makefile.in
patching file gcc/c-common.c
patching file gcc/caller-save.c
patching file gcc/config/i386/xm-mingw32.h
patching file gcc/config/mips/core-mmi.h
patching file gcc/config/mips/core-vumm.h
patching file gcc/config/mips/crti5900.asm
patching file gcc/config/mips/crtn5900.asm
patching file gcc/config/mips/mips-protos.h
patching file gcc/config/mips/mips.c
Hunk #10 succeeded at 518 with fuzz 2.
Hunk #36 FAILED at 6535.
1 out of 58 hunks FAILED -- saving rejects to file gcc/config/mips/mips.c.rej
patching file gcc/config/mips/mips.h
Hunk #37 succeeded at 4397 with fuzz 2 &#40;offset 339 lines&#41;.
Hunk #38 FAILED at 4446.
Hunk #39 FAILED at 4602.
Hunk #40 FAILED at 4620.
3 out of 45 hunks FAILED -- saving rejects to file gcc/config/mips/mips.h.rej
patching file gcc/config/mips/mips.md
Hunk #15 FAILED at 510.
Hunk #49 succeeded at 4471 with fuzz 2 &#40;offset 1186 lines&#41;.
Hunk #50 FAILED at 4522.
Hunk #51 FAILED at 4576.
Hunk #52 FAILED at 4594.
Hunk #53 FAILED at 4648.
Hunk #54 succeeded at 4768 with fuzz 2 &#40;offset 1170 lines&#41;.
Hunk #55 FAILED at 4895.
Hunk #56 FAILED at 4997.
Hunk #57 FAILED at 5122.
Hunk #58 FAILED at 5174.
Hunk #59 FAILED at 5627.
Hunk #60 FAILED at 5853.
11 out of 88 hunks FAILED -- saving rejects to file gcc/config/mips/mips.md.rej
patching file gcc/config/mips/r5900.h
patching file gcc/config/mips/t-irx
patching file gcc/config/mips/t-r5900
patching file gcc/config.gcc
patching file gcc/cp/decl.c
patching file gcc/fixinc/gnu-regex.c
patching file gcc/fixinc/mkfixinc.sh
patching file gcc/glimits.h
patching file gcc/integrate.c
patching file gcc/libgcc2-timode.c
patching file gcc/mklibgcc.in
patching file gcc/toplev.c
patching file include/obstack.h
patching file libstdc++-v3/configure.target
patching file libstdc++-v3/libsupc++/pure.cc
Playing with it, I get this:

Code: Select all

diff -burN ps2dev.gcc-3.2.2/gcc/config/i386/xm-mingw32.h gcc-3.2.2/gcc/config/i386/xm-mingw32.h
--- ps2dev.gcc-3.2.2/gcc/config/i386/xm-mingw32.h       2002-01-10 18&#58;21&#58;39.000000000 -0400
+++ gcc-3.2.2/gcc/config/i386/xm-mingw32.h      2007-07-26 03&#58;59&#58;05.000000000 -0300
@@ -31,3 +31,8 @@
 
 #undef PATH_SEPARATOR
 #define PATH_SEPARATOR ';'
+
+#define HOST_WIDEST_INT __int64
+#define HOST_WIDEST_INT_PRINT_DEC "%I64d"
+#define HOST_WIDEST_INT_PRINT_UNSIGNED "%I64u"
+#define HOST_WIDEST_INT_PRINT_HEX "0x%I64x"
I don't suppose this a valid description of your changes?
ragnarok2040
Posts: 202
Joined: Wed Aug 09, 2006 1:00 am

Post by ragnarok2040 »

The site on which I pasted the patch must be messing up something or maybe windows clipboard is doing it.

Ack, I forgot to define HOST_BITS_PER_WIDEST_INT as well, so the build errors out. It didn't need to be defined in hwint.h as HOST_WIDEST_INT hadn't been defined yet, but it's needed in xm-mingw32.h.

I'll have to make a new patch and test again.

Edit:
I ran into the shift bug again. Replacing hwint.h with the one I posted above fixes it. I think I see the problem...

Code: Select all

/* Use long long on the host if the target has a wider long type than
   the host.  */
Since the code after that would be true, then I probably have to define the HOST_WIDE_INT stuff the same as HOST_WIDEST_INT...

Edit2:
I just compiled gcc with xm-mingw32.h with HOST_WIDE_INT stuff defined plus the normal hwint.h and it's working again. I should've read the comments in hwint.h more closely.

Includes just the xm-mingw32.h patch as well as the full gcc-3.2.2-PS2+xm-mingw32.h patch.

Edit3:
Sorry about all the trouble with the patches. My first time submitting one, heh. I'm 99.9% sure I've #defined everything correctly. Migrating the changes was more convoluted than I thought it would be.

Edit4:
That .1% hit me. Just realized that those macros would affect the iop toolchain. I added some checks, but now it's not shifting correctly again. I'm going to just paste the code from hwint.h into xm-mingw32 and recompile again to see if that will work.

Code: Select all

diff -burN orig.gcc-3.2.2/gcc/config/i386/xm-mingw32.h gcc-3.2.2/gcc/config/i386/xm-mingw32.h
--- orig.gcc-3.2.2/gcc/config/i386/xm-mingw32.h	Thu Jan 10 17&#58;21&#58;39 2002
+++ gcc-3.2.2/gcc/config/i386/xm-mingw32.h	Thu Jul 26 10&#58;00&#58;22 2007
@@ -31,3 +31,143 @@
 
 #undef PATH_SEPARATOR
 #define PATH_SEPARATOR ';'
+
+/* This describes the machine the compiler is hosted on.  */
+#define HOST_BITS_PER_CHAR  CHAR_BIT
+#define HOST_BITS_PER_SHORT &#40;CHAR_BIT * SIZEOF_SHORT&#41;
+#define HOST_BITS_PER_INT   &#40;CHAR_BIT * SIZEOF_INT&#41;
+#define HOST_BITS_PER_LONG  &#40;CHAR_BIT * SIZEOF_LONG&#41;
+
+#ifdef HAVE_LONG_LONG
+# define HOST_BITS_PER_LONGLONG &#40;CHAR_BIT * SIZEOF_LONG_LONG&#41;
+#else
+#ifdef HAVE___INT64
+# define HOST_BITS_PER_LONGLONG &#40;CHAR_BIT * SIZEOF___INT64&#41;
+#else
+/* If we're here and we're GCC, assume this is stage 2+ of a bootstrap
+   and 'long long' has the width of the *target*'s long long.  */
+# if GCC_VERSION > 3000
+#  define HOST_BITS_PER_LONGLONG LONG_LONG_TYPE_SIZE
+# endif /* gcc */
+#endif
+#endif /* no long long */
+
+/* Find the largest host integer type and set its size and type.  */
+
+/* Use long long on the host if the target has a wider long type than
+   the host.  */
+
+#if ! defined HOST_BITS_PER_WIDE_INT \
+    && defined HOST_BITS_PER_LONGLONG \
+    && &#40;HOST_BITS_PER_LONGLONG > HOST_BITS_PER_LONG&#41; \
+    && &#40;defined &#40;LONG_LONG_MAX&#41; || defined &#40;LONGLONG_MAX&#41; \
+        || defined &#40;LLONG_MAX&#41; || defined &#40;__GNUC__&#41;&#41;
+
+# ifdef MAX_LONG_TYPE_SIZE
+#  if MAX_LONG_TYPE_SIZE > HOST_BITS_PER_LONG
+#   define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONGLONG
+#   define HOST_WIDE_INT long long
+#  endif
+# else
+#  if LONG_TYPE_SIZE > HOST_BITS_PER_LONG
+#   define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONGLONG
+#   define HOST_WIDE_INT long long
+#  endif
+# endif
+
+#endif
+
+#ifndef HOST_BITS_PER_WIDE_INT
+
+# if HOST_BITS_PER_LONG > HOST_BITS_PER_INT
+#  define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG
+#  define HOST_WIDE_INT long
+# else
+#  define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_INT
+#  define HOST_WIDE_INT int
+# endif
+
+#endif /* ! HOST_BITS_PER_WIDE_INT */
+
+/* Provide defaults for the way to print a HOST_WIDE_INT
+   in various manners.  */
+
+#ifndef HOST_WIDE_INT_PRINT_DEC
+# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
+#  define HOST_WIDE_INT_PRINT_DEC "%d"
+# else
+#  if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
+#   define HOST_WIDE_INT_PRINT_DEC "%ld"
+#  else
+#   define HOST_WIDE_INT_PRINT_DEC "%I64d"
+#  endif
+# endif
+#endif /* ! HOST_WIDE_INT_PRINT_DEC */
+
+#ifndef HOST_WIDE_INT_PRINT_UNSIGNED
+# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
+#  define HOST_WIDE_INT_PRINT_UNSIGNED "%u"
+# else
+#  if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
+#   define HOST_WIDE_INT_PRINT_UNSIGNED "%lu"
+#  else
+#   define HOST_WIDE_INT_PRINT_UNSIGNED "%I64u"
+#  endif
+# endif
+#endif /* ! HOST_WIDE_INT_PRINT_UNSIGNED */
+
+#ifndef HOST_WIDE_INT_PRINT_HEX
+# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
+#  define HOST_WIDE_INT_PRINT_HEX "0x%x"
+# else
+#  if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
+#   define HOST_WIDE_INT_PRINT_HEX "0x%lx"
+#  else
+#   define HOST_WIDE_INT_PRINT_HEX "0x%I64x"
+#  endif
+# endif
+#endif /* ! HOST_WIDE_INT_PRINT_HEX */
+
+#ifndef HOST_WIDE_INT_PRINT_DOUBLE_HEX
+# if HOST_BITS_PER_WIDE_INT == 64
+#  if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
+#   define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%x%016x"
+#  else
+#   if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
+#    define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%016lx"
+#   else
+#    define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%llx%016llx"
+#   endif
+#  endif
+# else
+#  if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
+#   define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%x%08x"
+#  else
+#   if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
+#    define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%08lx"
+#   else
+#    define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%llx%08llx"
+#   endif
+#  endif
+# endif
+#endif /* ! HOST_WIDE_INT_PRINT_DOUBLE_HEX */
+
+/* Find HOST_WIDEST_INT and set its bit size, type and print macros.
+   It will be the largest integer mode supported by the host which may
+   &#40;or may not&#41; be larger than HOST_WIDE_INT.  */
+
+#ifndef HOST_WIDEST_INT
+#if defined HOST_BITS_PER_LONGLONG && HOST_BITS_PER_LONGLONG > HOST_BITS_PER_LONG
+#   define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONGLONG
+#   define HOST_WIDEST_INT __int64
+#   define HOST_WIDEST_INT_PRINT_DEC "%I64d"
+#   define HOST_WIDEST_INT_PRINT_UNSIGNED "%I64u"
+#   define HOST_WIDEST_INT_PRINT_HEX "0x%I64x"
+#  else
+#   define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONG
+#   define HOST_WIDEST_INT long
+#   define HOST_WIDEST_INT_PRINT_DEC "%ld"
+#   define HOST_WIDEST_INT_PRINT_UNSIGNED "%lu"
+#   define HOST_WIDEST_INT_PRINT_HEX "0x%lx"
+# endif /* long long wider than long */
+#endif /* ! HOST_WIDEST_INT */
It worked. I made sure. I uploaded the final version:
http://www.usaupload.net/d/koupz4obi6o
ooPo
Site Admin
Posts: 2023
Joined: Sat Jan 17, 2004 9:56 am
Location: Canada
Contact:

Post by ooPo »

The patch applied cleanly and has been added to the repository:

Code: Select all

Sending        patches/gcc-3.2.2-PS2.patch
Transmitting file data .
Committed revision 1428.
For the curious, here's what has changed:

Code: Select all

diff -burN ps2dev.gcc-3.2.2/gcc/config/i386/xm-mingw32.h gcc-3.2.2/gcc/config/i386/xm-mingw32.h
--- ps2dev.gcc-3.2.2/gcc/config/i386/xm-mingw32.h	2002-01-10 18&#58;21&#58;39.000000000 -0400
+++ gcc-3.2.2/gcc/config/i386/xm-mingw32.h	2007-07-26 13&#58;02&#58;44.000000000 -0300
@@ -31,3 +31,143 @@
 
 #undef PATH_SEPARATOR
 #define PATH_SEPARATOR ';'
+
+/* This describes the machine the compiler is hosted on.  */
+#define HOST_BITS_PER_CHAR  CHAR_BIT
+#define HOST_BITS_PER_SHORT &#40;CHAR_BIT * SIZEOF_SHORT&#41;
+#define HOST_BITS_PER_INT   &#40;CHAR_BIT * SIZEOF_INT&#41;
+#define HOST_BITS_PER_LONG  &#40;CHAR_BIT * SIZEOF_LONG&#41;
+
+#ifdef HAVE_LONG_LONG
+# define HOST_BITS_PER_LONGLONG &#40;CHAR_BIT * SIZEOF_LONG_LONG&#41;
+#else
+#ifdef HAVE___INT64
+# define HOST_BITS_PER_LONGLONG &#40;CHAR_BIT * SIZEOF___INT64&#41;
+#else
+/* If we're here and we're GCC, assume this is stage 2+ of a bootstrap
+   and 'long long' has the width of the *target*'s long long.  */
+# if GCC_VERSION > 3000
+#  define HOST_BITS_PER_LONGLONG LONG_LONG_TYPE_SIZE
+# endif /* gcc */
+#endif
+#endif /* no long long */
+
+/* Find the largest host integer type and set its size and type.  */
+
+/* Use long long on the host if the target has a wider long type than
+   the host.  */
+
+#if ! defined HOST_BITS_PER_WIDE_INT \
+    && defined HOST_BITS_PER_LONGLONG \
+    && &#40;HOST_BITS_PER_LONGLONG > HOST_BITS_PER_LONG&#41; \
+    && &#40;defined &#40;LONG_LONG_MAX&#41; || defined &#40;LONGLONG_MAX&#41; \
+        || defined &#40;LLONG_MAX&#41; || defined &#40;__GNUC__&#41;&#41;
+
+# ifdef MAX_LONG_TYPE_SIZE
+#  if MAX_LONG_TYPE_SIZE > HOST_BITS_PER_LONG
+#   define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONGLONG
+#   define HOST_WIDE_INT long long
+#  endif
+# else
+#  if LONG_TYPE_SIZE > HOST_BITS_PER_LONG
+#   define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONGLONG
+#   define HOST_WIDE_INT long long
+#  endif
+# endif
+
+#endif
+
+#ifndef HOST_BITS_PER_WIDE_INT
+
+# if HOST_BITS_PER_LONG > HOST_BITS_PER_INT
+#  define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG
+#  define HOST_WIDE_INT long
+# else
+#  define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_INT
+#  define HOST_WIDE_INT int
+# endif
+
+#endif /* ! HOST_BITS_PER_WIDE_INT */
+
+/* Provide defaults for the way to print a HOST_WIDE_INT
+   in various manners.  */
+
+#ifndef HOST_WIDE_INT_PRINT_DEC
+# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
+#  define HOST_WIDE_INT_PRINT_DEC "%d"
+# else
+#  if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
+#   define HOST_WIDE_INT_PRINT_DEC "%ld"
+#  else
+#   define HOST_WIDE_INT_PRINT_DEC "%I64d"
+#  endif
+# endif
+#endif /* ! HOST_WIDE_INT_PRINT_DEC */
+
+#ifndef HOST_WIDE_INT_PRINT_UNSIGNED
+# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
+#  define HOST_WIDE_INT_PRINT_UNSIGNED "%u"
+# else
+#  if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
+#   define HOST_WIDE_INT_PRINT_UNSIGNED "%lu"
+#  else
+#   define HOST_WIDE_INT_PRINT_UNSIGNED "%I64u"
+#  endif
+# endif
+#endif /* ! HOST_WIDE_INT_PRINT_UNSIGNED */
+
+#ifndef HOST_WIDE_INT_PRINT_HEX
+# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
+#  define HOST_WIDE_INT_PRINT_HEX "0x%x"
+# else
+#  if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
+#   define HOST_WIDE_INT_PRINT_HEX "0x%lx"
+#  else
+#   define HOST_WIDE_INT_PRINT_HEX "0x%I64x"
+#  endif
+# endif
+#endif /* ! HOST_WIDE_INT_PRINT_HEX */
+
+#ifndef HOST_WIDE_INT_PRINT_DOUBLE_HEX
+# if HOST_BITS_PER_WIDE_INT == 64
+#  if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
+#   define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%x%016x"
+#  else
+#   if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
+#    define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%016lx"
+#   else
+#    define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%llx%016llx"
+#   endif
+#  endif
+# else
+#  if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
+#   define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%x%08x"
+#  else
+#   if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
+#    define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%08lx"
+#   else
+#    define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%llx%08llx"
+#   endif
+#  endif
+# endif
+#endif /* ! HOST_WIDE_INT_PRINT_DOUBLE_HEX */
+
+/* Find HOST_WIDEST_INT and set its bit size, type and print macros.
+   It will be the largest integer mode supported by the host which may
+   &#40;or may not&#41; be larger than HOST_WIDE_INT.  */
+
+#ifndef HOST_WIDEST_INT
+#if defined HOST_BITS_PER_LONGLONG && HOST_BITS_PER_LONGLONG > HOST_BITS_PER_LONG
+#   define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONGLONG
+#   define HOST_WIDEST_INT __int64
+#   define HOST_WIDEST_INT_PRINT_DEC "%I64d"
+#   define HOST_WIDEST_INT_PRINT_UNSIGNED "%I64u"
+#   define HOST_WIDEST_INT_PRINT_HEX "0x%I64x"
+#  else
+#   define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONG
+#   define HOST_WIDEST_INT long
+#   define HOST_WIDEST_INT_PRINT_DEC "%ld"
+#   define HOST_WIDEST_INT_PRINT_UNSIGNED "%lu"
+#   define HOST_WIDEST_INT_PRINT_HEX "0x%lx"
+# endif /* long long wider than long */
+#endif /* ! HOST_WIDEST_INT */
Keep up the good work, dudes.
User avatar
Lukasz
Posts: 248
Joined: Mon Jan 19, 2004 8:37 pm
Location: Denmark
Contact:

Post by Lukasz »

I built the MinGW toolchains today and tested gsKit and the shift bug is gone! Good work ragnarok2040! I've uploaded the new toolchain binaries and linked them from the MinGW tutorial. I've taken the Vista binaries down, since they are bugged :-)
ragnarok2040
Posts: 202
Joined: Wed Aug 09, 2006 1:00 am

Post by ragnarok2040 »

Nice, :D.

On another note, I've noticed a bug in ltconfig when building stdc++v3, I think. It tries to call c:\ps2dev\ee\ee\nm.exe, but instead it comes out as c:ps2deveeeenm.exe. I'm not sure where it gets the dos-based path. Would redefining the variable for the nm executable in config.cache to /c/ps2dev/ee/ee/nm.exe fix that? It's not a serious problem, I don't think, but I'm not that familiar with building libraries. I have no idea if it affects the ps2dev toolchain scripts since they use /usr/local/ps2dev
Post Reply