-G0 option in makefiles important?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
michaelp
Posts: 7
Joined: Mon Jul 02, 2007 2:21 am

-G0 option in makefiles important?

Post by michaelp »

Recently, I have been trying to get GDC(GCC D compiler, for the D programming language) working on the PSP using the instructions listed here:
http://forums.qj.net/psp-development-fo ... n-gdc.html
I got everything to install okay, but when I tried to use functions from graphics.c/.h, using the tutorial here:
http://forums.qj.net/psp-development-fo ... ost2184931
I got various errors, some are shown here:

Code: Select all

/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../psp/lib/libgphobos.a(cbridge_stdio.o): In function `_d_gnu_cbridge_init_stdio':
../../../libphobos/gcc/cbridge_stdio.c:29: relocation truncated to fit: R_MIPS_GPREL16 against `_d_gnu_cbridge_stderr'
../../../libphobos/gcc/cbridge_stdio.c:27: relocation truncated to fit: R_MIPS_GPREL16 against `_d_gnu_cbridge_stdin'
../../../libphobos/gcc/cbridge_stdio.c:30: relocation truncated to fit: R_MIPS_GPREL16 against `_d_gnu_cbridge_stdout'
collect2: ld returned 1 exit status
make: *** [HelloPspInD.elf] Error 1
Basically, whenever stdin or stdout or stderr were used in Phobos and one of the files was compiled with the program, there were these errors.(Even though files like std.stdio, where some errors came from, were not imported by me)
So, this Makefile line:

Code: Select all

CFLAGS = -O2 -G0 -Wall
was changed to:

Code: Select all

CFLAGS = -O2 -Wall
and everything was fine. (Tested on my PSP too, and worked fine.)

So, is the -G0 flag important, or is it okay for me to compile everything without it?
Criptych
Posts: 64
Joined: Sat Sep 12, 2009 5:18 am

Post by Criptych »

Actually, I've had the exact opposite problem before (in a C program); I kept receiving "relocation truncated to fit" linker errors until I recompiled one of the libraries with -G0. IIRC it has something to do with how data is arranged in the data segment, but I don't think it will inherently cause problems to omit it.

Also, make sure there are still no errors when you make rebuild, because when I had this problem, even though the first make would fail, the next worked -- but the program crashed in sceKernelModMgr-something.
"You hungry? I haven't eaten since later this afternoon."
michaelp
Posts: 7
Joined: Mon Jul 02, 2007 2:21 am

Post by michaelp »

Okay.
After running a make rebuild, everything is still fine, and works okay on the PSP.
Thanks.
Post Reply