GDC on psptoolchain
David Friedman
dvdfrdmn at users.ess-eff.net
Thu Jul 24 16:18:23 PDT 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'
>>>
>
More information about the D.gnu
mailing list