Closed edsinkevic closed 1 year ago
Seems there already is a pull request probably addressing this issue. Sweet!
The transition from makefiles to CMake, on which I'm working almost single-handedly, has been quite a bumpy ride so far (see #37). Plenty of stuff broke so don't be surprised if you find things refusing to work for no apparent reason. I am putting as much effort as I can into testing and bugfixing but it is far from trivial. CMake is full of undocumented behavior that only comes up when you push it to its limits, which I'm arguably doing (take a look at doc/dev notes.txt
).
Some examples even started having random issues that I haven't been able to fix: n00bdemo
crashes immediately on real hardware and no$psx (but works fine in other emulators), while dynlink
zerofills random chunks of memory on DuckStation but not on no$psx... wtf. Even though all the major PS1 emulators have debuggers, none of them has enough features to be usable, Debugging on real hardware is of course even worse.
All this said, my fork's cmake
branch should build without issues on both Windows and Linux once you get the toolchain up and running; see the updated instructions here. If you get tinyxml2
build errors, try using -DSKIP_TINYXML2=ON
and installing tinyxml2
from your package manager.
Your efforts are very inspiring. While I am still not adept at developing software let alone contributing to such ambitious projects, your work is surely worth praise in my eyes.
In case this may be of some help (at worst - another thing to worry about). I've tried building your cmake branch, and though it didn't have the initial issue, now there's a problem in the linking process:
[40/66] Building ASM object demos/n00bdemo/CMakeFiles/n00bdemo.dir/smdparser.s.obj [41/66] Building ASM object demos/n00bdemo/CMakeFiles/n00bdemo.dir/data.s.obj [42/66] Linking C executable graphics/hdtv/hdtv.elf [43/66] Linking C shared library system/dynlink/dynlink_balls.so FAILED: system/dynlink/dynlink_balls.so system/dynlink/dynlink_balls.dll /home/edvin/Downloads/PSn00bSDK-cmake/build/examples-prefix/src/examples-build/system/dynlink/dynlink_balls.dll : && /home/edvin/disobin/psx/toolchain/mipsel-unknown-elf/bin/mipsel-unknown-elf-gcc -fPIC -T/home/edvin/Downloads/PSn00bSDK-cmake/build/install_tree/lib/libpsn00b/cmake/../ldscripts/dll.ld -G0 -shared -nostdlib -Wl,-gc-sections -shared -o system/dynlink/dynlink_balls.so system/dynlink/CMakeFiles/dynlink_balls.dir/library/balls.c.obj && cd /home/edvin/Downloads/PSn00bSDK-cmake/build/examples-prefix/src/examples-build/system/dynlink && /home/edvin/disobin/psx/toolchain/mipsel-unknown-elf/bin/mipsel-unknown-elf-objcopy -O binary dynlink_balls.so dynlink_balls.dll /home/edvin/disobin/psx/toolchain/mipsel-unknown-elf/lib/gcc/mipsel-unknown-elf/7.4.0/../../../../mipsel-unknown-elf/bin/ld: system/dynlink/dynlink_balls.so: protected symbol `_procedure_table_size' isn't defined /home/edvin/disobin/psx/toolchain/mipsel-unknown-elf/lib/gcc/mipsel-unknown-elf/7.4.0/../../../../mipsel-unknown-elf/bin/ld: final link failed: bad value collect2: error: ld returned 1 exit status [44/66] Linking C executable system/console/console.elf [45/66] Linking C executable system/childexec/child.elf [46/66] Linking C executable graphics/render2tex/render2tex.elf [47/66] Building C object demos/n00bdemo/CMakeFiles/n00bdemo.dir/overlay.c.obj [48/66] Building C object demos/n00bdemo/CMakeFiles/n00bdemo.dir/lightdemo.c.obj [49/66] Building C object demos/n00bdemo/CMakeFiles/n00bdemo.dir/logo.c.obj [50/66] Building C object system/dynlink/CMakeFiles/dynlink_cube.dir/library/cube.c.obj [51/66] Building C object demos/n00bdemo/CMakeFiles/n00bdemo.dir/main.c.obj [52/66] Building C object sound/vagsample/CMakeFiles/vagsample.dir/main.c.obj ninja: build stopped: subcommand failed. ninja: build stopped: subcommand failed.
Unsurprisingly it's yet another issue with the dynamic linker (another creation of mine) and the dynlink
example.
I actually did some tests right now and it looks like older GCC versions, including 7.4.0, can't properly build MIPS DLLs in the non-standard format expected by my dynamic linker. I don't know what actually causes _procedure_table_size
to be undefined but it's probably some obscure MIPS ABI stuff, or maybe a GCC bug that got fixed in later releases. I'm going to remove the recommendation to use GCC 7.4.0 from the toolchain guide.
Try building binutils 2.37 and GCC 11.2.0, which should work (although you may have to do some small modifications to the binutils sources). I know compiling the toolchain a tedious process, but I just tried rebuilding the SDK and examples using GCC 11.2.0 on an Ubuntu VM and I had no issues.
Unsurprisingly it's yet another issue with the dynamic linker (another creation of mine) and the
dynlink
example.I actually did some tests right now and it looks like older GCC versions, including 7.4.0, can't properly build MIPS DLLs in the non-standard format expected by my dynamic linker. I don't know what actually causes
_procedure_table_size
to be undefined but it's probably some obscure MIPS ABI stuff, or maybe a GCC bug that got fixed in later releases. I'm going to remove the recommendation to use GCC 7.4.0 from the toolchain guide.Try building binutils 2.37 and GCC 11.2.0, which should work (although you may have to do some small modifications to the binutils sources). I know compiling the toolchain a tedious process, but I just tried rebuilding the SDK and examples using GCC 11.2.0 on an Ubuntu VM and I had no issues.
This change fixed building on Debian 11 (without modifications to either binutils or gcc), I have successfully updated https://alex-free.github.io/psn00bsdk_installer/ for the CMake based toolchain.
@alex-free: I took a quick look at your installer script. I have a few suggestions:
mipsel-none-elf
(instead of mipsel-unknown-elf
) and pass -DPSN00BSDK_TARGET=mipsel-none-elf
to CMake for future proofing, as I have switched to mipsel-none-elf
as the default toolchain in my work-in-progress fork (updated installation instructions here). The same branch has GitHub Actions CI scripts and support for building installer packages as well by the way./usr/local
rather than /usr/local/mipsel-unknown-elf
, for consistency with the way the toolchain is bundled in the packages generated by the CI script. CMake's default installation prefix is already /usr/local
, however you might still want to provide an option to change it.create_psn00bsdk_project
or similar script to quickly generate a new project. The script would copy the contents of the /usr/local/share/psn00bsdk/template
directory and populate the CMakePresets.json
file (see here) with the paths that were chosen during installation.
So basically I've ran these commands: cmake -S . -B ./build -G Ninja --install-prefix ~/disobin/psx/sdk and then.. cmake --build ./build ... everything is alright up to this moment
[15/16] Building CXX object CMakeFiles/smxlink.dir/smxlink/main.cpp.o [16/16] Linking CXX executable smxlink [24/40] Performing download step (git clone) for 'mkpsxiso' FAILED: mkpsxiso-prefix/src/mkpsxiso-stamp/mkpsxiso-download /home/edvin/Downloads/PSn00bSDK/build/mkpsxiso-prefix/src/mkpsxiso-stamp/mkpsxiso-download cd /home/edvin/Downloads/PSn00bSDK/build/mkpsxiso-prefix/src && /usr/bin/cmake -P /home/edvin/Downloads/PSn00bSDK/build/mkpsxiso-prefix/tmp/mkpsxiso-gitclone.cmake && /usr/bin/cmake -E touch /home/edvin/Downloads/PSn00bSDK/build/mkpsxiso-prefix/src/mkpsxiso-stamp/mkpsxiso-download Cloning into 'mkpsxiso'... fatal: invalid reference: cmake CMake Error at /home/edvin/Downloads/PSn00bSDK/build/mkpsxiso-prefix/tmp/mkpsxiso-gitclone.cmake:40 (message): Failed to checkout tag: 'cmake'
[25/40] Performing install step for 'tools' [0/1] Install the project... -- Install configuration: "" -- Installing: /home/edvin/Downloads/PSn00bSDK/build/install_tree/bin/elf2x -- Installing: /home/edvin/Downloads/PSn00bSDK/build/install_tree/bin/elf2cpe -- Installing: /home/edvin/Downloads/PSn00bSDK/build/install_tree/bin/smxlink -- Installing: /home/edvin/Downloads/PSn00bSDK/build/install_tree/bin/lzpack -- Installing: /home/edvin/Downloads/PSn00bSDK/build/install_tree/share/psn00bsdk/plugin -- Installing: /home/edvin/Downloads/PSn00bSDK/build/install_tree/share/psn00bsdk/plugin/io_export_smx_v3.py ninja: build stopped: subcommand failed.