July 23, 2008
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
July 24, 2008
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'
> >

July 24, 2008
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
July 24, 2008
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



July 24, 2008
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'
>>>
> 
July 24, 2008
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'
>>>>
>>
July 24, 2008
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'
>>>
> 
July 24, 2008
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'
>>>>
>>
July 25, 2008
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

# If your native compiler tools are in some extra non standard path
# also export these variables.
# In my case I use macports, installed on /opt/local
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
# we now must be in directory ...../pspd/gcc-4.1.0/gcc

# Checkout dgcc from svn
svn co https://dgcc.svn.sourceforge.net/svnroot/dgcc/trunk/d

cd ..

# setup dgcc
./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)
# Make a separate build subdirectory
# we must be ...../pspd/gcc-4.1.0
mkdir build-psp
cd build-psp

# Configure GCC
../configure --prefix="$PSPDEV" --target="psp" --enable-languages="c,d,c++" --with-newlib --enable-cxx-flags="-G0" --disable-libssp --enable-static --disable-shared

# Compile GCC
CFLAGS_FOR_TARGET="-G0" make

# Install GCC
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
>> 




July 25, 2008
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
> 
> # If your native compiler tools are in some extra non standard path
> # also export these variables.
> # In my case I use macports, installed on /opt/local
> 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
> # we now must be in directory ...../pspd/gcc-4.1.0/gcc
> 
> # Checkout dgcc from svn
> svn co https://dgcc.svn.sourceforge.net/svnroot/dgcc/trunk/d
> 
> cd ..
> 
> # setup dgcc
> ./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)
> # Make a separate build subdirectory
> # we must be ...../pspd/gcc-4.1.0
> mkdir build-psp
> cd build-psp
> 
> # Configure GCC
> ../configure --prefix="$PSPDEV" --target="psp" --enable-languages="c,d,c++" --with-newlib --enable-cxx-flags="-G0" --disable-libssp --enable-static --disable-shared
> 
> # Compile GCC
> CFLAGS_FOR_TARGET="-G0" make
> 
> # Install GCC
> 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
>>>
> 
> 
> 
>