www.digitalmars.com         C & C++   DMDScript  

D.gnu - GDC on psptoolchain

reply John Grindstaff <perfectcell14 yahoo.com> writes:
Building GDC for the psptoolchain (as psp-gdc) is it possible? I get compile
errors such as this:

http://paste.dprogramming.com/dppq5raf

Even though I did apply PSP patches and ran d language setup.sh

I'm not sure how to patch gdc for PSP use. I like programming on Playstation
Portable, but I only desire to return to that scene if I can program in a
sensible, modern language such as D.


      
Jul 18 2008
parent reply David Friedman <dvdfrdmn users.ess-eff.net> writes:
John Grindstaff wrote:
 Building GDC for the psptoolchain (as psp-gdc) is it possible? I get compile
errors such as this:
 
 http://paste.dprogramming.com/dppq5raf
 
 Even though I did apply PSP patches and ran d language setup.sh
 
 I'm not sure how to patch gdc for PSP use. I like programming on Playstation
Portable, but I only desire to return to that scene if I can program in a
sensible, modern language such as D.
 
 
       
The latest SVN version has fixes that will allow GDC to build with psptoolchain (and MIPS, in general). I do not have a PSP, so I cannot really test it beyond this. David
Jul 19 2008
next sibling parent reply FreekSh0w86 <perfectcell14 yahoo.com> writes:
The very latest? I checked out svn last week but I didn't know what to 
put in the configuration files in order to make it build. The 
psptoolchain works by compiling PSP binaries on a POSIX system, so 
setting the configuration file might be tricky.

Thanks

David Friedman wrote:
 John Grindstaff wrote:
 Building GDC for the psptoolchain (as psp-gdc) is it possible? I get 
 compile errors such as this:

 http://paste.dprogramming.com/dppq5raf

 Even though I did apply PSP patches and ran d language setup.sh

 I'm not sure how to patch gdc for PSP use. I like programming on 
 Playstation Portable, but I only desire to return to that scene if I 
 can program in a sensible, modern language such as D.


       
The latest SVN version has fixes that will allow GDC to build with psptoolchain (and MIPS, in general). I do not have a PSP, so I cannot really test it beyond this. David
Jul 20 2008
parent reply David Friedman <dvdfrdmn users.ess-eff.net> writes:
Yes, the very latest -- checked in last night.  I'm not sure what you 
mean by config 'files'.  You should use the commands in the psptoolchain 
build scripts.  The only difference is that the --enable-languages 
option should be

   --enable-languages=c,c++,d

or

   --enable-languages=c,d

David

FreekSh0w86 wrote:
 The very latest? I checked out svn last week but I didn't know what to 
 put in the configuration files in order to make it build. The 
 psptoolchain works by compiling PSP binaries on a POSIX system, so 
 setting the configuration file might be tricky.
 
 Thanks
 
 David Friedman wrote:
 John Grindstaff wrote:
 Building GDC for the psptoolchain (as psp-gdc) is it possible? I get 
 compile errors such as this:

 http://paste.dprogramming.com/dppq5raf

 Even though I did apply PSP patches and ran d language setup.sh

 I'm not sure how to patch gdc for PSP use. I like programming on 
 Playstation Portable, but I only desire to return to that scene if I 
 can program in a sensible, modern language such as D.


       
The latest SVN version has fixes that will allow GDC to build with psptoolchain (and MIPS, in general). I do not have a PSP, so I cannot really test it beyond this. David
Jul 20 2008
parent reply Kostas Karanikolas <k_karanikolas hotmail.com> writes:
Hi, 
I was intrigued enough to have another go at compiling GDC for the PSP (my
previous attempt half a year ago did not get me very far), and I can say that
at least the toolchain builds fine (for D 1.0) with a working compiler and a
libgphobos. (When I enabled D 2.0, the toolchain build stopped with compiler
errors)

Here's what my psp-gdc -v produces:

Using built-in specs.
Target: psp
Configured with: ../configure --prefix=/pspdev --target=psp
--enable-languages=c,d,c++ --with-newlib --enable-cxx-flags=-G0
--disable-libssp --enable-static --disable-shared
Thread model: single
gcc version 4.1.0 20060228 ( gdc 0.24, using dmd 1.030) (PSPDEV 20060507)

BTW you can also see the configure flags I used.

I wanted to see if I could get a working executable. So my test was, to have D
function be called from a C main function (because the PSP sdk has some special
initialization macros that I guess need to be defined to get a working
executable). However when linking the program I got a lot of linker errors,
originating from libphobos/std/math.d and libphobos/gcc/cbridge_math.c. My
guess is that these come from the lack of double support on the psp toolchain.
Could that be the case, or is it some kind of misconfiguration? Also is there
some way of fixing this?

Thanks!

Here is the test program:
----------------------------------
testd.d:
import std.stdio;

extern(C) void dfunc()
{
        printf("Hello from D");
}

----------------------------------
#include <pspkernel.h>
#include <stdio.h>
PSP_MODULE_INFO("test", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
extern void dfunc();
int main(int argc, char *argv[])
{
        printf("Hello World\n");
        dfunc();
        return 0;
}

----------------------------------
Here are the actual errors:

psp-gcc -I. -I/pspdev/psp/sdk/include -O0 -g -G0 -Wall -D_PSP_FW_VERSION=150 
-L. -L/pspdev/psp/sdk/lib -specs=/pspdev/psp/sdk/lib/prxspecs
-Wl,-q,-T/pspdev/psp/sdk/lib/linkfile.prx   main.o testd.o
/pspdev/psp/sdk/lib/prxexports.o -lgphobos -lpspdebug -lpspdisplay -lpspge
-lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver
-lpsputility -lpspuser -lpspkernel -o test.elf
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math4exp2FeZe':
../../../libphobos/std/math.d:785: undefined reference to `pow'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math9nextafterFddZd':
../../../libphobos/std/math.d:2137: undefined reference to `nextafter'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math9nextafterFffZf':
../../../libphobos/std/math.d:2126: undefined reference to `nextafterf'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math9nextafterFeeZe':
../../../libphobos/std/math.d:2115: undefined reference to `nextafter'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math3powFeeZe':
../../../libphobos/std/math.d:2371: undefined reference to `pow'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math9remainderFeeZe':
../../../libphobos/std/math.d:1574: undefined reference to `remainder'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math5truncFeZe':
../../../libphobos/std/math.d:1550: undefined reference to `trunc'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math5roundFeZe':
../../../libphobos/std/math.d:1509: undefined reference to `round'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math9nearbyintFeZe':
../../../libphobos/std/math.d:1431: undefined reference to `nearbyint'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math5floorFeZe':
../../../libphobos/std/math.d:1417: undefined reference to `floor'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math4ceilFeZe':
../../../libphobos/std/math.d:1411: undefined reference to `ceil'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math6tgammaFeZe':
../../../libphobos/std/math.d:1402: undefined reference to `tgamma'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math6lgammaFeZe':
../../../libphobos/std/math.d:1365: undefined reference to `lgamma'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math4erfcFeZe':
../../../libphobos/std/math.d:1345: undefined reference to `erfc'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math3erfFeZe':
../../../libphobos/std/math.d:1337: undefined reference to `erf'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math4cbrtFeZe':
../../../libphobos/std/math.d:1196: undefined reference to `cbrt'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math4logbFeZe':
../../../libphobos/std/math.d:1137: undefined reference to `logb'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math4log2FeZe':
../../../libphobos/std/math.d:1120: undefined reference to `log'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math3logFeZe':
../../../libphobos/std/math.d:1077: undefined reference to `log'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math5log1pFeZe':
../../../libphobos/std/math.d:1107: undefined reference to `log1p'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math5log10FeZe':
../../../libphobos/std/math.d:1090: undefined reference to `log10'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math5ilogbFeZi':
../../../libphobos/std/math.d:1052: undefined reference to `ilogb'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math4expiFeZc':
../../../libphobos/std/math.d:832: undefined reference to `cos'
../../../libphobos/std/math.d:832: undefined reference to `sin'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math5expm1FeZe':
../../../libphobos/std/math.d:804: undefined reference to `expm1'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math3expFeZe':
../../../libphobos/std/math.d:774: undefined reference to `exp'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math4sqrtFeZe':
../../../libphobos/std/math.d:721: undefined reference to `sqrt'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math4sqrtFdZd':
../../../libphobos/std/math.d:719: undefined reference to `sqrt'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math4sqrtFfZf':
../../../libphobos/std/math.d:717: undefined reference to `sqrtf'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math4tanhFeZe':
../../../libphobos/std/math.d:585: undefined reference to `tanh'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math4sinhFeZe':
../../../libphobos/std/math.d:574: undefined reference to `sinh'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math4coshFeZe':
../../../libphobos/std/math.d:563: undefined reference to `cosh'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math5atan2FeeZe':
../../../libphobos/std/math.d:553: undefined reference to `atan2'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math4atanFeZe':
../../../libphobos/std/math.d:530: undefined reference to `atan'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math4asinFeZe':
../../../libphobos/std/math.d:518: undefined reference to `asin'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In function
`_D3std4math4acosFeZe':
../../../libphobos/std/math.d:505: undefined reference to `acos'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls7signbitFfZi':
../../../libphobos/gcc/cbridge_math.c:39: undefined reference to `__signbitf'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls7signbitFdZi':
../../../libphobos/gcc/cbridge_math.c:39: undefined reference to `__signbitd'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls7signbitFeZi':
../../../libphobos/gcc/cbridge_math.c:39: undefined reference to `__signbitd'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls10fpclassifyFfZi':
../../../libphobos/gcc/cbridge_math.c:38: undefined reference to `__fpclassifyf'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls10fpclassifyFdZi':
../../../libphobos/gcc/cbridge_math.c:38: undefined reference to `__fpclassifyd'
/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls10fpclassifyFeZi':
../../../libphobos/gcc/cbridge_math.c:38: undefined reference to `__fpclassifyd'


David Friedman Wrote:

 Yes, the very latest -- checked in last night.  I'm not sure what you 
 mean by config 'files'.  You should use the commands in the psptoolchain 
 build scripts.  The only difference is that the --enable-languages 
 option should be
 
    --enable-languages=c,c++,d
 
 or
 
    --enable-languages=c,d
 
 David
 
 FreekSh0w86 wrote:
 The very latest? I checked out svn last week but I didn't know what to 
 put in the configuration files in order to make it build. The 
 psptoolchain works by compiling PSP binaries on a POSIX system, so 
 setting the configuration file might be tricky.
 
 Thanks
 
 David Friedman wrote:
 John Grindstaff wrote:
 Building GDC for the psptoolchain (as psp-gdc) is it possible? I get 
 compile errors such as this:

 http://paste.dprogramming.com/dppq5raf

 Even though I did apply PSP patches and ran d language setup.sh

 I'm not sure how to patch gdc for PSP use. I like programming on 
 Playstation Portable, but I only desire to return to that scene if I 
 can program in a sensible, modern language such as D.


       
The latest SVN version has fixes that will allow GDC to build with psptoolchain (and MIPS, in general). I do not have a PSP, so I cannot really test it beyond this. David
Jul 23 2008
parent reply John Grindstaff <perfectcell14 yahoo.com> writes:
Thanks for listing the compile flags. I successfully built an executable 
but there was no libgphobos.a appearing--which prevented me from 
instantiating any classes or structs in my test example (which operates 
similar to yours--an extern'd d function called from C).

Would it be possible to use a stripped down version of Tango or Phobos, 
perhaps something that has the base type/classinfo and memory management 
stuff and leave the rest alone? I just need auto memory management and 
classes and I can use all the sce* psp sdk functions for other things.

BTW, you might want to use pspDebugScreenPrintf and pspDebugScreenInit 
instead of printf for the C code. Last time I checked, they are very 
different and printf doesn't work.

Kostas Karanikolas wrote:
 Hi, 
 I was intrigued enough to have another go at compiling GDC for the PSP (my
previous attempt half a year ago did not get me very far), and I can say that
at least the toolchain builds fine (for D 1.0) with a working compiler and a
libgphobos. (When I enabled D 2.0, the toolchain build stopped with compiler
errors)
 
 Here's what my psp-gdc -v produces:
 
 Using built-in specs.
 Target: psp
 Configured with: ../configure --prefix=/pspdev --target=psp
--enable-languages=c,d,c++ --with-newlib --enable-cxx-flags=-G0
--disable-libssp --enable-static --disable-shared
 Thread model: single
 gcc version 4.1.0 20060228 ( gdc 0.24, using dmd 1.030) (PSPDEV 20060507)
 
 BTW you can also see the configure flags I used.
 
 I wanted to see if I could get a working executable. So my test was, to have D
function be called from a C main function (because the PSP sdk has some special
initialization macros that I guess need to be defined to get a working
executable). However when linking the program I got a lot of linker errors,
originating from libphobos/std/math.d and libphobos/gcc/cbridge_math.c. My
guess is that these come from the lack of double support on the psp toolchain.
Could that be the case, or is it some kind of misconfiguration? Also is there
some way of fixing this?
 
 Thanks!
 
 Here is the test program:
 ----------------------------------
 testd.d:
 import std.stdio;
 
 extern(C) void dfunc()
 {
         printf("Hello from D");
 }
 
 ----------------------------------
 #include <pspkernel.h>
 #include <stdio.h>
 PSP_MODULE_INFO("test", 0, 1, 1);
 PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
 extern void dfunc();
 int main(int argc, char *argv[])
 {
         printf("Hello World\n");
         dfunc();
         return 0;
 }
 
 ----------------------------------
 Here are the actual errors:
 
 psp-gcc -I. -I/pspdev/psp/sdk/include -O0 -g -G0 -Wall -D_PSP_FW_VERSION=150 
-L. -L/pspdev/psp/sdk/lib -specs=/pspdev/psp/sdk/lib/prxspecs
-Wl,-q,-T/pspdev/psp/sdk/lib/linkfile.prx   main.o testd.o
/pspdev/psp/sdk/lib/prxexports.o -lgphobos -lpspdebug -lpspdisplay -lpspge
-lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver
-lpsputility -lpspuser -lpspkernel -o test.elf
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4exp2FeZe':
 ../../../libphobos/std/math.d:785: undefined reference to `pow'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math9nextafterFddZd':
 ../../../libphobos/std/math.d:2137: undefined reference to `nextafter'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math9nextafterFffZf':
 ../../../libphobos/std/math.d:2126: undefined reference to `nextafterf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math9nextafterFeeZe':
 ../../../libphobos/std/math.d:2115: undefined reference to `nextafter'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math3powFeeZe':
 ../../../libphobos/std/math.d:2371: undefined reference to `pow'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math9remainderFeeZe':
 ../../../libphobos/std/math.d:1574: undefined reference to `remainder'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5truncFeZe':
 ../../../libphobos/std/math.d:1550: undefined reference to `trunc'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5roundFeZe':
 ../../../libphobos/std/math.d:1509: undefined reference to `round'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math9nearbyintFeZe':
 ../../../libphobos/std/math.d:1431: undefined reference to `nearbyint'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5floorFeZe':
 ../../../libphobos/std/math.d:1417: undefined reference to `floor'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4ceilFeZe':
 ../../../libphobos/std/math.d:1411: undefined reference to `ceil'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math6tgammaFeZe':
 ../../../libphobos/std/math.d:1402: undefined reference to `tgamma'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math6lgammaFeZe':
 ../../../libphobos/std/math.d:1365: undefined reference to `lgamma'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4erfcFeZe':
 ../../../libphobos/std/math.d:1345: undefined reference to `erfc'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math3erfFeZe':
 ../../../libphobos/std/math.d:1337: undefined reference to `erf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4cbrtFeZe':
 ../../../libphobos/std/math.d:1196: undefined reference to `cbrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4logbFeZe':
 ../../../libphobos/std/math.d:1137: undefined reference to `logb'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4log2FeZe':
 ../../../libphobos/std/math.d:1120: undefined reference to `log'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math3logFeZe':
 ../../../libphobos/std/math.d:1077: undefined reference to `log'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5log1pFeZe':
 ../../../libphobos/std/math.d:1107: undefined reference to `log1p'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5log10FeZe':
 ../../../libphobos/std/math.d:1090: undefined reference to `log10'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5ilogbFeZi':
 ../../../libphobos/std/math.d:1052: undefined reference to `ilogb'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4expiFeZc':
 ../../../libphobos/std/math.d:832: undefined reference to `cos'
 ../../../libphobos/std/math.d:832: undefined reference to `sin'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5expm1FeZe':
 ../../../libphobos/std/math.d:804: undefined reference to `expm1'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math3expFeZe':
 ../../../libphobos/std/math.d:774: undefined reference to `exp'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4sqrtFeZe':
 ../../../libphobos/std/math.d:721: undefined reference to `sqrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4sqrtFdZd':
 ../../../libphobos/std/math.d:719: undefined reference to `sqrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4sqrtFfZf':
 ../../../libphobos/std/math.d:717: undefined reference to `sqrtf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4tanhFeZe':
 ../../../libphobos/std/math.d:585: undefined reference to `tanh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4sinhFeZe':
 ../../../libphobos/std/math.d:574: undefined reference to `sinh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4coshFeZe':
 ../../../libphobos/std/math.d:563: undefined reference to `cosh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5atan2FeeZe':
 ../../../libphobos/std/math.d:553: undefined reference to `atan2'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4atanFeZe':
 ../../../libphobos/std/math.d:530: undefined reference to `atan'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4asinFeZe':
 ../../../libphobos/std/math.d:518: undefined reference to `asin'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4acosFeZe':
 ../../../libphobos/std/math.d:505: undefined reference to `acos'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls7signbitFfZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to `__signbitf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls7signbitFdZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to `__signbitd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls7signbitFeZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to `__signbitd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls10fpclassifyFfZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to
`__fpclassifyf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls10fpclassifyFdZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to
`__fpclassifyd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls10fpclassifyFeZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to
`__fpclassifyd'
Jul 23 2008
next sibling parent reply John Grindstaff <perfectcell14 yahoo.com> writes:
Oh yeah, did you try explicitly linking to the math lib (-lm)? Sometimes 
  library flags such as "-lm" have to be placed in a different order, 
before or after others, it's really strange.

As far as I know, doubles work fine on the PSP--I wrote a calculator 
program that uses doubles for the PSP a long time ago.
Jul 23 2008
parent Moritz Warning <moritzwarning web.de> writes:
On Wed, 23 Jul 2008 14:26:13 -0400, John Grindstaff wrote:

 Oh yeah, did you try explicitly linking to the math lib (-lm)? Sometimes
   library flags such as "-lm" have to be placed in a different order,
 before or after others, it's really strange.
 
 As far as I know, doubles work fine on the PSP--I wrote a calculator
 program that uses doubles for the PSP a long time ago.
Nice to hear, do you mind writing a short howto? Maybe on the news-group or on http://www.prowiki.org/wiki4d. For others who want to follow the path.
Jul 23 2008
prev sibling next sibling parent reply Vincent Richomme <forumer smartmobili.com> writes:
Hi,

Sorry to participate to this discussion but we may have some common goals.
Actually my company is actually working on generating a cross-compiler 
running on windows CE device.
We have almost finished, there are some minors bugs but it's pretty close.
Now I agree with you it would be great if we could compile with no 
dependencies to libphobos and actually it's possible if you pass 
-nophoboslib to linker.
But more generally we are working on a framework called Gynoid that 
targets embedded platforms(Windows CE, Symbian, Darwin) and it would be 
great if we could add support for PSP...

There something I don't understand in your sentence below :

 Would it be possible to use a stripped down version of Tango orPhobos,
 perhaps something that has the base type/classinfo and memory management
 stuff and leave the rest alone? I just need auto memory management and
 classes and I can use all the sce* psp sdk functions for other things.
I thought that memory management was part of the language and not in phobos lib, in this case I really agree that it would be interesting to remove libphobos dependency and to allow developpers to developp their own lib. John Grindstaff a écrit :
 Thanks for listing the compile flags. I successfully built an executable 
 but there was no libgphobos.a appearing--which prevented me from 
 instantiating any classes or structs in my test example (which operates 
 similar to yours--an extern'd d function called from C).
 
 Would it be possible to use a stripped down version of Tango or Phobos, 
 perhaps something that has the base type/classinfo and memory management 
 stuff and leave the rest alone? I just need auto memory management and 
 classes and I can use all the sce* psp sdk functions for other things.
 
 BTW, you might want to use pspDebugScreenPrintf and pspDebugScreenInit 
 instead of printf for the C code. Last time I checked, they are very 
 different and printf doesn't work.
 
 Kostas Karanikolas wrote:
 Hi, I was intrigued enough to have another go at compiling GDC for the 
 PSP (my previous attempt half a year ago did not get me very far), and 
 I can say that at least the toolchain builds fine (for D 1.0) with a 
 working compiler and a libgphobos. (When I enabled D 2.0, the 
 toolchain build stopped with compiler errors)

 Here's what my psp-gdc -v produces:

 Using built-in specs.
 Target: psp
 Configured with: ../configure --prefix=/pspdev --target=psp 
 --enable-languages=c,d,c++ --with-newlib --enable-cxx-flags=-G0 
 --disable-libssp --enable-static --disable-shared
 Thread model: single
 gcc version 4.1.0 20060228 ( gdc 0.24, using dmd 1.030) (PSPDEV 20060507)

 BTW you can also see the configure flags I used.

 I wanted to see if I could get a working executable. So my test was, 
 to have D function be called from a C main function (because the PSP 
 sdk has some special initialization macros that I guess need to be 
 defined to get a working executable). However when linking the program 
 I got a lot of linker errors, originating from libphobos/std/math.d 
 and libphobos/gcc/cbridge_math.c. My guess is that these come from the 
 lack of double support on the psp toolchain. Could that be the case, 
 or is it some kind of misconfiguration? Also is there some way of 
 fixing this?

 Thanks!

 Here is the test program:
 ----------------------------------
 testd.d:
 import std.stdio;

 extern(C) void dfunc()
 {
         printf("Hello from D");
 }

 ----------------------------------
 #include <pspkernel.h>
 #include <stdio.h>
 PSP_MODULE_INFO("test", 0, 1, 1);
 PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
 extern void dfunc();
 int main(int argc, char *argv[])
 {
         printf("Hello World\n");
         dfunc();
         return 0;
 }

 ----------------------------------
 Here are the actual errors:

 psp-gcc -I. -I/pspdev/psp/sdk/include -O0 -g -G0 -Wall 
 -D_PSP_FW_VERSION=150  -L. -L/pspdev/psp/sdk/lib 
 -specs=/pspdev/psp/sdk/lib/prxspecs 
 -Wl,-q,-T/pspdev/psp/sdk/lib/linkfile.prx   main.o testd.o 
 /pspdev/psp/sdk/lib/prxexports.o -lgphobos -lpspdebug -lpspdisplay 
 -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl 
 -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o test.elf
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math4exp2FeZe':
 ../../../libphobos/std/math.d:785: undefined reference to `pow'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math9nextafterFddZd':
 ../../../libphobos/std/math.d:2137: undefined reference to `nextafter'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math9nextafterFffZf':
 ../../../libphobos/std/math.d:2126: undefined reference to `nextafterf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math9nextafterFeeZe':
 ../../../libphobos/std/math.d:2115: undefined reference to `nextafter'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math3powFeeZe':
 ../../../libphobos/std/math.d:2371: undefined reference to `pow'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math9remainderFeeZe':
 ../../../libphobos/std/math.d:1574: undefined reference to `remainder'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math5truncFeZe':
 ../../../libphobos/std/math.d:1550: undefined reference to `trunc'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math5roundFeZe':
 ../../../libphobos/std/math.d:1509: undefined reference to `round'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math9nearbyintFeZe':
 ../../../libphobos/std/math.d:1431: undefined reference to `nearbyint'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math5floorFeZe':
 ../../../libphobos/std/math.d:1417: undefined reference to `floor'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math4ceilFeZe':
 ../../../libphobos/std/math.d:1411: undefined reference to `ceil'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math6tgammaFeZe':
 ../../../libphobos/std/math.d:1402: undefined reference to `tgamma'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math6lgammaFeZe':
 ../../../libphobos/std/math.d:1365: undefined reference to `lgamma'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math4erfcFeZe':
 ../../../libphobos/std/math.d:1345: undefined reference to `erfc'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math3erfFeZe':
 ../../../libphobos/std/math.d:1337: undefined reference to `erf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math4cbrtFeZe':
 ../../../libphobos/std/math.d:1196: undefined reference to `cbrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math4logbFeZe':
 ../../../libphobos/std/math.d:1137: undefined reference to `logb'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math4log2FeZe':
 ../../../libphobos/std/math.d:1120: undefined reference to `log'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math3logFeZe':
 ../../../libphobos/std/math.d:1077: undefined reference to `log'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math5log1pFeZe':
 ../../../libphobos/std/math.d:1107: undefined reference to `log1p'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math5log10FeZe':
 ../../../libphobos/std/math.d:1090: undefined reference to `log10'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math5ilogbFeZi':
 ../../../libphobos/std/math.d:1052: undefined reference to `ilogb'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math4expiFeZc':
 ../../../libphobos/std/math.d:832: undefined reference to `cos'
 ../../../libphobos/std/math.d:832: undefined reference to `sin'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math5expm1FeZe':
 ../../../libphobos/std/math.d:804: undefined reference to `expm1'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math3expFeZe':
 ../../../libphobos/std/math.d:774: undefined reference to `exp'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math4sqrtFeZe':
 ../../../libphobos/std/math.d:721: undefined reference to `sqrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math4sqrtFdZd':
 ../../../libphobos/std/math.d:719: undefined reference to `sqrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math4sqrtFfZf':
 ../../../libphobos/std/math.d:717: undefined reference to `sqrtf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math4tanhFeZe':
 ../../../libphobos/std/math.d:585: undefined reference to `tanh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math4sinhFeZe':
 ../../../libphobos/std/math.d:574: undefined reference to `sinh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math4coshFeZe':
 ../../../libphobos/std/math.d:563: undefined reference to `cosh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math5atan2FeeZe':
 ../../../libphobos/std/math.d:553: undefined reference to `atan2'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math4atanFeZe':
 ../../../libphobos/std/math.d:530: undefined reference to `atan'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math4asinFeZe':
 ../../../libphobos/std/math.d:518: undefined reference to `asin'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In 
 function `_D3std4math4acosFeZe':
 ../../../libphobos/std/math.d:505: undefined reference to `acos'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls7signbitFfZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to 
 `__signbitf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls7signbitFdZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to 
 `__signbitd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls7signbitFeZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to 
 `__signbitd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls10fpclassifyFfZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to 
 `__fpclassifyf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls10fpclassifyFdZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to 
 `__fpclassifyd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls10fpclassifyFeZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to 
 `__fpclassifyd'
Jul 23 2008
next sibling parent FreekSh0w86 <perfectcell14 yahoo.com> writes:
I think libphobos contains the whole runtime, which is needed for 
classes, structs, garbage collection, etc.

Of course it is possible to compile d source files without libphobos, 
but a runtime of some sort is still needed for class instances and 
garbage collection.

Vincent Richomme wrote:
 Hi,
 
 Sorry to participate to this discussion but we may have some common goals.
 Actually my company is actually working on generating a cross-compiler 
 running on windows CE device.
 We have almost finished, there are some minors bugs but it's pretty close.
 Now I agree with you it would be great if we could compile with no 
 dependencies to libphobos and actually it's possible if you pass 
 -nophoboslib to linker.
 But more generally we are working on a framework called Gynoid that 
 targets embedded platforms(Windows CE, Symbian, Darwin) and it would be 
 great if we could add support for PSP...
 
 There something I don't understand in your sentence below :
 
  > Would it be possible to use a stripped down version of Tango orPhobos,
  > perhaps something that has the base type/classinfo and memory management
  > stuff and leave the rest alone? I just need auto memory management and
  > classes and I can use all the sce* psp sdk functions for other things.
 
 I thought that memory management was part of the language and not in 
 phobos lib, in this case I really agree that it would be interesting to 
 remove libphobos dependency and to allow developpers to developp their 
 own lib.
 
 
 
 
 
 
 
 John Grindstaff a écrit :
 Thanks for listing the compile flags. I successfully built an 
 executable but there was no libgphobos.a appearing--which prevented me 
 from instantiating any classes or structs in my test example (which 
 operates similar to yours--an extern'd d function called from C).

 Would it be possible to use a stripped down version of Tango or 
 Phobos, perhaps something that has the base type/classinfo and memory 
 management stuff and leave the rest alone? I just need auto memory 
 management and classes and I can use all the sce* psp sdk functions 
 for other things.

 BTW, you might want to use pspDebugScreenPrintf and pspDebugScreenInit 
 instead of printf for the C code. Last time I checked, they are very 
 different and printf doesn't work.

 Kostas Karanikolas wrote:
 Hi, I was intrigued enough to have another go at compiling GDC for 
 the PSP (my previous attempt half a year ago did not get me very 
 far), and I can say that at least the toolchain builds fine (for D 
 1.0) with a working compiler and a libgphobos. (When I enabled D 2.0, 
 the toolchain build stopped with compiler errors)

 Here's what my psp-gdc -v produces:

 Using built-in specs.
 Target: psp
 Configured with: ../configure --prefix=/pspdev --target=psp 
 --enable-languages=c,d,c++ --with-newlib --enable-cxx-flags=-G0 
 --disable-libssp --enable-static --disable-shared
 Thread model: single
 gcc version 4.1.0 20060228 ( gdc 0.24, using dmd 1.030) (PSPDEV 
 20060507)

 BTW you can also see the configure flags I used.

 I wanted to see if I could get a working executable. So my test was, 
 to have D function be called from a C main function (because the PSP 
 sdk has some special initialization macros that I guess need to be 
 defined to get a working executable). However when linking the 
 program I got a lot of linker errors, originating from 
 libphobos/std/math.d and libphobos/gcc/cbridge_math.c. My guess is 
 that these come from the lack of double support on the psp toolchain. 
 Could that be the case, or is it some kind of misconfiguration? Also 
 is there some way of fixing this?

 Thanks!

 Here is the test program:
 ----------------------------------
 testd.d:
 import std.stdio;

 extern(C) void dfunc()
 {
         printf("Hello from D");
 }

 ----------------------------------
 #include <pspkernel.h>
 #include <stdio.h>
 PSP_MODULE_INFO("test", 0, 1, 1);
 PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
 extern void dfunc();
 int main(int argc, char *argv[])
 {
         printf("Hello World\n");
         dfunc();
         return 0;
 }

 ----------------------------------
 Here are the actual errors:

 psp-gcc -I. -I/pspdev/psp/sdk/include -O0 -g -G0 -Wall 
 -D_PSP_FW_VERSION=150  -L. -L/pspdev/psp/sdk/lib 
 -specs=/pspdev/psp/sdk/lib/prxspecs 
 -Wl,-q,-T/pspdev/psp/sdk/lib/linkfile.prx   main.o testd.o 
 /pspdev/psp/sdk/lib/prxexports.o -lgphobos -lpspdebug -lpspdisplay 
 -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl 
 -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o test.elf
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4exp2FeZe':
 ../../../libphobos/std/math.d:785: undefined reference to `pow'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math9nextafterFddZd':
 ../../../libphobos/std/math.d:2137: undefined reference to `nextafter'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math9nextafterFffZf':
 ../../../libphobos/std/math.d:2126: undefined reference to `nextafterf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math9nextafterFeeZe':
 ../../../libphobos/std/math.d:2115: undefined reference to `nextafter'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math3powFeeZe':
 ../../../libphobos/std/math.d:2371: undefined reference to `pow'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math9remainderFeeZe':
 ../../../libphobos/std/math.d:1574: undefined reference to `remainder'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5truncFeZe':
 ../../../libphobos/std/math.d:1550: undefined reference to `trunc'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5roundFeZe':
 ../../../libphobos/std/math.d:1509: undefined reference to `round'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math9nearbyintFeZe':
 ../../../libphobos/std/math.d:1431: undefined reference to `nearbyint'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5floorFeZe':
 ../../../libphobos/std/math.d:1417: undefined reference to `floor'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4ceilFeZe':
 ../../../libphobos/std/math.d:1411: undefined reference to `ceil'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math6tgammaFeZe':
 ../../../libphobos/std/math.d:1402: undefined reference to `tgamma'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math6lgammaFeZe':
 ../../../libphobos/std/math.d:1365: undefined reference to `lgamma'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4erfcFeZe':
 ../../../libphobos/std/math.d:1345: undefined reference to `erfc'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math3erfFeZe':
 ../../../libphobos/std/math.d:1337: undefined reference to `erf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4cbrtFeZe':
 ../../../libphobos/std/math.d:1196: undefined reference to `cbrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4logbFeZe':
 ../../../libphobos/std/math.d:1137: undefined reference to `logb'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4log2FeZe':
 ../../../libphobos/std/math.d:1120: undefined reference to `log'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math3logFeZe':
 ../../../libphobos/std/math.d:1077: undefined reference to `log'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5log1pFeZe':
 ../../../libphobos/std/math.d:1107: undefined reference to `log1p'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5log10FeZe':
 ../../../libphobos/std/math.d:1090: undefined reference to `log10'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5ilogbFeZi':
 ../../../libphobos/std/math.d:1052: undefined reference to `ilogb'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4expiFeZc':
 ../../../libphobos/std/math.d:832: undefined reference to `cos'
 ../../../libphobos/std/math.d:832: undefined reference to `sin'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5expm1FeZe':
 ../../../libphobos/std/math.d:804: undefined reference to `expm1'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math3expFeZe':
 ../../../libphobos/std/math.d:774: undefined reference to `exp'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4sqrtFeZe':
 ../../../libphobos/std/math.d:721: undefined reference to `sqrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4sqrtFdZd':
 ../../../libphobos/std/math.d:719: undefined reference to `sqrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4sqrtFfZf':
 ../../../libphobos/std/math.d:717: undefined reference to `sqrtf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4tanhFeZe':
 ../../../libphobos/std/math.d:585: undefined reference to `tanh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4sinhFeZe':
 ../../../libphobos/std/math.d:574: undefined reference to `sinh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4coshFeZe':
 ../../../libphobos/std/math.d:563: undefined reference to `cosh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5atan2FeeZe':
 ../../../libphobos/std/math.d:553: undefined reference to `atan2'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4atanFeZe':
 ../../../libphobos/std/math.d:530: undefined reference to `atan'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4asinFeZe':
 ../../../libphobos/std/math.d:518: undefined reference to `asin'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4acosFeZe':
 ../../../libphobos/std/math.d:505: undefined reference to `acos'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls7signbitFfZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to 
 `__signbitf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls7signbitFdZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to 
 `__signbitd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls7signbitFeZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to 
 `__signbitd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls10fpclassifyFfZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to 
 `__fpclassifyf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls10fpclassifyFdZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to 
 `__fpclassifyd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls10fpclassifyFeZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to 
 `__fpclassifyd'
Jul 23 2008
prev sibling parent Lars Ivar Igesund <larsivar igesund.net> writes:
Vincent Richomme wrote:

 Hi,
 
 Sorry to participate to this discussion but we may have some common goals.
 Actually my company is actually working on generating a cross-compiler
 running on windows CE device.
 We have almost finished, there are some minors bugs but it's pretty close.
 Now I agree with you it would be great if we could compile with no
 dependencies to libphobos and actually it's possible if you pass
 -nophoboslib to linker.
 But more generally we are working on a framework called Gynoid that
 targets embedded platforms(Windows CE, Symbian, Darwin) and it would be
 great if we could add support for PSP...
 
 There something I don't understand in your sentence below :
 
  > Would it be possible to use a stripped down version of Tango orPhobos,
  > perhaps something that has the base type/classinfo and memory
  > management stuff and leave the rest alone? I just need auto memory
  > management and classes and I can use all the sce* psp sdk functions for
  > other things.
 
 I thought that memory management was part of the language and not in
 phobos lib, in this case I really agree that it would be interesting to
 remove libphobos dependency and to allow developpers to developp their
 own lib.
The Garbage Collector, threading plus some language support routines (array operations in particular) are part of libphobos. Passing -nophoboslib generally means you need to pass something else with enough functionality. You probably don't want to do that yourself, as parts of it are very dependent on the compiler (or the other way round). With Tango, whatever you want to achieve, will be easier. In Tango, the tango.* namespace/imports (roughly equivalent to std.* in Phobos) is a separate library, and the runtime (language support) one library (typically called libtango-base-* where the * is the compiler). Going further, this runtime is cleanly divided into 3 separate parts, the GC, compiler specific stuff (Tango currently has support for GDC and DMD), and common stuff (non-GC functionality common for all compilers, like threading + some smaller features not present in Phobos). If one for some reason do wish to replace parts of the runtime, this will be much easier with this setup. In Tango, the interface provided by the runtime is well specified, and Tangobos (a Phobos port) in addition to Tango works on top of it. -- Lars Ivar Igesund blog at http://larsivi.net DSource, #d.tango & #D: larsivi Dancing the Tango
Jul 23 2008
prev sibling parent reply Kostas Karanikolas <k_karanikolas hotmail.com> writes:
Thanks John, for the pointer on libm, that indeed fixed my linker errors.

I've managed to get the libgphobos runtime working on the PSP, and the examples
I tried from http://www.dsource.org/projects/tutorials/wiki appear to work ! 

I had to make a tiny change in libgphobos though. I've had to rename the
libgphobos' c-startup function (phobos/internal/cmain.d) (which jumps into
d-main) into a name other than "main" so that it can be called from the PSPSDK
main. 

For those interested I've included my patch on libphobos as well as a simple
PSP Application (Makefile included). 
http://www.mediafire.com/?xlizxgmm0vl
Obviously for this to work you need to patch and build libgphobos.

Any people interested in this, let me know how you get on.

I've also had a go at compiling tango, but it doesn't look like a trivial task.
Initially the psp's arch is not detected by autoconf, and even by hacking the
detection, it still stops long before compiling anything. Perhaps someone with
more insight into tango can offer advice on how to port it.

BTW John, I haven't encountered any problems with printfs in my code so far (in
this or other unrelated projects). Perhaps you aren't using the latest version
of the SDK ?


John Grindstaff Wrote:

 Thanks for listing the compile flags. I successfully built an executable 
 but there was no libgphobos.a appearing--which prevented me from 
 instantiating any classes or structs in my test example (which operates 
 similar to yours--an extern'd d function called from C).
 
 Would it be possible to use a stripped down version of Tango or Phobos, 
 perhaps something that has the base type/classinfo and memory management 
 stuff and leave the rest alone? I just need auto memory management and 
 classes and I can use all the sce* psp sdk functions for other things.
 
 BTW, you might want to use pspDebugScreenPrintf and pspDebugScreenInit 
 instead of printf for the C code. Last time I checked, they are very 
 different and printf doesn't work.
 
 Kostas Karanikolas wrote:
 Hi, 
 I was intrigued enough to have another go at compiling GDC for the PSP (my
previous attempt half a year ago did not get me very far), and I can say that
at least the toolchain builds fine (for D 1.0) with a working compiler and a
libgphobos. (When I enabled D 2.0, the toolchain build stopped with compiler
errors)
 
 Here's what my psp-gdc -v produces:
 
 Using built-in specs.
 Target: psp
 Configured with: ../configure --prefix=/pspdev --target=psp
--enable-languages=c,d,c++ --with-newlib --enable-cxx-flags=-G0
--disable-libssp --enable-static --disable-shared
 Thread model: single
 gcc version 4.1.0 20060228 ( gdc 0.24, using dmd 1.030) (PSPDEV 20060507)
 
 BTW you can also see the configure flags I used.
 
 I wanted to see if I could get a working executable. So my test was, to have D
function be called from a C main function (because the PSP sdk has some special
initialization macros that I guess need to be defined to get a working
executable). However when linking the program I got a lot of linker errors,
originating from libphobos/std/math.d and libphobos/gcc/cbridge_math.c. My
guess is that these come from the lack of double support on the psp toolchain.
Could that be the case, or is it some kind of misconfiguration? Also is there
some way of fixing this?
 
 Thanks!
 
 Here is the test program:
 ----------------------------------
 testd.d:
 import std.stdio;
 
 extern(C) void dfunc()
 {
         printf("Hello from D");
 }
 
 ----------------------------------
 #include <pspkernel.h>
 #include <stdio.h>
 PSP_MODULE_INFO("test", 0, 1, 1);
 PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
 extern void dfunc();
 int main(int argc, char *argv[])
 {
         printf("Hello World\n");
         dfunc();
         return 0;
 }
 
 ----------------------------------
 Here are the actual errors:
 
 psp-gcc -I. -I/pspdev/psp/sdk/include -O0 -g -G0 -Wall -D_PSP_FW_VERSION=150 
-L. -L/pspdev/psp/sdk/lib -specs=/pspdev/psp/sdk/lib/prxspecs
-Wl,-q,-T/pspdev/psp/sdk/lib/linkfile.prx   main.o testd.o
/pspdev/psp/sdk/lib/prxexports.o -lgphobos -lpspdebug -lpspdisplay -lpspge
-lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver
-lpsputility -lpspuser -lpspkernel -o test.elf
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4exp2FeZe':
 ../../../libphobos/std/math.d:785: undefined reference to `pow'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math9nextafterFddZd':
 ../../../libphobos/std/math.d:2137: undefined reference to `nextafter'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math9nextafterFffZf':
 ../../../libphobos/std/math.d:2126: undefined reference to `nextafterf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math9nextafterFeeZe':
 ../../../libphobos/std/math.d:2115: undefined reference to `nextafter'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math3powFeeZe':
 ../../../libphobos/std/math.d:2371: undefined reference to `pow'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math9remainderFeeZe':
 ../../../libphobos/std/math.d:1574: undefined reference to `remainder'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5truncFeZe':
 ../../../libphobos/std/math.d:1550: undefined reference to `trunc'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5roundFeZe':
 ../../../libphobos/std/math.d:1509: undefined reference to `round'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math9nearbyintFeZe':
 ../../../libphobos/std/math.d:1431: undefined reference to `nearbyint'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5floorFeZe':
 ../../../libphobos/std/math.d:1417: undefined reference to `floor'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4ceilFeZe':
 ../../../libphobos/std/math.d:1411: undefined reference to `ceil'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math6tgammaFeZe':
 ../../../libphobos/std/math.d:1402: undefined reference to `tgamma'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math6lgammaFeZe':
 ../../../libphobos/std/math.d:1365: undefined reference to `lgamma'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4erfcFeZe':
 ../../../libphobos/std/math.d:1345: undefined reference to `erfc'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math3erfFeZe':
 ../../../libphobos/std/math.d:1337: undefined reference to `erf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4cbrtFeZe':
 ../../../libphobos/std/math.d:1196: undefined reference to `cbrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4logbFeZe':
 ../../../libphobos/std/math.d:1137: undefined reference to `logb'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4log2FeZe':
 ../../../libphobos/std/math.d:1120: undefined reference to `log'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math3logFeZe':
 ../../../libphobos/std/math.d:1077: undefined reference to `log'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5log1pFeZe':
 ../../../libphobos/std/math.d:1107: undefined reference to `log1p'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5log10FeZe':
 ../../../libphobos/std/math.d:1090: undefined reference to `log10'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5ilogbFeZi':
 ../../../libphobos/std/math.d:1052: undefined reference to `ilogb'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4expiFeZc':
 ../../../libphobos/std/math.d:832: undefined reference to `cos'
 ../../../libphobos/std/math.d:832: undefined reference to `sin'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5expm1FeZe':
 ../../../libphobos/std/math.d:804: undefined reference to `expm1'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math3expFeZe':
 ../../../libphobos/std/math.d:774: undefined reference to `exp'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4sqrtFeZe':
 ../../../libphobos/std/math.d:721: undefined reference to `sqrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4sqrtFdZd':
 ../../../libphobos/std/math.d:719: undefined reference to `sqrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4sqrtFfZf':
 ../../../libphobos/std/math.d:717: undefined reference to `sqrtf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4tanhFeZe':
 ../../../libphobos/std/math.d:585: undefined reference to `tanh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4sinhFeZe':
 ../../../libphobos/std/math.d:574: undefined reference to `sinh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4coshFeZe':
 ../../../libphobos/std/math.d:563: undefined reference to `cosh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5atan2FeeZe':
 ../../../libphobos/std/math.d:553: undefined reference to `atan2'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4atanFeZe':
 ../../../libphobos/std/math.d:530: undefined reference to `atan'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4asinFeZe':
 ../../../libphobos/std/math.d:518: undefined reference to `asin'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4acosFeZe':
 ../../../libphobos/std/math.d:505: undefined reference to `acos'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls7signbitFfZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to `__signbitf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls7signbitFdZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to `__signbitd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls7signbitFeZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to `__signbitd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls10fpclassifyFfZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to
`__fpclassifyf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls10fpclassifyFdZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to
`__fpclassifyd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls10fpclassifyFeZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to
`__fpclassifyd'
Jul 24 2008
next sibling parent reply Lars Ivar Igesund <larsivar igesund.net> writes:
Kostas Karanikolas wrote:
 
 I've also had a go at compiling tango, but it doesn't look like a trivial
 task. Initially the psp's arch is not detected by autoconf, and even by
 hacking the detection, it still stops long before compiling anything.
 Perhaps someone with more insight into tango can offer advice on how to
 port it.
The configure part is probably just something not having been merged yet, unfortunately I don't think I'm the right man to solve that particular part. The specific errors you get would be nice to have though. -- Lars Ivar Igesund blog at http://larsivi.net DSource, #d.tango & #D: larsivi Dancing the Tango
Jul 24 2008
parent Karanikolas Kostas <k_karanikolas hotmail.com> writes:
Lars Ivar Igesund wrote:

 The configure part is probably just something not having been merged 
 yet, unfortunately I don't think I'm the right man to solve that 
 particular part. The specific errors you get would be nice to have 
 though.
Hi Lars, First of all here's a patch to add the psp as a target to the configure script. I extracted it from the PSP toolchain patches. This patch is against svn tango-0.99.7, but it's really simple and probably would work on other versions as well. I applied it in lib/compiler/gdc (with -p1) Now having done that. I tried to run 'build-gdc-x.sh psp', but unfortunately it makes configure think that my host is also a psp. -------- ./build-gdc-x.sh psp checking build system type... powerpc-apple-darwin9.4.0 checking host system type... mipsallegrexel-psp-elf checking target system type... mipsallegrexel-psp-elf checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... ./install-sh -c -d checking for gawk... gawk checking whether make sets $(MAKE)... yes checking for psp-strip... psp-strip checking for psp-gcc... psp-gcc checking for C compiler default output file name... configure: error: C compiler cannot create executables -------- So I moved on to compiler/gdc/configure to try and get it to work A minor problem is that even though I'm cross compiling configure assumes that the "gdc" the executable is DMD, so I bypassed that with an environment variable so in the and I ran: -------- GDC=psp-gdc ./configure --prefix="$PSPDEV" --target="psp" --enable-phobos-config-dir=/somewhere/myphobos-config-dir checking build system type... powerpc-apple-darwin9.4.0 checking host system type... powerpc-apple-darwin9.4.0 checking target system type... mipsallegrexel-psp-elf checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... ./install-sh -c -d checking for gawk... gawk checking whether make sets $(MAKE)... yes checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... yes checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking for ranlib... ranlib checking for a BSD-compatible install... /usr/bin/install -c checking whether make sets $(MAKE)... (cached) yes checking If psp-gdc can compile D sources... yes checking D GCC version... 4.1.0 checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking stdio.h usability... yes checking stdio.h presence... yes checking for stdio.h... yes checking dirent.h usability... yes checking dirent.h presence... yes checking for dirent.h... yes checking for sizeof(FILE)... yes checking for sizeof(DIR)... yes checking for cos in -lm... yes checking for acosl... yes checking for truncl... yes checking for sqrtf... yes checking for trunc... yes checking for nearbyint... yes checking for round... yes checking for tgamma... yes checking for nan... yes checking for exp2... yes checking for log2... yes checking for fpclassify and signbit... yes checking for execvpe... no checking for spawnvp... no checking for fwide... yes checking for getdelim... no checking for fgetln... yes checking for fgetline... no checking for flockfile... yes checking for funlockfile... yes checking for putc_unlocked... yes checking for getc_unlocked... yes checking for putwc_unlocked... no checking for getwc_unlocked... no checking for strtold... yes checking for tm_gmtoff... yes checking for timezone... yes checking for _timezone... no checking for snprintf... yes checking for vsnprintf... yes checking for mmap... yes checking for __libc_stack_end... no configure: error: No usable data segment information -------- This is the point I'm stuck at the moment. Thanks
Jul 24 2008
prev sibling next sibling parent reply John Grindstaff <perfectcell14 yahoo.com> writes:
Thanks. How exactly do you compile libgphobos.a for the PSP? I tried it 
but got errors about missing files. What directory should I be in and 
what command do I type?

Also, I think the D's main function gets compiled to "_Dmain" so that 
should be extern'able in C as "_Dmain."

Kostas Karanikolas wrote:
 Thanks John, for the pointer on libm, that indeed fixed my linker errors.
 
 I've managed to get the libgphobos runtime working on the PSP, and the
examples I tried from http://www.dsource.org/projects/tutorials/wiki appear to
work ! 
 
 I had to make a tiny change in libgphobos though. I've had to rename the
libgphobos' c-startup function (phobos/internal/cmain.d) (which jumps into
d-main) into a name other than "main" so that it can be called from the PSPSDK
main. 
 
 For those interested I've included my patch on libphobos as well as a simple
PSP Application (Makefile included). 
 http://www.mediafire.com/?xlizxgmm0vl
 Obviously for this to work you need to patch and build libgphobos.
 
 Any people interested in this, let me know how you get on.
 
 I've also had a go at compiling tango, but it doesn't look like a trivial
task. Initially the psp's arch is not detected by autoconf, and even by hacking
the detection, it still stops long before compiling anything. Perhaps someone
with more insight into tango can offer advice on how to port it.
 
 BTW John, I haven't encountered any problems with printfs in my code so far
(in this or other unrelated projects). Perhaps you aren't using the latest
version of the SDK ?
 
 
 John Grindstaff Wrote:
 
 Thanks for listing the compile flags. I successfully built an executable 
 but there was no libgphobos.a appearing--which prevented me from 
 instantiating any classes or structs in my test example (which operates 
 similar to yours--an extern'd d function called from C).

 Would it be possible to use a stripped down version of Tango or Phobos, 
 perhaps something that has the base type/classinfo and memory management 
 stuff and leave the rest alone? I just need auto memory management and 
 classes and I can use all the sce* psp sdk functions for other things.

 BTW, you might want to use pspDebugScreenPrintf and pspDebugScreenInit 
 instead of printf for the C code. Last time I checked, they are very 
 different and printf doesn't work.

 Kostas Karanikolas wrote:
 Hi, 
 I was intrigued enough to have another go at compiling GDC for the PSP (my
previous attempt half a year ago did not get me very far), and I can say that
at least the toolchain builds fine (for D 1.0) with a working compiler and a
libgphobos. (When I enabled D 2.0, the toolchain build stopped with compiler
errors)

 Here's what my psp-gdc -v produces:

 Using built-in specs.
 Target: psp
 Configured with: ../configure --prefix=/pspdev --target=psp
--enable-languages=c,d,c++ --with-newlib --enable-cxx-flags=-G0
--disable-libssp --enable-static --disable-shared
 Thread model: single
 gcc version 4.1.0 20060228 ( gdc 0.24, using dmd 1.030) (PSPDEV 20060507)

 BTW you can also see the configure flags I used.

 I wanted to see if I could get a working executable. So my test was, to have D
function be called from a C main function (because the PSP sdk has some special
initialization macros that I guess need to be defined to get a working
executable). However when linking the program I got a lot of linker errors,
originating from libphobos/std/math.d and libphobos/gcc/cbridge_math.c. My
guess is that these come from the lack of double support on the psp toolchain.
Could that be the case, or is it some kind of misconfiguration? Also is there
some way of fixing this?

 Thanks!

 Here is the test program:
 ----------------------------------
 testd.d:
 import std.stdio;

 extern(C) void dfunc()
 {
         printf("Hello from D");
 }

 ----------------------------------
 #include <pspkernel.h>
 #include <stdio.h>
 PSP_MODULE_INFO("test", 0, 1, 1);
 PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
 extern void dfunc();
 int main(int argc, char *argv[])
 {
         printf("Hello World\n");
         dfunc();
         return 0;
 }

 ----------------------------------
 Here are the actual errors:

 psp-gcc -I. -I/pspdev/psp/sdk/include -O0 -g -G0 -Wall -D_PSP_FW_VERSION=150 
-L. -L/pspdev/psp/sdk/lib -specs=/pspdev/psp/sdk/lib/prxspecs
-Wl,-q,-T/pspdev/psp/sdk/lib/linkfile.prx   main.o testd.o
/pspdev/psp/sdk/lib/prxexports.o -lgphobos -lpspdebug -lpspdisplay -lpspge
-lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver
-lpsputility -lpspuser -lpspkernel -o test.elf
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4exp2FeZe':
 ../../../libphobos/std/math.d:785: undefined reference to `pow'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math9nextafterFddZd':
 ../../../libphobos/std/math.d:2137: undefined reference to `nextafter'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math9nextafterFffZf':
 ../../../libphobos/std/math.d:2126: undefined reference to `nextafterf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math9nextafterFeeZe':
 ../../../libphobos/std/math.d:2115: undefined reference to `nextafter'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math3powFeeZe':
 ../../../libphobos/std/math.d:2371: undefined reference to `pow'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math9remainderFeeZe':
 ../../../libphobos/std/math.d:1574: undefined reference to `remainder'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5truncFeZe':
 ../../../libphobos/std/math.d:1550: undefined reference to `trunc'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5roundFeZe':
 ../../../libphobos/std/math.d:1509: undefined reference to `round'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math9nearbyintFeZe':
 ../../../libphobos/std/math.d:1431: undefined reference to `nearbyint'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5floorFeZe':
 ../../../libphobos/std/math.d:1417: undefined reference to `floor'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4ceilFeZe':
 ../../../libphobos/std/math.d:1411: undefined reference to `ceil'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math6tgammaFeZe':
 ../../../libphobos/std/math.d:1402: undefined reference to `tgamma'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math6lgammaFeZe':
 ../../../libphobos/std/math.d:1365: undefined reference to `lgamma'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4erfcFeZe':
 ../../../libphobos/std/math.d:1345: undefined reference to `erfc'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math3erfFeZe':
 ../../../libphobos/std/math.d:1337: undefined reference to `erf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4cbrtFeZe':
 ../../../libphobos/std/math.d:1196: undefined reference to `cbrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4logbFeZe':
 ../../../libphobos/std/math.d:1137: undefined reference to `logb'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4log2FeZe':
 ../../../libphobos/std/math.d:1120: undefined reference to `log'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math3logFeZe':
 ../../../libphobos/std/math.d:1077: undefined reference to `log'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5log1pFeZe':
 ../../../libphobos/std/math.d:1107: undefined reference to `log1p'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5log10FeZe':
 ../../../libphobos/std/math.d:1090: undefined reference to `log10'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5ilogbFeZi':
 ../../../libphobos/std/math.d:1052: undefined reference to `ilogb'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4expiFeZc':
 ../../../libphobos/std/math.d:832: undefined reference to `cos'
 ../../../libphobos/std/math.d:832: undefined reference to `sin'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5expm1FeZe':
 ../../../libphobos/std/math.d:804: undefined reference to `expm1'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math3expFeZe':
 ../../../libphobos/std/math.d:774: undefined reference to `exp'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4sqrtFeZe':
 ../../../libphobos/std/math.d:721: undefined reference to `sqrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4sqrtFdZd':
 ../../../libphobos/std/math.d:719: undefined reference to `sqrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4sqrtFfZf':
 ../../../libphobos/std/math.d:717: undefined reference to `sqrtf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4tanhFeZe':
 ../../../libphobos/std/math.d:585: undefined reference to `tanh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4sinhFeZe':
 ../../../libphobos/std/math.d:574: undefined reference to `sinh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4coshFeZe':
 ../../../libphobos/std/math.d:563: undefined reference to `cosh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5atan2FeeZe':
 ../../../libphobos/std/math.d:553: undefined reference to `atan2'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4atanFeZe':
 ../../../libphobos/std/math.d:530: undefined reference to `atan'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4asinFeZe':
 ../../../libphobos/std/math.d:518: undefined reference to `asin'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4acosFeZe':
 ../../../libphobos/std/math.d:505: undefined reference to `acos'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls7signbitFfZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to `__signbitf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls7signbitFdZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to `__signbitd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls7signbitFeZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to `__signbitd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls10fpclassifyFfZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to
`__fpclassifyf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls10fpclassifyFdZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to
`__fpclassifyd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls10fpclassifyFeZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to
`__fpclassifyd'
Jul 24 2008
parent John Grindstaff <perfectcell14 yahoo.com> writes:
To clarify, I try to enter the gcc-4.1.0/gcc/d/phobos directory and do 
./configure but I get this:
configure: error: cannot find install-sh or install.sh in . ./.. ./../..
So I'm not exactly what to do. If I put a blank install.sh file I get 
this error:
configure: error: cannot run /bin/bash ./config.sub

 Thanks. How exactly do you compile libgphobos.a for the PSP? I tried it 
 but got errors about missing files. What directory should I be in and 
 what command do I type?
 
 Also, I think the D's main function gets compiled to "_Dmain" so that 
 should be extern'able in C as "_Dmain."
 
 Kostas Karanikolas wrote:
 Thanks John, for the pointer on libm, that indeed fixed my linker errors.

 I've managed to get the libgphobos runtime working on the PSP, and the 
 examples I tried from http://www.dsource.org/projects/tutorials/wiki 
 appear to work !
 I had to make a tiny change in libgphobos though. I've had to rename 
 the libgphobos' c-startup function (phobos/internal/cmain.d) (which 
 jumps into d-main) into a name other than "main" so that it can be 
 called from the PSPSDK main.
 For those interested I've included my patch on libphobos as well as a 
 simple PSP Application (Makefile included). 
 http://www.mediafire.com/?xlizxgmm0vl
 Obviously for this to work you need to patch and build libgphobos.

 Any people interested in this, let me know how you get on.

 I've also had a go at compiling tango, but it doesn't look like a 
 trivial task. Initially the psp's arch is not detected by autoconf, 
 and even by hacking the detection, it still stops long before 
 compiling anything. Perhaps someone with more insight into tango can 
 offer advice on how to port it.

 BTW John, I haven't encountered any problems with printfs in my code 
 so far (in this or other unrelated projects). Perhaps you aren't using 
 the latest version of the SDK ?


 John Grindstaff Wrote:

 Thanks for listing the compile flags. I successfully built an 
 executable but there was no libgphobos.a appearing--which prevented 
 me from instantiating any classes or structs in my test example 
 (which operates similar to yours--an extern'd d function called from C).

 Would it be possible to use a stripped down version of Tango or 
 Phobos, perhaps something that has the base type/classinfo and memory 
 management stuff and leave the rest alone? I just need auto memory 
 management and classes and I can use all the sce* psp sdk functions 
 for other things.

 BTW, you might want to use pspDebugScreenPrintf and 
 pspDebugScreenInit instead of printf for the C code. Last time I 
 checked, they are very different and printf doesn't work.

 Kostas Karanikolas wrote:
 Hi, I was intrigued enough to have another go at compiling GDC for 
 the PSP (my previous attempt half a year ago did not get me very 
 far), and I can say that at least the toolchain builds fine (for D 
 1.0) with a working compiler and a libgphobos. (When I enabled D 
 2.0, the toolchain build stopped with compiler errors)

 Here's what my psp-gdc -v produces:

 Using built-in specs.
 Target: psp
 Configured with: ../configure --prefix=/pspdev --target=psp 
 --enable-languages=c,d,c++ --with-newlib --enable-cxx-flags=-G0 
 --disable-libssp --enable-static --disable-shared
 Thread model: single
 gcc version 4.1.0 20060228 ( gdc 0.24, using dmd 1.030) (PSPDEV 
 20060507)

 BTW you can also see the configure flags I used.

 I wanted to see if I could get a working executable. So my test was, 
 to have D function be called from a C main function (because the PSP 
 sdk has some special initialization macros that I guess need to be 
 defined to get a working executable). However when linking the 
 program I got a lot of linker errors, originating from 
 libphobos/std/math.d and libphobos/gcc/cbridge_math.c. My guess is 
 that these come from the lack of double support on the psp 
 toolchain. Could that be the case, or is it some kind of 
 misconfiguration? Also is there some way of fixing this?

 Thanks!

 Here is the test program:
 ----------------------------------
 testd.d:
 import std.stdio;

 extern(C) void dfunc()
 {
         printf("Hello from D");
 }

 ----------------------------------
 #include <pspkernel.h>
 #include <stdio.h>
 PSP_MODULE_INFO("test", 0, 1, 1);
 PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
 extern void dfunc();
 int main(int argc, char *argv[])
 {
         printf("Hello World\n");
         dfunc();
         return 0;
 }

 ----------------------------------
 Here are the actual errors:

 psp-gcc -I. -I/pspdev/psp/sdk/include -O0 -g -G0 -Wall 
 -D_PSP_FW_VERSION=150  -L. -L/pspdev/psp/sdk/lib 
 -specs=/pspdev/psp/sdk/lib/prxspecs 
 -Wl,-q,-T/pspdev/psp/sdk/lib/linkfile.prx   main.o testd.o 
 /pspdev/psp/sdk/lib/prxexports.o -lgphobos -lpspdebug -lpspdisplay 
 -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl 
 -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o test.elf
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4exp2FeZe':
 ../../../libphobos/std/math.d:785: undefined reference to `pow'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math9nextafterFddZd':
 ../../../libphobos/std/math.d:2137: undefined reference to `nextafter'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math9nextafterFffZf':
 ../../../libphobos/std/math.d:2126: undefined reference to `nextafterf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math9nextafterFeeZe':
 ../../../libphobos/std/math.d:2115: undefined reference to `nextafter'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math3powFeeZe':
 ../../../libphobos/std/math.d:2371: undefined reference to `pow'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math9remainderFeeZe':
 ../../../libphobos/std/math.d:1574: undefined reference to `remainder'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5truncFeZe':
 ../../../libphobos/std/math.d:1550: undefined reference to `trunc'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5roundFeZe':
 ../../../libphobos/std/math.d:1509: undefined reference to `round'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math9nearbyintFeZe':
 ../../../libphobos/std/math.d:1431: undefined reference to `nearbyint'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5floorFeZe':
 ../../../libphobos/std/math.d:1417: undefined reference to `floor'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4ceilFeZe':
 ../../../libphobos/std/math.d:1411: undefined reference to `ceil'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math6tgammaFeZe':
 ../../../libphobos/std/math.d:1402: undefined reference to `tgamma'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math6lgammaFeZe':
 ../../../libphobos/std/math.d:1365: undefined reference to `lgamma'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4erfcFeZe':
 ../../../libphobos/std/math.d:1345: undefined reference to `erfc'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math3erfFeZe':
 ../../../libphobos/std/math.d:1337: undefined reference to `erf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4cbrtFeZe':
 ../../../libphobos/std/math.d:1196: undefined reference to `cbrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4logbFeZe':
 ../../../libphobos/std/math.d:1137: undefined reference to `logb'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4log2FeZe':
 ../../../libphobos/std/math.d:1120: undefined reference to `log'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math3logFeZe':
 ../../../libphobos/std/math.d:1077: undefined reference to `log'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5log1pFeZe':
 ../../../libphobos/std/math.d:1107: undefined reference to `log1p'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5log10FeZe':
 ../../../libphobos/std/math.d:1090: undefined reference to `log10'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5ilogbFeZi':
 ../../../libphobos/std/math.d:1052: undefined reference to `ilogb'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4expiFeZc':
 ../../../libphobos/std/math.d:832: undefined reference to `cos'
 ../../../libphobos/std/math.d:832: undefined reference to `sin'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5expm1FeZe':
 ../../../libphobos/std/math.d:804: undefined reference to `expm1'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math3expFeZe':
 ../../../libphobos/std/math.d:774: undefined reference to `exp'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4sqrtFeZe':
 ../../../libphobos/std/math.d:721: undefined reference to `sqrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4sqrtFdZd':
 ../../../libphobos/std/math.d:719: undefined reference to `sqrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4sqrtFfZf':
 ../../../libphobos/std/math.d:717: undefined reference to `sqrtf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4tanhFeZe':
 ../../../libphobos/std/math.d:585: undefined reference to `tanh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4sinhFeZe':
 ../../../libphobos/std/math.d:574: undefined reference to `sinh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4coshFeZe':
 ../../../libphobos/std/math.d:563: undefined reference to `cosh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5atan2FeeZe':
 ../../../libphobos/std/math.d:553: undefined reference to `atan2'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4atanFeZe':
 ../../../libphobos/std/math.d:530: undefined reference to `atan'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4asinFeZe':
 ../../../libphobos/std/math.d:518: undefined reference to `asin'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4acosFeZe':
 ../../../libphobos/std/math.d:505: undefined reference to `acos'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls7signbitFfZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to 
 `__signbitf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls7signbitFdZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to 
 `__signbitd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls7signbitFeZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to 
 `__signbitd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls10fpclassifyFfZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to 
 `__fpclassifyf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls10fpclassifyFdZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to 
 `__fpclassifyd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls10fpclassifyFeZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to 
 `__fpclassifyd'
Jul 24 2008
prev sibling parent reply David Friedman <dvdfrdmn users.ess-eff.net> writes:
Assuming the C main() in libgphobos is not actually interfering with the 
  PSP SDK (e.g., duplicate symbols), you do not have to rename it.  You 
can call the following function which exists for exactly this purpose.

extern (C) int _d_run_Dmain(int argc, char **argv);

David

Kostas Karanikolas wrote:
 Thanks John, for the pointer on libm, that indeed fixed my linker errors.
 
 I've managed to get the libgphobos runtime working on the PSP, and the
examples I tried from http://www.dsource.org/projects/tutorials/wiki appear to
work ! 
 
 I had to make a tiny change in libgphobos though. I've had to rename the
libgphobos' c-startup function (phobos/internal/cmain.d) (which jumps into
d-main) into a name other than "main" so that it can be called from the PSPSDK
main. 
 
 For those interested I've included my patch on libphobos as well as a simple
PSP Application (Makefile included). 
 http://www.mediafire.com/?xlizxgmm0vl
 Obviously for this to work you need to patch and build libgphobos.
 
 Any people interested in this, let me know how you get on.
 
 I've also had a go at compiling tango, but it doesn't look like a trivial
task. Initially the psp's arch is not detected by autoconf, and even by hacking
the detection, it still stops long before compiling anything. Perhaps someone
with more insight into tango can offer advice on how to port it.
 
 BTW John, I haven't encountered any problems with printfs in my code so far
(in this or other unrelated projects). Perhaps you aren't using the latest
version of the SDK ?
 
 
 John Grindstaff Wrote:
 
 Thanks for listing the compile flags. I successfully built an executable 
 but there was no libgphobos.a appearing--which prevented me from 
 instantiating any classes or structs in my test example (which operates 
 similar to yours--an extern'd d function called from C).

 Would it be possible to use a stripped down version of Tango or Phobos, 
 perhaps something that has the base type/classinfo and memory management 
 stuff and leave the rest alone? I just need auto memory management and 
 classes and I can use all the sce* psp sdk functions for other things.

 BTW, you might want to use pspDebugScreenPrintf and pspDebugScreenInit 
 instead of printf for the C code. Last time I checked, they are very 
 different and printf doesn't work.

 Kostas Karanikolas wrote:
 Hi, 
 I was intrigued enough to have another go at compiling GDC for the PSP (my
previous attempt half a year ago did not get me very far), and I can say that
at least the toolchain builds fine (for D 1.0) with a working compiler and a
libgphobos. (When I enabled D 2.0, the toolchain build stopped with compiler
errors)

 Here's what my psp-gdc -v produces:

 Using built-in specs.
 Target: psp
 Configured with: ../configure --prefix=/pspdev --target=psp
--enable-languages=c,d,c++ --with-newlib --enable-cxx-flags=-G0
--disable-libssp --enable-static --disable-shared
 Thread model: single
 gcc version 4.1.0 20060228 ( gdc 0.24, using dmd 1.030) (PSPDEV 20060507)

 BTW you can also see the configure flags I used.

 I wanted to see if I could get a working executable. So my test was, to have D
function be called from a C main function (because the PSP sdk has some special
initialization macros that I guess need to be defined to get a working
executable). However when linking the program I got a lot of linker errors,
originating from libphobos/std/math.d and libphobos/gcc/cbridge_math.c. My
guess is that these come from the lack of double support on the psp toolchain.
Could that be the case, or is it some kind of misconfiguration? Also is there
some way of fixing this?

 Thanks!

 Here is the test program:
 ----------------------------------
 testd.d:
 import std.stdio;

 extern(C) void dfunc()
 {
         printf("Hello from D");
 }

 ----------------------------------
 #include <pspkernel.h>
 #include <stdio.h>
 PSP_MODULE_INFO("test", 0, 1, 1);
 PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
 extern void dfunc();
 int main(int argc, char *argv[])
 {
         printf("Hello World\n");
         dfunc();
         return 0;
 }

 ----------------------------------
 Here are the actual errors:

 psp-gcc -I. -I/pspdev/psp/sdk/include -O0 -g -G0 -Wall -D_PSP_FW_VERSION=150 
-L. -L/pspdev/psp/sdk/lib -specs=/pspdev/psp/sdk/lib/prxspecs
-Wl,-q,-T/pspdev/psp/sdk/lib/linkfile.prx   main.o testd.o
/pspdev/psp/sdk/lib/prxexports.o -lgphobos -lpspdebug -lpspdisplay -lpspge
-lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver
-lpsputility -lpspuser -lpspkernel -o test.elf
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4exp2FeZe':
 ../../../libphobos/std/math.d:785: undefined reference to `pow'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math9nextafterFddZd':
 ../../../libphobos/std/math.d:2137: undefined reference to `nextafter'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math9nextafterFffZf':
 ../../../libphobos/std/math.d:2126: undefined reference to `nextafterf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math9nextafterFeeZe':
 ../../../libphobos/std/math.d:2115: undefined reference to `nextafter'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math3powFeeZe':
 ../../../libphobos/std/math.d:2371: undefined reference to `pow'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math9remainderFeeZe':
 ../../../libphobos/std/math.d:1574: undefined reference to `remainder'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5truncFeZe':
 ../../../libphobos/std/math.d:1550: undefined reference to `trunc'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5roundFeZe':
 ../../../libphobos/std/math.d:1509: undefined reference to `round'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math9nearbyintFeZe':
 ../../../libphobos/std/math.d:1431: undefined reference to `nearbyint'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5floorFeZe':
 ../../../libphobos/std/math.d:1417: undefined reference to `floor'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4ceilFeZe':
 ../../../libphobos/std/math.d:1411: undefined reference to `ceil'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math6tgammaFeZe':
 ../../../libphobos/std/math.d:1402: undefined reference to `tgamma'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math6lgammaFeZe':
 ../../../libphobos/std/math.d:1365: undefined reference to `lgamma'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4erfcFeZe':
 ../../../libphobos/std/math.d:1345: undefined reference to `erfc'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math3erfFeZe':
 ../../../libphobos/std/math.d:1337: undefined reference to `erf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4cbrtFeZe':
 ../../../libphobos/std/math.d:1196: undefined reference to `cbrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4logbFeZe':
 ../../../libphobos/std/math.d:1137: undefined reference to `logb'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4log2FeZe':
 ../../../libphobos/std/math.d:1120: undefined reference to `log'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math3logFeZe':
 ../../../libphobos/std/math.d:1077: undefined reference to `log'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5log1pFeZe':
 ../../../libphobos/std/math.d:1107: undefined reference to `log1p'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5log10FeZe':
 ../../../libphobos/std/math.d:1090: undefined reference to `log10'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5ilogbFeZi':
 ../../../libphobos/std/math.d:1052: undefined reference to `ilogb'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4expiFeZc':
 ../../../libphobos/std/math.d:832: undefined reference to `cos'
 ../../../libphobos/std/math.d:832: undefined reference to `sin'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5expm1FeZe':
 ../../../libphobos/std/math.d:804: undefined reference to `expm1'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math3expFeZe':
 ../../../libphobos/std/math.d:774: undefined reference to `exp'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4sqrtFeZe':
 ../../../libphobos/std/math.d:721: undefined reference to `sqrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4sqrtFdZd':
 ../../../libphobos/std/math.d:719: undefined reference to `sqrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4sqrtFfZf':
 ../../../libphobos/std/math.d:717: undefined reference to `sqrtf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4tanhFeZe':
 ../../../libphobos/std/math.d:585: undefined reference to `tanh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4sinhFeZe':
 ../../../libphobos/std/math.d:574: undefined reference to `sinh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4coshFeZe':
 ../../../libphobos/std/math.d:563: undefined reference to `cosh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math5atan2FeeZe':
 ../../../libphobos/std/math.d:553: undefined reference to `atan2'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4atanFeZe':
 ../../../libphobos/std/math.d:530: undefined reference to `atan'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4asinFeZe':
 ../../../libphobos/std/math.d:518: undefined reference to `asin'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): In
function `_D3std4math4acosFeZe':
 ../../../libphobos/std/math.d:505: undefined reference to `acos'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls7signbitFfZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to `__signbitf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls7signbitFdZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to `__signbitd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls7signbitFeZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to `__signbitd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls10fpclassifyFfZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to
`__fpclassifyf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls10fpclassifyFdZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to
`__fpclassifyd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): In
function `_D3gcc5fpcls10fpclassifyFeZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to
`__fpclassifyd'
Jul 24 2008
parent reply FreekSh0w86 <perfectcell14 yahoo.com> writes:
Oh yeah that's true... I forgot because I made an example without 
libgphobos but that _would_ interfere. I don't have libgphobos.a 
compiled yet so I wouldn't know directly.
David Friedman wrote:
 Assuming the C main() in libgphobos is not actually interfering with the 
  PSP SDK (e.g., duplicate symbols), you do not have to rename it.  You 
 can call the following function which exists for exactly this purpose.
 
 extern (C) int _d_run_Dmain(int argc, char **argv);
 
 David
 
 Kostas Karanikolas wrote:
 Thanks John, for the pointer on libm, that indeed fixed my linker errors.

 I've managed to get the libgphobos runtime working on the PSP, and the 
 examples I tried from http://www.dsource.org/projects/tutorials/wiki 
 appear to work !
 I had to make a tiny change in libgphobos though. I've had to rename 
 the libgphobos' c-startup function (phobos/internal/cmain.d) (which 
 jumps into d-main) into a name other than "main" so that it can be 
 called from the PSPSDK main.
 For those interested I've included my patch on libphobos as well as a 
 simple PSP Application (Makefile included). 
 http://www.mediafire.com/?xlizxgmm0vl
 Obviously for this to work you need to patch and build libgphobos.

 Any people interested in this, let me know how you get on.

 I've also had a go at compiling tango, but it doesn't look like a 
 trivial task. Initially the psp's arch is not detected by autoconf, 
 and even by hacking the detection, it still stops long before 
 compiling anything. Perhaps someone with more insight into tango can 
 offer advice on how to port it.

 BTW John, I haven't encountered any problems with printfs in my code 
 so far (in this or other unrelated projects). Perhaps you aren't using 
 the latest version of the SDK ?


 John Grindstaff Wrote:

 Thanks for listing the compile flags. I successfully built an 
 executable but there was no libgphobos.a appearing--which prevented 
 me from instantiating any classes or structs in my test example 
 (which operates similar to yours--an extern'd d function called from C).

 Would it be possible to use a stripped down version of Tango or 
 Phobos, perhaps something that has the base type/classinfo and memory 
 management stuff and leave the rest alone? I just need auto memory 
 management and classes and I can use all the sce* psp sdk functions 
 for other things.

 BTW, you might want to use pspDebugScreenPrintf and 
 pspDebugScreenInit instead of printf for the C code. Last time I 
 checked, they are very different and printf doesn't work.

 Kostas Karanikolas wrote:
 Hi, I was intrigued enough to have another go at compiling GDC for 
 the PSP (my previous attempt half a year ago did not get me very 
 far), and I can say that at least the toolchain builds fine (for D 
 1.0) with a working compiler and a libgphobos. (When I enabled D 
 2.0, the toolchain build stopped with compiler errors)

 Here's what my psp-gdc -v produces:

 Using built-in specs.
 Target: psp
 Configured with: ../configure --prefix=/pspdev --target=psp 
 --enable-languages=c,d,c++ --with-newlib --enable-cxx-flags=-G0 
 --disable-libssp --enable-static --disable-shared
 Thread model: single
 gcc version 4.1.0 20060228 ( gdc 0.24, using dmd 1.030) (PSPDEV 
 20060507)

 BTW you can also see the configure flags I used.

 I wanted to see if I could get a working executable. So my test was, 
 to have D function be called from a C main function (because the PSP 
 sdk has some special initialization macros that I guess need to be 
 defined to get a working executable). However when linking the 
 program I got a lot of linker errors, originating from 
 libphobos/std/math.d and libphobos/gcc/cbridge_math.c. My guess is 
 that these come from the lack of double support on the psp 
 toolchain. Could that be the case, or is it some kind of 
 misconfiguration? Also is there some way of fixing this?

 Thanks!

 Here is the test program:
 ----------------------------------
 testd.d:
 import std.stdio;

 extern(C) void dfunc()
 {
         printf("Hello from D");
 }

 ----------------------------------
 #include <pspkernel.h>
 #include <stdio.h>
 PSP_MODULE_INFO("test", 0, 1, 1);
 PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
 extern void dfunc();
 int main(int argc, char *argv[])
 {
         printf("Hello World\n");
         dfunc();
         return 0;
 }

 ----------------------------------
 Here are the actual errors:

 psp-gcc -I. -I/pspdev/psp/sdk/include -O0 -g -G0 -Wall 
 -D_PSP_FW_VERSION=150  -L. -L/pspdev/psp/sdk/lib 
 -specs=/pspdev/psp/sdk/lib/prxspecs 
 -Wl,-q,-T/pspdev/psp/sdk/lib/linkfile.prx   main.o testd.o 
 /pspdev/psp/sdk/lib/prxexports.o -lgphobos -lpspdebug -lpspdisplay 
 -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl 
 -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o test.elf
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4exp2FeZe':
 ../../../libphobos/std/math.d:785: undefined reference to `pow'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math9nextafterFddZd':
 ../../../libphobos/std/math.d:2137: undefined reference to `nextafter'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math9nextafterFffZf':
 ../../../libphobos/std/math.d:2126: undefined reference to `nextafterf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math9nextafterFeeZe':
 ../../../libphobos/std/math.d:2115: undefined reference to `nextafter'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math3powFeeZe':
 ../../../libphobos/std/math.d:2371: undefined reference to `pow'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math9remainderFeeZe':
 ../../../libphobos/std/math.d:1574: undefined reference to `remainder'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5truncFeZe':
 ../../../libphobos/std/math.d:1550: undefined reference to `trunc'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5roundFeZe':
 ../../../libphobos/std/math.d:1509: undefined reference to `round'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math9nearbyintFeZe':
 ../../../libphobos/std/math.d:1431: undefined reference to `nearbyint'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5floorFeZe':
 ../../../libphobos/std/math.d:1417: undefined reference to `floor'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4ceilFeZe':
 ../../../libphobos/std/math.d:1411: undefined reference to `ceil'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math6tgammaFeZe':
 ../../../libphobos/std/math.d:1402: undefined reference to `tgamma'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math6lgammaFeZe':
 ../../../libphobos/std/math.d:1365: undefined reference to `lgamma'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4erfcFeZe':
 ../../../libphobos/std/math.d:1345: undefined reference to `erfc'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math3erfFeZe':
 ../../../libphobos/std/math.d:1337: undefined reference to `erf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4cbrtFeZe':
 ../../../libphobos/std/math.d:1196: undefined reference to `cbrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4logbFeZe':
 ../../../libphobos/std/math.d:1137: undefined reference to `logb'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4log2FeZe':
 ../../../libphobos/std/math.d:1120: undefined reference to `log'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math3logFeZe':
 ../../../libphobos/std/math.d:1077: undefined reference to `log'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5log1pFeZe':
 ../../../libphobos/std/math.d:1107: undefined reference to `log1p'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5log10FeZe':
 ../../../libphobos/std/math.d:1090: undefined reference to `log10'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5ilogbFeZi':
 ../../../libphobos/std/math.d:1052: undefined reference to `ilogb'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4expiFeZc':
 ../../../libphobos/std/math.d:832: undefined reference to `cos'
 ../../../libphobos/std/math.d:832: undefined reference to `sin'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5expm1FeZe':
 ../../../libphobos/std/math.d:804: undefined reference to `expm1'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math3expFeZe':
 ../../../libphobos/std/math.d:774: undefined reference to `exp'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4sqrtFeZe':
 ../../../libphobos/std/math.d:721: undefined reference to `sqrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4sqrtFdZd':
 ../../../libphobos/std/math.d:719: undefined reference to `sqrt'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4sqrtFfZf':
 ../../../libphobos/std/math.d:717: undefined reference to `sqrtf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4tanhFeZe':
 ../../../libphobos/std/math.d:585: undefined reference to `tanh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4sinhFeZe':
 ../../../libphobos/std/math.d:574: undefined reference to `sinh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4coshFeZe':
 ../../../libphobos/std/math.d:563: undefined reference to `cosh'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math5atan2FeeZe':
 ../../../libphobos/std/math.d:553: undefined reference to `atan2'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4atanFeZe':
 ../../../libphobos/std/math.d:530: undefined reference to `atan'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4asinFeZe':
 ../../../libphobos/std/math.d:518: undefined reference to `asin'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(math.o): 
 In function `_D3std4math4acosFeZe':
 ../../../libphobos/std/math.d:505: undefined reference to `acos'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls7signbitFfZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to 
 `__signbitf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls7signbitFdZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to 
 `__signbitd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls7signbitFeZi':
 ../../../libphobos/gcc/cbridge_math.c:39: undefined reference to 
 `__signbitd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls10fpclassifyFfZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to 
 `__fpclassifyf'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls10fpclassifyFdZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to 
 `__fpclassifyd'
 /pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_math.o): 
 In function `_D3gcc5fpcls10fpclassifyFeZi':
 ../../../libphobos/gcc/cbridge_math.c:38: undefined reference to 
 `__fpclassifyd'
Jul 24 2008
parent reply Kostas Karanikolas <k_karanikolas hotmail.com> writes:
John Grindstaff wrote:

 Thanks. How exactly do you compile libgphobos.a for the PSP? I tried it
 but got errors about missing files. What directory should I be in and
 what command do I type?
Build instructions First of all I'm running OSX Leopard on a PowerPC, so what you need to do may vary, not by much on a Unix system but potentially a lot on Windows. I assume you have the latest and complete psp toolchain. If not I suggest you try downloading & installing a prebuilt one or preferably use the "psptoolchain" build scripts found on: svn://svn.ps2dev.org/psp/trunk/psptoolchain Ok, here we go: 1. Make a temporary directory for your build mkdir pspd cd pspd 2. Setup environment paths export PSPDEV=/the/path/where/the/pspsdk/is/already/installed export PATH=$PATH:$PSPDEV/bin export C_INCLUDE_PATH="/opt/local/include" export CPLUS_INCLUDE_PATH="/opt/local/include" export LIBRARY_PATH="/opt/local/lib" 3. Download and unpack gcc wget --continue ftp://ftp.gnu.org/pub/gnu/gcc/gcc-4.1.0/gcc-4.1.0.tar.bz2 tar -xvjf gcc-4.1.0.tar.bz2 4. Download and apply psp toolchain patches to gcc svn export svn://svn.ps2dev.org/psp/trunk/psptoolchain/patches/gcc-4.1.0-PSP.patch cd gcc-4.1.0 patch -p1 <../gcc-4.1.0-PSP.patch 5. Download and setup gdc cd gcc svn co https://dgcc.svn.sourceforge.net/svnroot/dgcc/trunk/d cd .. ./gcc/d/setup-gcc.sh --d-language-version=1 5.5 Optional step, for those compiling GCC under Leopard/PowerPC. Apply a patch to fix some GCC compiler errors cd gcc/config/rs6000/ wget "http://trac.macports.org/attachment/ticket/13191/gcc_patch?format=raw" -Oleopard_ppc.patch patch -p1 <leopard_ppc.patch cd ../../../ 6. Configure, build, and install gcc (gdc & libgphobos included) mkdir build-psp cd build-psp ../configure --prefix="$PSPDEV" --target="psp" --enable-languages="c,d,c++" --with-newlib --enable-cxx-flags="-G0" --disable-libssp --enable-static --disable-shared CFLAGS_FOR_TARGET="-G0" make make install And that should be enough to get a funcional GCC with D/libgphobos As far as my small libgphobos patch is concerned, I agree that it might not be necessary. However given the temperamental behaviour of the linker (especially when it comes to the order of the PSPSDK libraries) I removed the extra definition of main, to make sure that if no main is declared a linker error would be raised. At any rate it works fine without the change. Have fun ! Kostas FreekSh0w86 wrote:
 Oh yeah that's true... I forgot because I made an example without 
 libgphobos but that _would_ interfere. I don't have libgphobos.a 
 compiled yet so I wouldn't know directly. David Friedman wrote:
 Assuming the C main() in libgphobos is not actually interfering 
 with the  PSP SDK (e.g., duplicate symbols), you do not have to 
 rename it. You can call the following function which exists for 
 exactly this purpose.
 
 extern (C) int _d_run_Dmain(int argc, char **argv);
 
 David
 
Jul 25 2008
next sibling parent reply Vince <toto toto.fr> writes:
Hi Kostas,

I am interested in your PSP port and I would like to add it to my cegdc 
(gdc for window CE), it could be interesting to have a gcc for embedded 
targets.
I am working on scripts to build differents versions, something like :


sh build-gdc.sh --target psp or
sh build-gdc.sh --target arm-mingw32ce
...










Kostas Karanikolas a écrit :
 John Grindstaff wrote:
 
 Thanks. How exactly do you compile libgphobos.a for the PSP? I tried it
 but got errors about missing files. What directory should I be in and
 what command do I type?
Build instructions First of all I'm running OSX Leopard on a PowerPC, so what you need to do may vary, not by much on a Unix system but potentially a lot on Windows. I assume you have the latest and complete psp toolchain. If not I suggest you try downloading & installing a prebuilt one or preferably use the "psptoolchain" build scripts found on: svn://svn.ps2dev.org/psp/trunk/psptoolchain Ok, here we go: 1. Make a temporary directory for your build mkdir pspd cd pspd 2. Setup environment paths export PSPDEV=/the/path/where/the/pspsdk/is/already/installed export PATH=$PATH:$PSPDEV/bin export C_INCLUDE_PATH="/opt/local/include" export CPLUS_INCLUDE_PATH="/opt/local/include" export LIBRARY_PATH="/opt/local/lib" 3. Download and unpack gcc wget --continue ftp://ftp.gnu.org/pub/gnu/gcc/gcc-4.1.0/gcc-4.1.0.tar.bz2 tar -xvjf gcc-4.1.0.tar.bz2 4. Download and apply psp toolchain patches to gcc svn export svn://svn.ps2dev.org/psp/trunk/psptoolchain/patches/gcc-4.1.0-PSP.patch cd gcc-4.1.0 patch -p1 <../gcc-4.1.0-PSP.patch 5. Download and setup gdc cd gcc svn co https://dgcc.svn.sourceforge.net/svnroot/dgcc/trunk/d cd .. ./gcc/d/setup-gcc.sh --d-language-version=1 5.5 Optional step, for those compiling GCC under Leopard/PowerPC. Apply a patch to fix some GCC compiler errors cd gcc/config/rs6000/ wget "http://trac.macports.org/attachment/ticket/13191/gcc_patch?format=raw" -Oleopard_ppc.patch patch -p1 <leopard_ppc.patch cd ../../../ 6. Configure, build, and install gcc (gdc & libgphobos included) mkdir build-psp cd build-psp ../configure --prefix="$PSPDEV" --target="psp" --enable-languages="c,d,c++" --with-newlib --enable-cxx-flags="-G0" --disable-libssp --enable-static --disable-shared CFLAGS_FOR_TARGET="-G0" make make install And that should be enough to get a funcional GCC with D/libgphobos As far as my small libgphobos patch is concerned, I agree that it might not be necessary. However given the temperamental behaviour of the linker (especially when it comes to the order of the PSPSDK libraries) I removed the extra definition of main, to make sure that if no main is declared a linker error would be raised. At any rate it works fine without the change. Have fun ! Kostas FreekSh0w86 wrote:
 Oh yeah that's true... I forgot because I made an example without 
 libgphobos but that _would_ interfere. I don't have libgphobos.a 
 compiled yet so I wouldn't know directly. David Friedman wrote:
 Assuming the C main() in libgphobos is not actually interfering with 
 the  PSP SDK (e.g., duplicate symbols), you do not have to rename it. 
 You can call the following function which exists for exactly this 
 purpose.

 extern (C) int _d_run_Dmain(int argc, char **argv);

 David
Jul 25 2008
parent Kostas Karanikolas <k_karanikolas hotmail.com> writes:
Vince wrote:
 Hi Kostas,
 
 I am interested in your PSP port and I would like to add it to my cegdc 
 (gdc for window CE), it could be interesting to have a gcc for embedded 
 targets.
 I am working on scripts to build differents versions, something like :
 
 
 sh build-gdc.sh --target psp or
 sh build-gdc.sh --target arm-mingw32ce
 ...
Hi Vince, Personally I don't have a problem. Building, however, the full psp toolchain and sdk for scratch involves many more steps. The method I described is just for rebuilding the toolchain with D support. The difficult work was done the pspdev community. To get idea of what is involved in building the entire toolchain/sdk from scratch have a look at svn://svn.ps2dev.org/psp/trunk/psptoolchain especially the scripts directory. (binutils, gcc stage1, pspsdk stage1, newlib, gcc stage2, psp sdk stage2, etc) However, if you are just interested in making easy for people to build just gdc given a working toolchain, then that's ok.
Jul 25 2008
prev sibling parent reply John Grindstaff <perfectcell14 yahoo.com> writes:
Thanks very much. That actually worked and libgphobos.a appeared where 
it should (in psp next to libiberty, libc++ or whatever).

Are you using garbage collection without calling Phobos's Cmain 
function? I thought it inits GC with gc_init() so how is that possible?

I wonder if it is possible to write a C-source function wrapper around 
the PSP_MODULE_MACRO so that one could use a D main function (as normal)?

Kostas Karanikolas wrote:
 John Grindstaff wrote:
 
 Thanks. How exactly do you compile libgphobos.a for the PSP? I tried it
 but got errors about missing files. What directory should I be in and
 what command do I type?
Build instructions First of all I'm running OSX Leopard on a PowerPC, so what you need to do may vary, not by much on a Unix system but potentially a lot on Windows. I assume you have the latest and complete psp toolchain. If not I suggest you try downloading & installing a prebuilt one or preferably use the "psptoolchain" build scripts found on: svn://svn.ps2dev.org/psp/trunk/psptoolchain Ok, here we go: 1. Make a temporary directory for your build mkdir pspd cd pspd 2. Setup environment paths export PSPDEV=/the/path/where/the/pspsdk/is/already/installed export PATH=$PATH:$PSPDEV/bin export C_INCLUDE_PATH="/opt/local/include" export CPLUS_INCLUDE_PATH="/opt/local/include" export LIBRARY_PATH="/opt/local/lib" 3. Download and unpack gcc wget --continue ftp://ftp.gnu.org/pub/gnu/gcc/gcc-4.1.0/gcc-4.1.0.tar.bz2 tar -xvjf gcc-4.1.0.tar.bz2 4. Download and apply psp toolchain patches to gcc svn export svn://svn.ps2dev.org/psp/trunk/psptoolchain/patches/gcc-4.1.0-PSP.patch cd gcc-4.1.0 patch -p1 <../gcc-4.1.0-PSP.patch 5. Download and setup gdc cd gcc svn co https://dgcc.svn.sourceforge.net/svnroot/dgcc/trunk/d cd .. ./gcc/d/setup-gcc.sh --d-language-version=1 5.5 Optional step, for those compiling GCC under Leopard/PowerPC. Apply a patch to fix some GCC compiler errors cd gcc/config/rs6000/ wget "http://trac.macports.org/attachment/ticket/13191/gcc_patch?format=raw" -Oleopard_ppc.patch patch -p1 <leopard_ppc.patch cd ../../../ 6. Configure, build, and install gcc (gdc & libgphobos included) mkdir build-psp cd build-psp ../configure --prefix="$PSPDEV" --target="psp" --enable-languages="c,d,c++" --with-newlib --enable-cxx-flags="-G0" --disable-libssp --enable-static --disable-shared CFLAGS_FOR_TARGET="-G0" make make install And that should be enough to get a funcional GCC with D/libgphobos As far as my small libgphobos patch is concerned, I agree that it might not be necessary. However given the temperamental behaviour of the linker (especially when it comes to the order of the PSPSDK libraries) I removed the extra definition of main, to make sure that if no main is declared a linker error would be raised. At any rate it works fine without the change. Have fun ! Kostas FreekSh0w86 wrote:
 Oh yeah that's true... I forgot because I made an example without 
 libgphobos but that _would_ interfere. I don't have libgphobos.a 
 compiled yet so I wouldn't know directly. David Friedman wrote:
 Assuming the C main() in libgphobos is not actually interfering with 
 the  PSP SDK (e.g., duplicate symbols), you do not have to rename it. 
 You can call the following function which exists for exactly this 
 purpose.

 extern (C) int _d_run_Dmain(int argc, char **argv);

 David
Jul 25 2008
parent reply John Grindstaff <perfectcell14 yahoo.com> writes:
To clarify, I meant "PSP_MODULE_INFO" macro, and its C wrapper would 
ideally be built into libgphobos as a patch so that one could write D 
psp projects without the C source file "glue."

John Grindstaff wrote:
 Thanks very much. That actually worked and libgphobos.a appeared where 
 it should (in psp next to libiberty, libc++ or whatever).
 
 Are you using garbage collection without calling Phobos's Cmain 
 function? I thought it inits GC with gc_init() so how is that possible?
 
 I wonder if it is possible to write a C-source function wrapper around 
 the PSP_MODULE_MACRO so that one could use a D main function (as normal)?
 
 Kostas Karanikolas wrote:
 John Grindstaff wrote:

 Thanks. How exactly do you compile libgphobos.a for the PSP? I tried it
 but got errors about missing files. What directory should I be in and
 what command do I type?
Build instructions First of all I'm running OSX Leopard on a PowerPC, so what you need to do may vary, not by much on a Unix system but potentially a lot on Windows. I assume you have the latest and complete psp toolchain. If not I suggest you try downloading & installing a prebuilt one or preferably use the "psptoolchain" build scripts found on: svn://svn.ps2dev.org/psp/trunk/psptoolchain Ok, here we go: 1. Make a temporary directory for your build mkdir pspd cd pspd 2. Setup environment paths export PSPDEV=/the/path/where/the/pspsdk/is/already/installed export PATH=$PATH:$PSPDEV/bin export C_INCLUDE_PATH="/opt/local/include" export CPLUS_INCLUDE_PATH="/opt/local/include" export LIBRARY_PATH="/opt/local/lib" 3. Download and unpack gcc wget --continue ftp://ftp.gnu.org/pub/gnu/gcc/gcc-4.1.0/gcc-4.1.0.tar.bz2 tar -xvjf gcc-4.1.0.tar.bz2 4. Download and apply psp toolchain patches to gcc svn export svn://svn.ps2dev.org/psp/trunk/psptoolchain/patches/gcc-4.1.0-PSP.patch cd gcc-4.1.0 patch -p1 <../gcc-4.1.0-PSP.patch 5. Download and setup gdc cd gcc svn co https://dgcc.svn.sourceforge.net/svnroot/dgcc/trunk/d cd .. ./gcc/d/setup-gcc.sh --d-language-version=1 5.5 Optional step, for those compiling GCC under Leopard/PowerPC. Apply a patch to fix some GCC compiler errors cd gcc/config/rs6000/ wget "http://trac.macports.org/attachment/ticket/13191/gcc_patch?format=raw" -Oleopard_ppc.patch patch -p1 <leopard_ppc.patch cd ../../../ 6. Configure, build, and install gcc (gdc & libgphobos included) mkdir build-psp cd build-psp ../configure --prefix="$PSPDEV" --target="psp" --enable-languages="c,d,c++" --with-newlib --enable-cxx-flags="-G0" --disable-libssp --enable-static --disable-shared CFLAGS_FOR_TARGET="-G0" make make install And that should be enough to get a funcional GCC with D/libgphobos As far as my small libgphobos patch is concerned, I agree that it might not be necessary. However given the temperamental behaviour of the linker (especially when it comes to the order of the PSPSDK libraries) I removed the extra definition of main, to make sure that if no main is declared a linker error would be raised. At any rate it works fine without the change. Have fun ! Kostas FreekSh0w86 wrote:
 Oh yeah that's true... I forgot because I made an example without 
 libgphobos but that _would_ interfere. I don't have libgphobos.a 
 compiled yet so I wouldn't know directly. David Friedman wrote:
 Assuming the C main() in libgphobos is not actually interfering with 
 the  PSP SDK (e.g., duplicate symbols), you do not have to rename 
 it. You can call the following function which exists for exactly 
 this purpose.

 extern (C) int _d_run_Dmain(int argc, char **argv);

 David
Jul 25 2008
parent reply Kostas Karanikolas <k_karanikolas hotmail.com> writes:
I think it's better if the PSP_* macros are maintained in a user .c file 
that gets compiled along with the user application.

For example:

pspconfig.c:
#include <pspkernel.h>
PSP_MODULE_INFO("my-dmodule", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
PSP_HEAP_SIZE_MAX();

Note that no c main function is necessary, just the macros.

These declarations do vary per application, and give the option of 
customizing things (thread attributes, kernel/usermode, heap size 
configuration, etc.).

John Grindstaff wrote:
 To clarify, I meant "PSP_MODULE_INFO" macro, and its C wrapper would 
 ideally be built into libgphobos as a patch so that one could write D 
 psp projects without the C source file "glue."
 
 John Grindstaff wrote:
 Thanks very much. That actually worked and libgphobos.a appeared where 
 it should (in psp next to libiberty, libc++ or whatever).

 Are you using garbage collection without calling Phobos's Cmain 
 function? I thought it inits GC with gc_init() so how is that possible?

 I wonder if it is possible to write a C-source function wrapper around 
 the PSP_MODULE_MACRO so that one could use a D main function (as normal)?
Jul 26 2008
parent FreekSh0w86 <perfectcell14 yahoo.com> writes:
That's how I have it setup now, but someone reminded me that GDC 
actually supports the old gcc-style of inline assembly. So it _may_ 
actually be possible to port those macros to D after all. I'd rather not 
try it though, right now I am busy wrestling with png.h trying to 
convert it to D, but it is the worst C header file I've ever tried to 
look at...

Kostas Karanikolas wrote:
 I think it's better if the PSP_* macros are maintained in a user .c file 
 that gets compiled along with the user application.
 
 For example:
 
 pspconfig.c:
 #include <pspkernel.h>
 PSP_MODULE_INFO("my-dmodule", 0, 1, 1);
 PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
 PSP_HEAP_SIZE_MAX();
 
 Note that no c main function is necessary, just the macros.
 
 These declarations do vary per application, and give the option of 
 customizing things (thread attributes, kernel/usermode, heap size 
 configuration, etc.).
 
 John Grindstaff wrote:
 To clarify, I meant "PSP_MODULE_INFO" macro, and its C wrapper would 
 ideally be built into libgphobos as a patch so that one could write D 
 psp projects without the C source file "glue."

 John Grindstaff wrote:
 Thanks very much. That actually worked and libgphobos.a appeared 
 where it should (in psp next to libiberty, libc++ or whatever).

 Are you using garbage collection without calling Phobos's Cmain 
 function? I thought it inits GC with gc_init() so how is that possible?

 I wonder if it is possible to write a C-source function wrapper 
 around the PSP_MODULE_MACRO so that one could use a D main function 
 (as normal)?
Jul 26 2008
prev sibling parent reply "Koroskin Denis" <2korden gmail.com> writes:
On Sun, 20 Jul 2008 03:45:57 +0400, David Friedman  
<dvdfrdmn users.ess-eff.net> wrote:

 John Grindstaff wrote:
 Building GDC for the psptoolchain (as psp-gdc) is it possible? I get  
 compile errors such as this:
  http://paste.dprogramming.com/dppq5raf
  Even though I did apply PSP patches and ran d language setup.sh
  I'm not sure how to patch gdc for PSP use. I like programming on  
 Playstation Portable, but I only desire to return to that scene if I  
 can program in a sensible, modern language such as D.
The latest SVN version has fixes that will allow GDC to build with psptoolchain (and MIPS, in general). I do not have a PSP, so I cannot really test it beyond this. David
I have official psp-gcc sources (patches to gcc), and since they are covered by GPL I think it's ok to share them. Will it help make better psp-gdc?
Jul 25 2008
parent FreekSh0w86 <perfectcell14 yahoo.com> writes:
GPL allows full sharing as long as you make available the source code of 
your changes if you release something with it.

Thanks to Kostas advice, I am able to use D on GDC and posted an example 
of a PSP app that uses D's real main function (still with a minor glue C 
source file).

Link: http://forums.qj.net/showthread.php?t=142864

Right now I'm porting all of the PSP SDK's header files to D. I just 
finished with pspgu.h, look forever with its 1000+ lines but most of it 
is comments anyway.

Koroskin Denis wrote:
 On Sun, 20 Jul 2008 03:45:57 +0400, David Friedman 
 <dvdfrdmn users.ess-eff.net> wrote:
 
 John Grindstaff wrote:
 Building GDC for the psptoolchain (as psp-gdc) is it possible? I get 
 compile errors such as this:
  http://paste.dprogramming.com/dppq5raf
  Even though I did apply PSP patches and ran d language setup.sh
  I'm not sure how to patch gdc for PSP use. I like programming on 
 Playstation Portable, but I only desire to return to that scene if I 
 can program in a sensible, modern language such as D.
The latest SVN version has fixes that will allow GDC to build with psptoolchain (and MIPS, in general). I do not have a PSP, so I cannot really test it beyond this. David
I have official psp-gcc sources (patches to gcc), and since they are covered by GPL I think it's ok to share them. Will it help make better psp-gdc?
Jul 25 2008