www.digitalmars.com         C & C++   DMDScript  

D.gnu - gdc frontend for other platforms

reply Graham <grahamamacdonald gmail.com> writes:
I understand that gdc is a gcc frontend which supports various 
platforms.  What would it take to have it compile code for PSP 
(http://wiki.ps2dev.org/psp:toolchain) or for PS3?  (Assuming no garbage 
collection for simplicity - incidentally - what would it take to have 
garbage collection also?)

Thanks!
Mar 17 2007
parent Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes:
Graham wrote:
 I understand that gdc is a gcc frontend which supports various 
 platforms.  What would it take to have it compile code for PSP 
 (http://wiki.ps2dev.org/psp:toolchain) or for PS3?  (Assuming no garbage 
 collection for simplicity - incidentally - what would it take to have 
 garbage collection also?)
For one thing, it would require a GCC backend capable of compiling for it. Since the PSP SDK mentioned on that page seems to be GCC-based, this shouldn't be a problem. The next step would be to make sure the GDC frontend is compatible with that backend (Is it even possible for it to be incompatible? I have no idea). Then you compile a cross-compiler for PSP, with the appropriate GDC patch applied (and --enable-languages=d specified to configure). This may be a bit more tricky since getting a working cross-compiler with GDC isn't quite as easy as it should be IIRC. I do seem to recall David Friedman saying that fixing this was one of the goals that should be accomplished before he would release a GDC 1.0, so I presume he's working on it. If you do get a working cross-compiler up and running, you then need to port the runtime library. I haven't looked into gphobos much, but DMD's phobos on which it's based has a tendency to make non-portable assumptions. I have noticed that gphobos has some changes to fix this, but I'm not sure how far this goes. It may work as-is, or it may require some extra fixes. To get GC working (the GC is part of (g)phobos, by the way) you'll need to write the OS layer for the GC to call whatever OS services the PSP provides (or if it doesn't provide any, do it manually). To see what you would need to implement or port, see gclinux.d, win32.d or gcgcc.d in gcc/d/phobos/internal/gc/. I'm not sure how portable the rest of the gc is, but AFAIK the platform-specific stuff should mostly be in those files.
Mar 17 2007