ps3dev / ps3toolchain

A script to autobuild an open source toolchain for the PS3.
BSD 2-Clause "Simplified" License
283 stars 92 forks source link

assert when using -Os #17

Closed sherpya closed 13 years ago

sherpya commented 13 years ago

I've reduced the testcase:

int func1(void)
{
        int result;

        result = func2(0, 0, 0, 0);
        if (result != 0)
                return result;

        result = func2(0, 0, 0, 0);
        return 0;
}

compile with ppu-gcc -Os testcase.c I get: testcase.c: In function 'func1': testcase.c:11:1: internal compiler error: in rs6000_savres_routine_name, at config/rs6000/rs6000.c:18375

ooPo commented 13 years ago

I've added a fix from shagkur to gcc, try rebuilding the toolchain with this new patch.

sherpya commented 13 years ago

ok the patch works fine, I suggest you to do dos2unix on the patch since there are spurious \r

I was building git://github.com/grafchokolo/psgroove.git I think you can check it, since it does not resolve some symbols and some should be somehow in the free sdk (in psl1ght)

memcpy and memset: I dunno why it does not picks gcc builtins, I think because -Tldscript.ld -nostartfiles -nostdlib -nodefaultlibs

the other ones are lv1_xxxxx

I have a relatively fast linux box to try changes, I would be glad to help with some test

ooPo commented 13 years ago

If you add --no-builtin to CFLAGS you can eliminate some of the errors.

sherpya commented 13 years ago

the problem is all missing symbols are instead made in asm, for some reason the compiler mangles symbols with a dot, while the asm macro declaration is without the dot, adding the dot in the macro it works, so what is the correct mangling for symbols ? none or dot?

ooPo commented 13 years ago

If you edit ppc_asm.h and change it to:

#define _GLOBAL(name)                                   \
        .section ".text";                                            \
        .align 2 ;                                                      \
        .global .name;                                             \
        .type name,@function;                                \
.name:                                                                 \

Basically putting a '.' in front of both 'name' locations. Does that work?

sherpya commented 13 years ago

I've also added . on .type line

ooPo commented 13 years ago

Did this work for you?

sherpya commented 13 years ago

in ppc_asm.h I have

#define _GLOBAL(name)                           \
    .section ".text";                           \
    .align 2 ;                                  \
    .globl name;                                \
    .type name,@function;                       \
name:                                           \

I've changed it in:

#define _GLOBAL(name)                           \
    .section ".text";                           \
    .align 2 ;                                  \
    .globl .name;                               \
    .type .name,@function;                      \
.name:                                          \

and it link correcly,I've noticed also while compiling others sources problems with the dot mangle, there is a reason for the dot?

ooPo commented 13 years ago

I suspect that something has changed recently in the toolchain and that something is mangling by default where it hadn't before. There's probably a flag you could use to reverse the behavior but I'm not sure what it would be.

ooPo commented 13 years ago

Is this issue still a problem?