Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building for PSP failes upon linking libSDL_mixed #148

Closed
Phyksar opened this issue Apr 22, 2024 · 7 comments
Closed

Building for PSP failes upon linking libSDL_mixed #148

Phyksar opened this issue Apr 22, 2024 · 7 comments

Comments

@Phyksar
Copy link

Phyksar commented Apr 22, 2024

I'm trying to usepspdev/pspdev:latest docker image to build the project, this includes the psp toolchain required in the building instructions. The image, along with the psp toolchain is based upon alpine linux, however I get linking errors when calling ./scripts/build-psp.sh.

[100%] Linking CXX executable Spelunky_PSP
/usr/local/pspdev/lib/gcc/psp/13.2.0/../../../../psp/bin/ld: /usr/local/pspdev/psp/lib/libSDL_mixer.a(music_cmd.o): in function `MusicCMD_Start':
(.text+0x23c): undefined reference to `sigprocmask'
/usr/local/pspdev/lib/gcc/psp/13.2.0/../../../../psp/bin/ld: /usr/local/pspdev/psp/lib/libSDL_mixer.a(music_cmd.o): in function `MusicCMD_Stop':
(.text+0x2e0): undefined reference to `waitpid'
/usr/local/pspdev/lib/gcc/psp/13.2.0/../../../../psp/bin/ld: /usr/local/pspdev/psp/lib/libSDL_mixer.a(music_cmd.o): in function `MusicCMD_Active':
(.text+0x370): undefined reference to `waitpid'
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/Spelunky_PSP.dir/build.make:121: Spelunky_PSP] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:501: CMakeFiles/Spelunky_PSP.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2

It looks like alpine doesn't define sigprocmask, waitpid functions used in libSDL_mixer. What can I do with this and how this is supposed to be built? I have no idea, since switching to any other linux distributive would be a very time-consuming task as it requires to recursively modify all the images used in the pspdev build.

@dbeef
Copy link
Owner

dbeef commented Apr 22, 2024

Hey, I will try to reproduce this error and get back to you in a few hours.

@dbeef
Copy link
Owner

dbeef commented Apr 22, 2024

I did replicate the error you're experiencing. Took a few steps but now I got it building with the most recent toolchain image. It involved:

  • Updating glm to more recent version (as gcc bundled within the new toolchain image has been updated, it resulted in some compilation errors in glm that's included within the repo)
  • Removing linking to libvorbisidec + Replacing the Audio CMake target implementation with the dummy one (temporary workaround until I figure out what to do with symbols missing in libSDL_mixer)

I have some appointments now, but I will push what I have soon. The problems come from the fact that I have not built a PSP artifact for some time and when I do, I have a local toolchain on my computer so I'm not affected by the toolchain changes within the Docker image such as gcc upgrade or changes within shipped toolchain libraries. Sorry for inconvenience and at the same time - thanks for reporting the issue.

@Phyksar
Copy link
Author

Phyksar commented Apr 23, 2024

Thank you very much for your response, I will look into it. I previously fixed some comiplation errors in LookAt.cpp by removing #include "glm/glm.h" and changing libvorbisidec to libvorbis (don't know exactly will it fix anything, but at least the missing library errors were gone). But with libSDL_mixer errors I was completely lost trying to solve it for hours.

@dbeef
Copy link
Owner

dbeef commented Apr 24, 2024

You're welcome, I spend much less time developing SpelunkyPSP nowadays but I'm always happy to help.
I pushed my changes to: #149 - It includes updating glm, disabling the audio module (temporarily hides the problem with libSDL_mixer - later can be solved by just switching to libSDL2_mixer as it does not reference those missing symbols), and also an attempt to fix a warning that comes from psp-fixup-imports, that is "Warning: could not fixup imports, stubs out of order".

It builds, the resulting EBOOT.PBP file opens in an emulator (I'm using PPSSPP) and I can play without any problems, however when I try running it on a real PSP I get "The game could not be started. (8002013C)" error message.

I think the error is related to this warning from psp-fixup-imports. I will investigate this more in the following days. Cheers.

@dbeef
Copy link
Owner

dbeef commented Apr 28, 2024

An update:

  • I resolved the psp-fixup-imports warning - just like the message suggested I forced linking PSP SDK libraries as last by aggregating all PSP-SDK libs into an extra interface target in CMake (for some reason only this guaranteed they will really be last in the list) - The warning is gone, however it didn't fix the crash on PSP, which turns out to be...
  • ...Most probably the change of default firmware version in the PSP toolchain which I tracked to a group of commits from March this year: pspdev/pspsdk@2b4e949 pspdev/pspsdk@b9cbe7f
  • With the change of default supported firmware from PSP_FW_VERSION=150 to PSP_FW_VERSION=600 now it makes sense that the build worked on an emulator, but failed on my PSP (firmware <600) with error code 8002013C
  • This means that if you have more recent firmware on your PSP then the build from adjusting-to-updated-pspsdk branch will run just fine (yet without sound)
  • Re-enabling sound is the last thing to be solved. It could be that moving to SDL2 will be required (which for some reason is challenging to make it work with glad, unlike SDL1, which is the reason I sticked to the latter)
  • Well, this and thinking what to do with the firmware issue - I don't want to drop support for older firmware if it can be avoided, yet it will probably not be enough to build SpelunkyPSP with PSP_FW_VERSION=150, but all libraries included with the toolchain (such as SDL) with PSP_FW_VERSION=150. To be honest, I might just go with 600 for simple convenience of not branching off the mainstream PSP toolchain image / delivering my own prebuilt dependencies for 150.

I will post the next update (hopefully - with the audio module re-enabled) in a few days. Cheers.

@dbeef
Copy link
Owner

dbeef commented Apr 30, 2024

Got it working :D Building on pspdev/pspdev:latest, running on PSP-1000 6.60 CFW.

IMG_4560_small

On top of the previous changes:

  • Updated firmware on my PSP (as a result of the new default version in the PSP toolchain: PSP_FW_VERSION=600)
  • Switched both video / GL context creation on PSP to SDL2
  • Switched audio implementation on PSP to use SDL2_mixer (works!)
  • As anticipated, glad can't retrieve GL function pointers using SDL2, using SDL2/SDL_opengl.h header as a workaround.

I will push the fixes tomorrow, hopefully I come up with something to still use glad.

Unwelcome side effect - switching from SDL1 to SDL2 results with significantly bigger artifact (EBOOT.PBP) - an increase from 15.8 MB to 17.8 MB

@dbeef
Copy link
Owner

dbeef commented May 14, 2024

I just merged the relevant changes: #149

You can now build the project with pspdev/pspdev:latest.
Example usage:

git clone [email protected]:dbeef/spelunky-psp.git
cd spelunky-psp
sudo docker run --rm -it -v $(pwd):/root pspdev/pspdev:latest /bin/bash
# Inside the container:
cd
./scripts/config-psp.sh
./scripts/build-psp.sh
# Output artifacts:
ls ./tmp/build-psp/

Thank you for reporting the issue.

@dbeef dbeef closed this as completed May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants