Skip to content

Upgrade GCC 13.2.0 version (PPU-SPU) - #121

Open
humbertodias wants to merge 159 commits into
ps3dev:masterfrom
humbertodias:gcc-ppu-spu-13.2.0
Open

humbertodias wants to merge 159 commits into
ps3dev:masterfrom
humbertodias:gcc-ppu-spu-13.2.0

Conversation

@humbertodias

@humbertodias humbertodias commented Mar 5, 2024

Copy link
Copy Markdown

Features

  • binutils-ppu bumped from 2.22 to 2.42
  • ppu-gcc bumped from 7.20 to 13.2.0
  • spu-gcc bumped from 7.20 to 9.5.0
  • docker bumped from 16.04 to 24.04 - LTS
  • ci/cd working again and building releases
  • ci/cd to docker hub
  • ci/cd badges
  • build on ubuntu/macOS for arm64 enabled
  • test PSL1GHT hello game

Note

We've selected the version 9.5.0 because it's the last GCC release to include support for SPU.
https://www.phoronix.com/news/GCC-10-Drops-Cell-BE-SPU

Result

  1. ar --version
GNU ar (GNU Binutils) 2.42
Copyright (C) 2024 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.
  1. ppu-gcc --version
ppu-gcc (GCC) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  1. spu-gcc --version
spu-gcc (GCC) 9.5.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  1. Docker
FROM ubuntu:24.04
  1. ci/cd success

image

https://github.com/humbertodias/ps3toolchain/actions/runs/8166663270

  1. ci/cd docker
    image

Note

Don't forget to create a named DockerHub environment on your repository with two secret variables: DOCKERHUB_USERNAME and DOCKERHUB_TOKEN

  1. badges
    image

  2. PSL1GHT hello game

image

@humbertodias humbertodias changed the title add gcc-ppu-spu v13.2.0 Update GCC to 13.2.0 (PUU-SPU) Mar 5, 2024
@humbertodias humbertodias changed the title Update GCC to 13.2.0 (PUU-SPU) Update GCC version (PUU-SPU) Mar 5, 2024
@humbertodias humbertodias changed the title Update GCC version (PUU-SPU) Update GCC version (PPU-SPU) Mar 5, 2024
@Fewnity

Fewnity commented Mar 5, 2024

Copy link
Copy Markdown

Hey cool work, I really want gcc 13 on ps3. But you just forgot to credit Darjan Krijanand and luizfernandonb :/

@humbertodias

Copy link
Copy Markdown
Author

Hey cool work, I really want gcc 13 on ps3. But you just forgot to credit Darjan Krijanand and luizfernandonb :/

Yeah.. I left his name on patch's file given him the credit

@humbertodias

Copy link
Copy Markdown
Author

A question: Which commits are the patches generated from? I don't see corresponding pull requests to https://github.com/ps3dev/gcc-PS3 et al. If new base repos are used (which might make sense given a large jump in version), it would be good if those could be moved to the ps3dev org for maintainability.

Got it. Here ps3dev/gcc-PS3#1

@Cruslan

Cruslan commented Sep 2, 2026

Copy link
Copy Markdown

As i tested again on modern host Linux environment (tested on GCC 162.0) uncovered a few compilation failures that prevent the toolchain from building.

1. libcody/client.cc: Ambiguous Overload Error on Modern C++ Compilers

When compiling GCC 13.2.0 (scripts/002-gcc-newlib-PPU.sh), compilation of libcody fails:

../../libcody/client.cc: In function 'Cody::Packet Cody::IncludeTranslateResponse(std::vector<std::__cxx11::basic_string<char> >&)':
../../libcody/client.cc:325:42: error: call of overloaded 'Packet(Cody::Client::PacketCode, int)' is ambiguous
  325 |         return Packet (Client::PC_BOOL, 0);
      |                                          ^
note: candidate 1: 'Cody::Packet::Packet(unsigned int, size_t)'
note: candidate 2: 'Cody::Packet::Packet(unsigned int, const char8_t*)'

PR #121 introduced the constructor Packet (unsigned c, const char8_t *s) to libcody/cody.hh under #if __cpp_char8_t >= 201811. However, cody.hh already defines Packet (unsigned c, size_t i = 0). In C++, the integer literal 0 is both a numeric integer and a valid null pointer constant. Under C++20 / C++23 mode on newer GCC host compilers, calling Packet(Client::PC_BOOL, 0) produces an ambiguous overload between size_t and const char8_t*. Integer literals in client.cc has to be cast explicitly to size_t. Update patches/gcc-13.2.0-PS3-host.patch as follows:

--- a/libcody/client.cc
+++ b/libcody/client.cc
@@ -322,9 +322,9 @@ Packet IncludeTranslateResponse (std::vector<std::string> &words)
   if (words[0] == (const char *) u8"BOOL" && words.size () == 2)
     {
       if (words[1] == (const char *) u8"FALSE")
-	return Packet (Client::PC_BOOL, 0);
+	return Packet (Client::PC_BOOL, size_t (0));
       else if (words[1] == (const char *) u8"TRUE")
-	return Packet (Client::PC_BOOL, 1);
+	return Packet (Client::PC_BOOL, size_t (1));
       else
 	return Packet (Client::PC_ERROR, u8"");
     }

2. GDB 8.3.1 Bundled Readline Build Failure Under Host GCC 15/16 (C23 Default)

When building GDB 8.3.1 (scripts/003-gdb-PPU.sh and scripts/007-gdb-SPU.sh), the bundled readline fails during compilation of signals.c:

../../readline/signals.c:385:40: error: passing argument 2 of 'rl_set_sighandler' from incompatible pointer type [-Wincompatible-pointer-types]
  385 |       oh = rl_set_sighandler (SIGALRM, rl_signal_handler, &old_alrm);
../../readline/signals.c:62:36: error: 'return' with a value, in function returning void [-Wreturn-mismatch]
   62 | #  define SIGHANDLER_RETURN return (0)

Recent host GCC compilers default to C23 (-std=gnu23). In C23, empty function declarations like void (*signal ()) (); now mean void (*signal (void)) (void) instead of unprototyped functions with unspecified arguments. Readline's configure script uses void (*signal ()) (); in its compile check for VOID_SIGHANDLER. This fails against glibc's <signal.h> prototype, causing VOID_SIGHANDLER to remain undefined. Consequently, readline expects signal handlers to return int, which triggers -Wreturn-mismatch and -Wincompatible-pointer-types (both errors by default in GCC 14+). Explicitly pass -std=gnu17 and compatibility flags to CFLAGS and CXXFLAGS in both GDB build scripts (scripts/003-gdb-PPU.sh and scripts/007-gdb-SPU.sh):

--- a/scripts/003-gdb-PPU.sh
+++ b/scripts/003-gdb-PPU.sh
@@ -37,6 +37,8 @@ cd ${GDB}/build-ppu
 ## Configure the build.
 ## pyenv ships Python 3.10; gdb 8.3.1 cannot build against that ABI.
+CFLAGS="${CFLAGS:-} -std=gnu17 -Wno-incompatible-pointer-types -Wno-int-conversion" \
+CXXFLAGS="${CXXFLAGS:-} -std=gnu++17 -Wno-narrowing" \
 ../configure --prefix="$PS3DEV/ppu" --target="powerpc64-ps3-elf" \
     --disable-multilib \
     --disable-nls \
--- a/scripts/007-gdb-SPU.sh
+++ b/scripts/007-gdb-SPU.sh
@@ -37,6 +37,8 @@ cd ${GDB}/build-spu
 ## Configure the build.
 ## pyenv ships Python 3.10; gdb 8.3.1 cannot build against that ABI.
+CFLAGS="${CFLAGS:-} -std=gnu17 -Wno-incompatible-pointer-types -Wno-int-conversion" \
+CXXFLAGS="${CXXFLAGS:-} -std=gnu++17 -Wno-narrowing" \
 ../configure --prefix="$PS3DEV/spu" --target="spu" \
     --disable-nls \
     --disable-sim \

3. SPU Binutils 2.22 Compatibility with C23 Host Compilers

Compiling Binutils 2.22 for SPU (scripts/005-binutils-SPU.sh) encounters failures on newer host toolchains due to obsolete K&R style definitions, implicit conversions, and strict C23 compiler checks. Enforce C17 semantics by passing -std=gnu17 in scripts/005-binutils-SPU.sh:

--- a/scripts/005-binutils-SPU.sh
+++ b/scripts/005-binutils-SPU.sh
@@ -37,6 +37,7 @@ cd ${BINUTILS}/build-spu
 ## Configure the build.
+CFLAGS="${CFLAGS:-} -std=gnu17 -Wno-incompatible-pointer-types -Wno-int-conversion -Wno-implicit-function-declaration" \
 ../configure --prefix="$PS3DEV/spu" --target="spu" \
     --disable-nls \
     --disable-shared \

@humbertodias

Copy link
Copy Markdown
Author

As i tested again on modern host Linux environment (tested on GCC 162.0) uncovered a few compilation failures that prevent the toolchain from building.

1. libcody/client.cc: Ambiguous Overload Error on Modern C++ Compilers

When compiling GCC 13.2.0 (scripts/002-gcc-newlib-PPU.sh), compilation of libcody fails:

../../libcody/client.cc: In function 'Cody::Packet Cody::IncludeTranslateResponse(std::vector<std::__cxx11::basic_string<char> >&)':
../../libcody/client.cc:325:42: error: call of overloaded 'Packet(Cody::Client::PacketCode, int)' is ambiguous
  325 |         return Packet (Client::PC_BOOL, 0);
      |                                          ^
note: candidate 1: 'Cody::Packet::Packet(unsigned int, size_t)'
note: candidate 2: 'Cody::Packet::Packet(unsigned int, const char8_t*)'

PR #121 introduced the constructor Packet (unsigned c, const char8_t *s) to libcody/cody.hh under #if __cpp_char8_t >= 201811. However, cody.hh already defines Packet (unsigned c, size_t i = 0). In C++, the integer literal 0 is both a numeric integer and a valid null pointer constant. Under C++20 / C++23 mode on newer GCC host compilers, calling Packet(Client::PC_BOOL, 0) produces an ambiguous overload between size_t and const char8_t*. Integer literals in client.cc has to be cast explicitly to size_t. Update patches/gcc-13.2.0-PS3-host.patch as follows:

--- a/libcody/client.cc
+++ b/libcody/client.cc
@@ -322,9 +322,9 @@ Packet IncludeTranslateResponse (std::vector<std::string> &words)
   if (words[0] == (const char *) u8"BOOL" && words.size () == 2)
     {
       if (words[1] == (const char *) u8"FALSE")
-	return Packet (Client::PC_BOOL, 0);
+	return Packet (Client::PC_BOOL, size_t (0));
       else if (words[1] == (const char *) u8"TRUE")
-	return Packet (Client::PC_BOOL, 1);
+	return Packet (Client::PC_BOOL, size_t (1));
       else
 	return Packet (Client::PC_ERROR, u8"");
     }

2. GDB 8.3.1 Bundled Readline Build Failure Under Host GCC 15/16 (C23 Default)

When building GDB 8.3.1 (scripts/003-gdb-PPU.sh and scripts/007-gdb-SPU.sh), the bundled readline fails during compilation of signals.c:

../../readline/signals.c:385:40: error: passing argument 2 of 'rl_set_sighandler' from incompatible pointer type [-Wincompatible-pointer-types]
  385 |       oh = rl_set_sighandler (SIGALRM, rl_signal_handler, &old_alrm);
../../readline/signals.c:62:36: error: 'return' with a value, in function returning void [-Wreturn-mismatch]
   62 | #  define SIGHANDLER_RETURN return (0)

Recent host GCC compilers default to C23 (-std=gnu23). In C23, empty function declarations like void (*signal ()) (); now mean void (*signal (void)) (void) instead of unprototyped functions with unspecified arguments. Readline's configure script uses void (*signal ()) (); in its compile check for VOID_SIGHANDLER. This fails against glibc's <signal.h> prototype, causing VOID_SIGHANDLER to remain undefined. Consequently, readline expects signal handlers to return int, which triggers -Wreturn-mismatch and -Wincompatible-pointer-types (both errors by default in GCC 14+). Explicitly pass -std=gnu17 and compatibility flags to CFLAGS and CXXFLAGS in both GDB build scripts (scripts/003-gdb-PPU.sh and scripts/007-gdb-SPU.sh):

--- a/scripts/003-gdb-PPU.sh
+++ b/scripts/003-gdb-PPU.sh
@@ -37,6 +37,8 @@ cd ${GDB}/build-ppu
 ## Configure the build.
 ## pyenv ships Python 3.10; gdb 8.3.1 cannot build against that ABI.
+CFLAGS="${CFLAGS:-} -std=gnu17 -Wno-incompatible-pointer-types -Wno-int-conversion" \
+CXXFLAGS="${CXXFLAGS:-} -std=gnu++17 -Wno-narrowing" \
 ../configure --prefix="$PS3DEV/ppu" --target="powerpc64-ps3-elf" \
     --disable-multilib \
     --disable-nls \
--- a/scripts/007-gdb-SPU.sh
+++ b/scripts/007-gdb-SPU.sh
@@ -37,6 +37,8 @@ cd ${GDB}/build-spu
 ## Configure the build.
 ## pyenv ships Python 3.10; gdb 8.3.1 cannot build against that ABI.
+CFLAGS="${CFLAGS:-} -std=gnu17 -Wno-incompatible-pointer-types -Wno-int-conversion" \
+CXXFLAGS="${CXXFLAGS:-} -std=gnu++17 -Wno-narrowing" \
 ../configure --prefix="$PS3DEV/spu" --target="spu" \
     --disable-nls \
     --disable-sim \

3. SPU Binutils 2.22 Compatibility with C23 Host Compilers

Compiling Binutils 2.22 for SPU (scripts/005-binutils-SPU.sh) encounters failures on newer host toolchains due to obsolete K&R style definitions, implicit conversions, and strict C23 compiler checks. Enforce C17 semantics by passing -std=gnu17 in scripts/005-binutils-SPU.sh:

--- a/scripts/005-binutils-SPU.sh
+++ b/scripts/005-binutils-SPU.sh
@@ -37,6 +37,7 @@ cd ${BINUTILS}/build-spu
 ## Configure the build.
+CFLAGS="${CFLAGS:-} -std=gnu17 -Wno-incompatible-pointer-types -Wno-int-conversion -Wno-implicit-function-declaration" \
 ../configure --prefix="$PS3DEV/spu" --target="spu" \
     --disable-nls \
     --disable-shared \

No problem. Now we are using gcc 16.2 to compile.
humbertodias@a27ba07
Thanks

@Cruslan

Cruslan commented Sep 2, 2026

Copy link
Copy Markdown

As i tested it can compile my PS3 Moonlight project without change single of code. It works like charm. It improved altivec SIMD register usage by huge margin, it will increase performance of homebrews by huge margin. Good work.

Architectural Metric (-O2 Baseline) GCC 7.2.0 (Legacy Toolchain) GCC 13.2.0 (Modern Toolchain) Delta / Variance Microarchitectural Analysis & Hardware Impact
Total Instruction Count 389,209 insns 396,141 insns +6,932 (+1.78%) Controlled loop unrolling and SIMD loop prologue/epilogue peeling.
AltiVec SIMD Vector Ops 57 insns 129 insns +72 (+126.3%) Opus audio DSP kernels auto-vectorized into 128-bit VMX vmaddfp operations.
Hardware Counter Loops (bdnz) 2,070 loops 2,337 loops +267 (+12.9%) Counted loops routed to Count Register (CTR) with zero branch penalty.
Redundant Sign-Extends (extsw) 9,048 insns 7,435 insns -1,613 (-17.8%) Advanced VRP eliminates 1,613 dead cycles on the in-order PPE pipeline.
Condition Compares (cmpdi) 9,055 insns 7,806 insns -1,249 (-13.8%) Combined comparisons with single-cycle record-form instructions (mr.).
Video Receiver Memory Traffic 1,122 ops 1,006 ops -116 ops (-10.3%) 67 fewer loads and 49 fewer stores in VideoReceiveThreadProc stream path.
Total Function Boundaries 7,472 funcs 7,352 funcs -120 funcs Inter-procedural whole-program inlining eliminating function call overhead.
Procedure Descriptors (.opd) 89,784 B (3,741 entries) 88,344 B (3,681 entries) -1,440 B (-60 entries) 60 fewer external function descriptors saving 24 bytes per descriptor table.
Stripped Binary Footprint 2,398,848 B (2.39 MB) 2,463,752 B (2.46 MB) +64.9 KB (+2.71%) 70.3% of size delta is DWARF 5 Call Frame Information (.eh_frame) unwinding.
Deployable Package (.pkg) 843,264 B (824 KB) 886,208 B (866 KB) +42.9 KB (+5.09%) Hardware-ready retail signed NPDRM installation package footprint.

@Cruslan

Cruslan commented Sep 2, 2026

Copy link
Copy Markdown
Ekran Görüntüsü_20260903_000713 Works nice.

@zeldin

zeldin commented Sep 2, 2026

Copy link
Copy Markdown
Member

Got it. Here ps3dev/gcc-PS3#1

Thanks. However, please don't slap a new upstreams version on the master branch; we have an upstream branch where the gcc sources are imported without any PS3 modifications (so exactly what comes in the upstream tarball), and then we merge that into master to keep changes with traceability. The patch for ps3toolchain is then simply generated by git diff upstream master.

You don't need to make a separate pull request for the upstream branch; just keep the same structure in your own repo and submit the master branch commit with the merge intact and we can work with that.

If the new gcc version has diverged too much for a merge to be practical, it's better to create a new repo (still with an upstream branch in the same way) and cherry-pick the commits from the old repo that are still relevant.

This may all seem like extra work, but it does ensure maintainability going forward.

@humbertodias

humbertodias commented Sep 3, 2026

Copy link
Copy Markdown
Author

Got it. Here ps3dev/gcc-PS3#1

Thanks. However, please don't slap a new upstreams version on the master branch; we have an upstream branch where the gcc sources are imported without any PS3 modifications (so exactly what comes in the upstream tarball), and then we merge that into master to keep changes with traceability. The patch for ps3toolchain is then simply generated by git diff upstream master.

You don't need to make a separate pull request for the upstream branch; just keep the same structure in your own repo and submit the master branch commit with the merge intact and we can work with that.

If the new gcc version has diverged too much for a merge to be practical, it's better to create a new repo (still with an upstream branch in the same way) and cherry-pick the commits from the old repo that are still relevant.

This may all seem like extra work, but it does ensure maintainability going forward.

Thanks for the guidance - I've restructured this PR to match that workflow.

upstream on my fork is a clean import of gcc-13.2.0.tar.xz (tag gcc-13.2.0-upstream), with no PS3 changes.
This branch merges that tag into master (Merge tag 'gcc-13.2.0-upstream') and keeps the PS3-only commits on top. There is no separate PR for upstream.

The ps3toolchain patch can be generated with:

git diff upstream gcc-ppu-spu-13.2.0

Please, let me know if i missed anything.

@zeldin

zeldin commented Sep 4, 2026

Copy link
Copy Markdown
Member

Perfect! Thank you. Now it's also easier to review.

@Cruslan

Cruslan commented Sep 6, 2026

Copy link
Copy Markdown

I wanna see this update, GCC's improved auto-vectorizer and SNS modules significantly improves performance.

@Fewnity

Fewnity commented Sep 6, 2026

Copy link
Copy Markdown

GCM samples from PSL1GHT should be compiled with the update because if I remember correctly, GCM stuff wasn't working well when I tested when the PR was created.

@Cruslan

Cruslan commented Sep 6, 2026

Copy link
Copy Markdown

On my PS3 Moonlight project i compiled pr for myself. I didn't see any problems with that, my project utilized Tiny3D for display.

@humbertodias

Copy link
Copy Markdown
Author

Tested with SoRR

bennug64-port-ps3.mp4

@zeldin

zeldin commented Sep 13, 2026

Copy link
Copy Markdown
Member

@humbertodias Your gcc updates have been merged through the gcc-PS3 repository.
Please rebase your remaining changes on current master and open smaller pull requests for anything which is still relevant. Thanks!

Keep split PPU/SPU/host patches and gcc-PS3 PPU delta (no TARGET_USES_LINUX64_OPT).
Take master's newlib dirent sentinels and SPU --with-newlib/--with-pic.
The upstream merge left a cat of gcc-9.5.0-PS3.patch; SPU already uses the -SPU/-host/-macos-arm64 patches.
@humbertodias

humbertodias commented Sep 13, 2026

Copy link
Copy Markdown
Author

@humbertodias Your gcc updates have been merged through the gcc-PS3 repository. Please rebase your remaining changes on current master and open smaller pull requests for anything which is still relevant. Thanks!

Sure! master branch merged into this PR

Keep split GCC patches; also refresh newlib config.guess/config.sub and keep SPU --with-system-zlib.
The last master merge applied those hunks to gcc-13.2.0-PS3-PPU.patch; they already exist in GCC 13 and make GNU patch fail on Linux after zlib.
os: linux

- runner: macos-15-intel
- runner: macos-26-intel

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were targeting mac-15-intel to keep it compatible with old Mac Intel users.
I'm not sure if macos-26-intel would work fine for those people using old mac intel systems with older macOS. 🤔

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved to 26 because the 15 was in a infinite loop. I think they deprecated
Putting 15 back ec5410b

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4hrs.. seems to be broken still. Reverting

image

@bucanero

Copy link
Copy Markdown
Contributor

Sure! master branch merged into this PR

thanks for all your efforts here @humbertodias 👍 I've triggered the CI checks to confirm everything builds ok.

Please follow up with zeldin if you have questions or need another review. 🙏

This branch had an error being deployed

1 failed deployment
DockerHub fce08b7b Deployed Sep 22, 2026 by humbertodias via dockerhub-push (linux/amd64) #114
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

Successfully merging this pull request may close these issues.

9 participants