Building PS2 GCC 3.x on a GCC 4.x platform

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

Moderators: cheriff, Herben

Post Reply
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Building PS2 GCC 3.x on a GCC 4.x platform

Post by TyRaNiD »

It seems that ps2 toolchain just wont build on a gcc4 system by default, but there is a fix. I haven't merged this into subversion yet as I dont know how the toolchain is structured for the ps2, ill leave that to someone else ;)

The problem is from 3.4 onwards they decprecated the use of casted lvalues which a few bits of the gcc source used. You need to do two things, update the copy of obstack.h and patch decl.c.

The patch for decl.c is:

Code: Select all

460a461,464
> #define set_current_binding_level(x) \
> 	if(cfun && cp_function_chain->bindings) { cp_function_chain->bindings = (x); } \
> 	else { scope_chain->bindings = (x); }
> 
510c514
<   current_binding_level = newlevel;
---
>   set_current_binding_level&#40;newlevel&#41;;
566c570
<     current_binding_level = current_binding_level->level_chain;
---
>     set_current_binding_level&#40;current_binding_level->level_chain&#41;;
581c585,587
<     current_binding_level = class_binding_level;
---
>   &#123;
>     set_current_binding_level&#40;class_binding_level&#41;;
>   &#125;
603c609
<   current_binding_level = current_binding_level->level_chain;
---
>   set_current_binding_level&#40;current_binding_level->level_chain&#41;;
616c622
<   current_binding_level = b;
---
>   set_current_binding_level&#40;b&#41;;
4294c4300
<       current_binding_level = level;
---
>       set_current_binding_level&#40;level&#41;;
4296c4302
<       current_binding_level = b;
---
>       set_current_binding_level&#40;b&#41;;
6539c6545
<   current_binding_level = NULL_BINDING_LEVEL;
---
>   set_current_binding_level&#40;NULL_BINDING_LEVEL&#41;;
10125c10131
<       current_binding_level = b->level_chain;
---
>       set_current_binding_level&#40;b->level_chain&#41;;
10128c10134
<       current_binding_level = b;
---
>       set_current_binding_level&#40;b&#41;;
13758c13764
<   current_binding_level = bl;
---
>   set_current_binding_level&#40;bl&#41;;
Copy that patch into the file decl.c.patch inside the ps2toolchain folder.
And then I just modified toolchain.sh to do copying and patching, e.g. at line 155 I added:

Code: Select all

   cd $GCC; cp /usr/include/obstack.h include/ || &#123; echo "ERROR COPYING obstack.h"; exit; &#125;
   cd ..
   cd $GCC; patch gcc/cp/decl.c "$SRCDIR/decl.c.patch" || &#123; echo "ERROR PATCHING decl.c"; exit; &#125;
   cd ..
It should now build correctly.
User avatar
Lukasz
Posts: 248
Joined: Mon Jan 19, 2004 8:37 pm
Location: Denmark
Contact:

Post by Lukasz »

Nice work Tyranid, now we can all avoid the hassle of switching back to gcc 3.3 every time we need to build the toolchains. I hope someone gets this fix into the toolchain patches soon :-)
sneeze
Posts: 15
Joined: Fri Mar 03, 2006 4:31 am

Post by sneeze »

I took some alternatives of these patches (see references below) and merged them with the result from the gcc-3.2.2.patch.

You can find it here http://h1.ripway.com/sneezer/gcc-3.2.2_on_4.x.patch

Feel free to try it out. It should work as a direct replacement of the 3.2.2.patch file

The actual patches are stolen from
http://mail-index.netbsd.org/netbsd-bug ... /0008.html (obstack.h)
and
http://gcc.gnu.org/ml/gcc-patches/2003-04/msg00210.html (decl.c)
cosmito
Posts: 307
Joined: Sun Mar 04, 2007 4:26 am
Location: Portugal
Contact:

Post by cosmito »

Thanks all for the help.

Sneeze : How can I apply a patch under Linux ? I'm really new to Linux...
cosmito
Posts: 307
Joined: Sun Mar 04, 2007 4:26 am
Location: Portugal
Contact:

Post by cosmito »

@sneeze,

How distracted I was... It was simply a matter or replacing the gcc-3.2.2.patch by this new one, right ?

I'm going to try.

Thanks
sneeze
Posts: 15
Joined: Fri Mar 03, 2006 4:31 am

Post by sneeze »

Yes, just replace the gcc-3.2.2.patch file

Did it work ok?
cosmito
Posts: 307
Joined: Sun Mar 04, 2007 4:26 am
Location: Portugal
Contact:

Post by cosmito »

Hi sneeze,

In fact, I've got an error during building again ...
But I didn't started the building (by running the toolchain.sh) from scratch. Instead I re-runned the toolchain.sh from my previous attempt (before replacing the file) which gave the a building/compiling error... It may not be conclusive. I should start from scratch. The error now might be due to any previous trash I had from the first attempt (before replacing the file)

I'll try next weekend probably. Too little time lately :(

Thanks for asking.
I'll post as soon I get new results.
ooPo
Site Admin
Posts: 2023
Joined: Sat Jan 17, 2004 9:56 am
Location: Canada
Contact:

Post by ooPo »

I've updated the ps2toolchain in the respository with the changes Tyranid suggested. It builds fine on an Ubuntu Feisty system running gcc-4.1.2.

Enjoy!
cosmito
Posts: 307
Joined: Sun Mar 04, 2007 4:26 am
Location: Portugal
Contact:

Post by cosmito »

Thanks ooPo!

In fact, today I was going to post the results of my last attempt with Cygwin.

It gave me the same error, after installing from scratch everything (the cygwin itself, checking out the svn sources and building the toolchain - I made this on a virtual machine). If anyone is interested, i'll post here the verbose output of it.

From this experience I conclude that the gcc-3.2.2.patch replacement suggested by sneeze doesn't work on the GCC 3.4.4-3 the latest Cygwin has. But now, with the new toolchain i'm going to try again.

Painful hours (why is cygwin building so slow?) of building are waiting me :)

bwt : I managed to build (in a snap) the previous toolchain last week under Debian linux (running under Virtual PC). No need to patch anything, no problem at all :)

But I think I'll prefer to work in a cygwin environment, I guess.
I'll post the results ASAP.

Thanks again
cosmito
Posts: 307
Joined: Sun Mar 04, 2007 4:26 am
Location: Portugal
Contact:

Post by cosmito »

@ooPo,

Hi

I just tried to execute the toolchain.sh but it seems there are problems under cygwin.

Code: Select all

$ ./toolchain.sh
&#58; command not founde 4&#58;
&#58; command not founde 8&#58;
&#58; command not founde 13&#58;
&#58; command not founde 17&#58;
&#58; command not founde 22&#58;
&#58; command not founde 26&#58;
'/toolchain.sh&#58; line 42&#58; syntax error near unexpected token `in
'/toolchain.sh&#58; line 42&#58; `    case "$1" in
I checked the differences between this and the previous version with WinMerge and it gives the warning : "These files uses different carriage return types". Might this be the problem ?
ubergeek42
Posts: 83
Joined: Wed Jul 13, 2005 12:25 am

Post by ubergeek42 »

Yes, from my experience, cygwin shell scripts only work when the line endings are LF(Line feed) only, as opposed to (CRLF)
ooPo
Site Admin
Posts: 2023
Joined: Sat Jan 17, 2004 9:56 am
Location: Canada
Contact:

Post by ooPo »

Cygwin isn't officially supported, although it may work if you tweak it a bit.

I suggest downloading a premade package if you're set on using it, though.
cosmito
Posts: 307
Joined: Sun Mar 04, 2007 4:26 am
Location: Portugal
Contact:

Post by cosmito »

OK, i'll strip the CR characters and give it a shot.
cosmito
Posts: 307
Joined: Sun Mar 04, 2007 4:26 am
Location: Portugal
Contact:

Post by cosmito »

Well, it didn't worked on Cygwin. I got rid of one of those line end two characters and just leaving the LF one, just like in the previous toolchain versions.

The building now starts under Cygwin but it fails.

For the interested :

Code: Select all

&#40;...&#41;v3/libmath
 -g -O2 -fno-implicit-templates -Wall -Wno-format -W -Wwrite-strings -Winline -f
diagnostics-show-location=once -G0 -g -c ../../../../libstdc++-v3/src/locale-ins
t.cc -o locale-inst.o
/tmp/ps2dev/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/include/bits/locale_facets.tc
c&#58; In
   member function `_InIter std&#58;&#58;money_get<_CharT, _InIter>&#58;&#58;do_get&#40;_InIter,
   _InIter, bool, std&#58;&#58;ios_base&, std&#58;&#58;_Ios_Iostate&, std&#58;&#58;basic_string<_CharT,

   std&#58;&#58;char_traits<_CharT>, std&#58;&#58;allocator<_CharT> >&&#41; const &#91;with _CharT =
   char, _InIter = std&#58;&#58;istreambuf_iterator<char, std&#58;&#58;char_traits<char> >&#93;'&#58;
../../../../libstdc++-v3/src/locale-inst.cc&#58;47&#58;   instantiated from here
/tmp/ps2dev/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/include/bits/locale_facets.tc
c&#58;1167&#58; Internal
   compiler error in schedule_block, at haifa-sched.c&#58;1714
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL&#58;http&#58;//www.gnu.org/software/gcc/bugs.html> for instructions.
gmake&#91;3&#93;&#58; *** &#91;locale-inst.lo&#93; Error 1
gmake&#91;3&#93;&#58; Leaving directory `/tmp/ps2dev/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/
src'
gmake&#91;2&#93;&#58; *** &#91;all-recursive&#93; Error 1
gmake&#91;2&#93;&#58; Leaving directory `/tmp/ps2dev/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3'

gmake&#91;1&#93;&#58; *** &#91;all-recursive-am&#93; Error 2
gmake&#91;1&#93;&#58; Leaving directory `/tmp/ps2dev/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3'

gmake&#58; *** &#91;all-target-libstdc++-v3&#93; Error 2
ERROR BUILDING GCC &#40;gcc-3.2.2 ee C++&#41;
Well, I had enough of Cygwin. Bailing out :)

At least on Debian linux it build (well, just the toolchain previous version builded now I hope it still does :) )

The GCC version on Cygwin is 3.4.4.
cosmito
Posts: 307
Joined: Sun Mar 04, 2007 4:26 am
Location: Portugal
Contact:

Post by cosmito »

@TyRaNiD,

Well, maybe i'll try your patch, just maybe.
And BTW, congratulations for your interesting presentation on BP2007!

I quite new to PS2 delopment (just finally buit the toolchain on Linux and in the mean while looked at the SDK examples, tutorials and built some using a precompiled Win32 for Cygwin) but it seems that the PSP is a bit more documented... Just my impression ?

Why my obcession about documentation when anyone can look at the examples ? Quite simple : Documentation is essecial for true knowledge and correct way of doing thigs. Anyone can look at the examples and figure how things works, but it's depending on our understanding and interpretation of it, not the direct explanation. Also, no example is ever complete compared to a reference document.
Post Reply