ps3dev / ps3toolchain

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

[Question] Would it be possible to update gcc? #118

Open DarkBattle0000 opened 9 months ago

DarkBattle0000 commented 9 months ago

I'm new to the playstation 3 development scene, I started using the toolset not too long ago. But I noticed some interesting things that got in the way of development for the platform. For some reason I have problems compiling projects with -O2 levels, it compiles more does not run, always returns to xmb (I did Code Review, this ok). In search of an answer the idea came to my mind that the flags that -O2 levels add could be the problem, so I decided to test one by one until I get to the -fcode-hoisting flag, for some reason this flag does not allow me to compile with -O2 levels. Searching around a bit, I found a small update from gcc 7.2.0 to gcc 7.5.0, but it seems to be very unstable. But when compiling my project with this update it worked perfectly. The point here is, Would it be possible to update gcc or fix the problem?

zeldin commented 9 months ago

Hi! You might want to try out #110 which contains an update to gcc 10. Would be nice to get some more feedback on how that works out for people.

humbertodias commented 7 months ago

@DarkBattle0000 Try out https://github.com/ps3dev/ps3toolchain/pull/121

cy33hc commented 7 months ago

Hi! You might want to try out #110 which contains an update to gcc 10. Would be nice to get some more feedback on how that works out for people.

Built couple of tiny3d samples, but get a black screen and have to power off the ps3 when trying to load from ps3loadx.

cy33hc commented 7 months ago

@DarkBattle0000 Try out #121

Built the toolchain on Ubuntu focal and then built a couple of tiny3d samples. Loaded it via ps3loadx. Same like thing like gcc 10.2.0, I just get black screen and have to poweroff the ps3.

humbertodias commented 7 months ago

@DarkBattle0000 Try out #121

Built the toolchain on Ubuntu focal and then built a couple of tiny3d samples. Loaded it via ps3loadx. Same like thing like gcc 10.2.0, I just get black screen and have to poweroff the ps3.

I'm also facing the black screen using c++ with iostream.h and I'm still investigating the reason. On the hand pure c it's working. @DarkBattle0000 try out to generated the pkg and tell me if still fails

docker run -i --rm -v `pwd`:/build -w /build hldtux/ps3dev-sdl2 bash -s <<EOF
echo '#include <SDL.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
    SDL_version version;
    SDL_VERSION(&version);
    printf("SDL version %d.%d.%d\n", version.major, version.minor, version.patch);

    // Initialize SDL with video and game controller subsystems
    if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER) != 0) {
        printf("SDL initialization failed: %s\n", SDL_GetError());
        return 1;
    }

    SDL_Window * window = SDL_CreateWindow(
       "window",
        SDL_WINDOWPOS_UNDEFINED,
        SDL_WINDOWPOS_UNDEFINED,
        480,
        272,
        0
    );

    if (window == NULL) {
        printf("Window creation failed: %s\n", SDL_GetError());
        SDL_Quit();
        return 1;
    }

    // SDL_Renderer * renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
    SDL_Renderer * renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
    if (renderer == NULL) {
        printf("Renderer creation failed: %s\n", SDL_GetError());
        SDL_DestroyWindow(window);
        SDL_Quit();
        return 1;
    }

    SDL_Rect rect = {216, 96, 34, 64};

    int running = 1;
    SDL_Event event;
    while (running) {
        if (SDL_PollEvent(&event)) {
            switch (event.type) {
                case SDL_QUIT:
                        running = 0;
                    break;
                case SDL_CONTROLLERDEVICEADDED:
                    SDL_GameControllerOpen(event.cdevice.which);
                    break;
                case SDL_CONTROLLERBUTTONDOWN:
                    if(event.cbutton.button == SDL_CONTROLLER_BUTTON_START)
                        running = 0;
                    break;
            }
        }

        // Clear the screen
        SDL_RenderClear(renderer);

        // Draw a red square
        SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
        SDL_RenderFillRect(renderer, &rect);

        // Draw everything on a white background
        SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
        SDL_RenderPresent(renderer);
    }

    return 0;
}' > main.c

# compile
ppu-gcc main.c -o main \
-mcpu=cell -I/usr/local/ps3dev/ppu/include \
-I/usr/local/ps3dev/portlibs/ppu/include \
-L/usr/local/ps3dev/portlibs/ppu/lib \
-L/usr/local/ps3dev/spu/spu/lib \
-L/usr/local/ps3dev/ppu/powerpc64-ps3-elf/lib \
-I/usr/local/ps3dev/portlibs/ppu/include/SDL2 -I/usr/local/ps3dev/portlibs/ppu/include -L/usr/local/ps3dev/portlibs/ppu/lib -lSDL2_image -lSDL2 -lm -lgcm_sys -lrsx -lsysutil -lrt -llv2 -lio -laudio

# elf
ppu-strip main -o main.elf
sprxlinker main.elf
fself main.elf main.self
make_self main.elf main.self

# pkg
mkdir -p pkg/USRDIR
make_self_npdrm main.elf pkg/USRDIR/EBOOT.BIN UP0000-ABCDEFG_00-0000000000000000
cp /usr/local/ps3dev/bin/sfo.xml .
sed -i "s/01\.00/2.00/g" sfo.xml
sfo.py --title GAME_TITLE --appid GAME_ID -f sfo.xml pkg/PARAM.SFO
pkg.py --contentid UP0000-ABCDEFG_00-0000000000000000 pkg/ main.pkg

EOF

Screenshot 2024-03-13 at 12 17 48 PM

cy33hc commented 7 months ago

@humbertodias Blacks screen with pkg also.

humbertodias commented 7 months ago

@humbertodias Blacks screen with pkg also.

Weird! I have tested successfully it on rpcs3 today. is the black screen only on console or also on rpcs3?

cy33hc commented 7 months ago

@humbertodias Testing on console only. I can try downloading your prebuilt toolchain and try building. What Ubuntu version are you on? I tried running in Focal and I'm getting this error.

./powerpc64-ps3-elf-gcc: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found

humbertodias commented 7 months ago

I'm using ubuntu 24.04 amd64 the same used to publish at releases

You could also use the docker version of toolchain

docker run -it -v`pwd`:/build hldtux/ps3dev
cy33hc commented 7 months ago

Tested with the prebuilt toolchain. Testing on console only.

  1. Built sprite2D sample from tiny3d and black screen on both PKG and ps3loadx
  2. Built the graphics/cairo sample from PSL1GHT and black screen on ps3loadx. This sample does not have option to build a pkg.
humbertodias commented 7 months ago

Unfortunately, I don't have a ps3 for testing. But, I have successfully tested on rpcs3

How I did to compile sprites 2D and generate the pkg

git clone https://github.com/wargio/tiny3D
docker run -i -v`pwd`:/build hldtux/ps3dev bash -s <<EOF
cd tiny3D
make
cd samples/sprites2D
make pkg
EOF

Then outside the container grab the tiny3D/samples/sprites2D/sprites2D.pkg and drop on rpcs3

image
humbertodias commented 7 months ago

Tested with the prebuilt toolchain. Testing on console only.

  1. Built sprite2D sample from tiny3d and black screen on both PKG and ps3loadx
  2. Built the graphics/cairo sample from PSL1GHT and black screen on ps3loadx. This sample does not have option to build a pkg.

I found out the problem and fix here https://github.com/humbertodias/ps3toolchain/commit/bc0c04bab19301c2f726cbac07d068e0edcd2be4 Basically, the app ps3loadx uses the library tiny3D that wasn't on https://github.com/ps3dev/ps3libraries Therefore, I had pointed to mine https://github.com/humbertodias/ps3libraries that already have the script to install it. Try to use the latest release of https://github.com/humbertodias/ps3loadx/releases and it should work now.