Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,626
1,212
Mission [mostly] accomplished, we got a working gcc11 compiler on a PowerPC:

gcc11.png


Anyone who may want to make it build:

1. First build and install this branch of gcc10 using Apple native gcc42: https://github.com/iains/gcc-10-branch/tree/gcc-10-3-ppc
2. Using newly built gcc10, build gcc11: https://github.com/iains/gcc-11-branch

P. S. The process could be replicated on 10.6 PPC too, but needs adjustments. As of now, I tried to rebuild gcc10 as ppc32 on 10.5.8 and used that to install it on 10.6 PPC. It did install and apparently works. I have not yet tried it with gcc11. (Building gcc10 directly on 10.6 PPC failed, but should be possible. And unless 10.6 PPC is modified to re-introduce support for ppc64, m64 will not work.)
 
Last edited:

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,626
1,212
Mad skills

Installed gcc10 within Macports.

UPD. Patches have to be fixed, compiler works for basic stuff but spits out errors with complex things.

The following has only a historical record value. At the moment, gcc10-bootstrap, gcc11 and gcc12 build on Leopard and work normally. They also build on 10.6 PPC (10A190), but need a small patch found here. gcc11 and gcc12 build also on 10.6.8 Rosetta.

Apparently I have fixed gcc10 with Macports: just built mpich-gcc10 with CXX and Fortran enabled, it worked.

Code:
36-47:~ svacchanda$ port -v installed mpich-gcc10
The following ports are currently installed:
  mpich-gcc10 @3.4.2_0 requested_variants='-universal' platform='darwin 9' archs='ppc' date='2022-02-03T03:40:23+0800'
  mpich-gcc10 @3.4.2_0+fortran (active) requested_variants='+fortran-universal' platform='darwin 9' archs='ppc' date='2022-02-03T05:44:13+0800'

I had to manually place two dylibs from gcc10 built outside of Macports though: https://trac.macports.org/ticket/64577
Not sure if that was some random build error or what. Anyway, in result compiler appears fully functional.

P. S. Notice that, as of now, most probably it won’t build without significant manual work. I am not posting patches until I am sure everything works correctly. However if anyone wants to repeat that (or improve on), I did diff on Macports gcc10 source and Iain’s branch, generated patches and modified port file. Macports requires its own cctools and linker to be used, so setting will differ.

For those who don’t bother about Macports, all this is irrelevent. Both gcc10 and gcc11 do build on 10.5.8 for ppc/ppc64 (and on 10.6.8 Rosetta for ppc). One line to change is this, with example of gcc10 (don’t copy-paste, make a diff):

Code:
--- /Users/svacchanda/darwin.c    2022-01-30 15:15:59.000000000 +0800
+++ /Users/svacchanda/gcc-10-branch/gcc/config/darwin.c    2022-01-30 02:04:05.000000000 +0800

@@ -3569,7 +3569,7 @@
darwin_fold_builtin (tree fndecl, int n_args, tree *argp,
bool ARG_UNUSED (ignore))
{
-  unsigned int fcode = DECL_MD_FUNCTION_CODE (fndecl);
+  int fcode = DECL_MD_FUNCTION_CODE (fndecl);

if (fcode == darwin_builtin_cfstring)
{

P. S. This has been fixed in gcc12 and gcc10 10.4.0.
 
Last edited:

alex_free

macrumors 65816
Feb 24, 2020
1,060
2,245
Apparently I have fixed gcc10 with Macports: just built mpich-gcc10 with CXX and Fortran enabled, it worked.

Code:
36-47:~ svacchanda$ port -v installed mpich-gcc10
The following ports are currently installed:
  mpich-gcc10 @3.4.2_0 requested_variants='-universal' platform='darwin 9' archs='ppc' date='2022-02-03T03:40:23+0800'
  mpich-gcc10 @3.4.2_0+fortran (active) requested_variants='+fortran-universal' platform='darwin 9' archs='ppc' date='2022-02-03T05:44:13+0800'

I had to manually place two dylibs from gcc10 built outside of Macports though: https://trac.macports.org/ticket/64577
Not sure if that was some random build error or what. Anyway, in result compiler appears fully functional.

P. S. Notice that, as of now, most probably it won’t build without significant manual work. I am not posting patches until I am sure everything works correctly. However if anyone wants to repeat that (or improve on), I did diff on Macports gcc10 source and Iain’s branch, generated patches and modified port file. Macports requires its own cctools and linker to be used, so setting will differ.

For those who don’t bother about Macports, all this is irrelevent. Both gcc10 and gcc11 do build on 10.5.8 for ppc/ppc64 (and on 10.6.8 Rosetta for ppc). One line to change is this, with example of gcc10 (don’t copy-paste, make a diff):

Code:
--- /Users/svacchanda/darwin.c    2022-01-30 15:15:59.000000000 +0800
+++ /Users/svacchanda/gcc-10-branch/gcc/config/darwin.c    2022-01-30 02:04:05.000000000 +0800

@@ -3569,7 +3569,7 @@
darwin_fold_builtin (tree fndecl, int n_args, tree *argp,
bool ARG_UNUSED (ignore))
{
-  unsigned int fcode = DECL_MD_FUNCTION_CODE (fndecl);
+  int fcode = DECL_MD_FUNCTION_CODE (fndecl);

if (fcode == darwin_builtin_cfstring)
{
Please try building Cmake as a test of if it fixes the ABI incompatibies.
 
  • Like
Reactions: Project Alice

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,626
1,212
Please try building Cmake as a test of if it fixes the ABI incompatibies.

If you meant Macports gcc10, then no, unfortunately, it fails with multiple undeclared symbols errors. Also llvm-3.5 failed.
At the same time icu, sqlite3 and mpich-gcc10 did build. Weird.

In any case gcc10 in Macports needs to be rebuilt. I will go through patches carefully when I get time.

If you mean outside of Macports, then both gcc10 and gcc11 should work perfectly (aside of known bugs). If anything extra discovered, we should report that to gcc bugzilla.
 

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,626
1,212
Besides, I have got gcc11ppc on 10A190 and 10.6.8.

Code:
svacchanda$ /opt/svacchanda/gcc11ppc/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/opt/svacchanda/gcc11ppc/bin/gcc
COLLECT_LTO_WRAPPER=/opt/svacchanda/gcc11ppc/libexec/gcc/powerpc-apple-darwin10/11.2.1/lto-wrapper
Target: powerpc-apple-darwin10
Configured with: /Users/svacchanda/gcc-11-branch/configure --prefix=/opt/svacchanda/gcc11ppc --build=powerpc-apple-darwin10 --with-as=/Developer/usr/bin/as --with-ld=/Developer/usr/bin/ld --with-sysroot=/Developer/SDKs/MacOSX10.6.sdk --disable-multilib --disable-target-libsanitizer CC='/opt/svacchanda/gcc10ppc/bin/gcc -m32 -arch ppc --sysroot=/Developer/SDKs/MacOSX10.6.sdk' CXX='/opt/svacchanda/gcc10ppc/bin/g++ -m32 -arch ppc --sysroot=/Developer/SDKs/MacOSX10.6.sdk'
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.1 20211013 (GCC)
 
svacchanda$ sw_vers
ProductName:    Mac OS X
ProductVersion:    10.6.8
BuildVersion:    10K549
 
  • Like
Reactions: ChrisCharman

alex_free

macrumors 65816
Feb 24, 2020
1,060
2,245
If you meant Macports gcc10, then no, unfortunately, it fails with multiple undeclared symbols errors. Also llvm-3.5 failed.
At the same time icu, sqlite3 and mpich-gcc10 did build. Weird.

In any case gcc10 in Macports needs to be rebuilt. I will go through patches carefully when I get time.

If you mean outside of Macports, then both gcc10 and gcc11 should work perfectly (aside of known bugs). If anything extra discovered, we should report that to gcc bugzilla.
Either way, if you can compile the latest CMAKE outside of macports (or in it), AFAIK the ABI incompatibilities is fixed!

I just mean in general, if you have a compiler that can compile the latest CMake as is on 10.5.8.
 

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,626
1,212
Either way, if you can compile the latest CMAKE outside of macports (or in it), AFAIK the ABI incompatibilities is fixed!

I just mean in general, if you have a compiler that can compile the latest CMake as is on 10.5.8.

Latest Cmake builds for ppc32 with gcc7 in Macports with no issues (in 10.5.8, 10.6 PPC and 10.6.8 Rosetta).
Building for ppc64 is broken though.

P. S. If you have any issues building, I can check if I modified port files and confirm how to build. I do not build for/in Tiger though.
 
  • Like
Reactions: ChrisCharman

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,626
1,212
A new port of gcc10 allowing to bootstrap it easily on 10.5.8 and likely 10.4.11: https://ports.macports.org/port/gcc10-bootstrap/

Most of recent tweaks for PowerPC Darwin are included. (Installation on 10.6 may require some changes.)

UPD March 15: Works on 10.5.8, works on 10.6 PPC with my patches, FAILS on 10.4.11 and FAILS on 10.6.8 Rosetta.
 
Last edited:
  • Like
Reactions: fra9000

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,626
1,212
And finally,

Code:
36-72% port -v installed libgcc11
The following ports are currently installed:
  libgcc11 @11.2.0_3 (active) requested_variants='' platform='darwin 10' archs='ppc' date='2022-03-09T07:19:42+0800'
36-72% port -v installed gcc11
The following ports are currently installed:
  gcc11 @11.2.0_3 (active) requested_variants='' platform='darwin 10' archs='ppc' date='2022-03-09T01:38:58+0800'
36-72% port -v installed libgcc
The following ports are currently installed:
  libgcc @5.0_0 (active) requested_variants='' platform='darwin 10' archs='ppc' date='2022-03-09T07:26:11+0800'

Natively built on 10A190.
 

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,626
1,212
Please try building Cmake as a test of if it fixes the ABI incompatibies.

Okay, I can confirm now that gcc11 builds cmake 3.22.3.

Code:
36-78% port -v installed cmake
The following ports are currently installed:
  cmake @3.21.3_0 requested_variants='' platform='darwin 10' archs='ppc' date='2021-10-05T04:11:22+0800'
  cmake @3.21.4_0 requested_variants='' platform='darwin 10' archs='ppc' date='2021-11-15T03:46:29+0800'
  cmake @3.22.1_0 requested_variants='' platform='darwin 10' archs='ppc' date='2021-12-16T17:04:48+0800'
  cmake @3.22.2_0 requested_variants='' platform='darwin 10' archs='ppc' date='2022-01-28T16:56:53+0800'
  cmake @3.22.3_0 (active) requested_variants='' platform='darwin 10' archs='ppc' date='2022-03-11T19:30:22+0800'
 

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,626
1,212
I just mean in general, if you have a compiler that can compile the latest CMake as is on 10.5.8.

I have rebuilt now gcc10 using gcc10-bootstrap on 10A190 with a modified patch, and apparently Fortran is fixed. Configure of mpich-gcc10 (failing earlier) passed successfully, now compilation running.

I want to rebuild gcc10-bootstrap once again to verify, and upon that we have a fully functional and hopefully reproducibly so Macports environment with gcc10/gcc11 on 10.6 PPC. libgcc is rebuilt with libgcc11, so gcc7 goes obsolete. You won’t even need to build it at all.

To not duplicate posts, I refer to this post: https://forums.macrumors.com/thread...-6-powerpc-10a190-and-10-6-8-rosetta.2332711/
I will upload overlay repo update there soon, hopefully today if I don’t die on a spot LOL. Rebuilt gcc10 twice today, and need to do it once again.
 
  • Haha
Reactions: alex_free

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,626
1,212
Please try building Cmake as a test of if it fixes the ABI incompatibies.

I have just built the latest Cmake on Tiger using gcc7 overnight. Now, it wasn't pleasant: took many hours (Quad was busy, so I used G4 with Tiger), but built and installed smoothly.
 

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,626
1,212
A quick update:

gcc11 @11.3.0 builds fine on Leopard and 10A190 using gcc10-bootstrap.

Apparently, jit is fixed (or I screwed it up earlier myself). Anyway, it may be left in the portfile to build now.

If you will build on Leopard with +universal, it may be needed to use an earlier version of gcc10-bootstrap port (go to history of the port on Github, pick from there, if the current version fails to build). Yes, this is ugly, but there were changes to how +universal is handled, and some were/are broken. I think I still use v. 0 on Leopard, which works fine. (This issue is not relevant to 10A190 or Leopard ppc32.)

Building on 10A190 requires my patches, it gonna fail as-is. I will make a Github repo soon and post a link here.

Building on 10.6.8 Rosetta is broken – gcc10-bootstrap fails to build (and perhaps will never be fixed, since no one cares). Alternatives: build gcc7, use it to build gcc10, use it to build gcc11 (not tested, but should work); or, pre-build gcc10-bootstrap on 10A190 (sudo port -v destroot gcc10-bootstrap), install that into 10.6.8, use it to build gcc11 (confirmed to work). gcc11 for ppc on 10.6.8 Rosetta does not need patching of darwin.h, but likely needs a patch for darwin.c (I have it here just above).

P. S. gcc11/libgcc11 has changes to dylibs, once you upgrade, older gcc will be broken (unless you rebuild etc, not tested personally). But you get the latest gcc11 working :)

UPD. jit confirmed to build, TLS confirmed to fail (so --disable-tls is correct).
 
Last edited:
  • Like
Reactions: fra9000

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,626
1,212
By the way, do not use ld64-127. Use ld64-97, it works far better for ppc. In particular, a build of libgcc11 failed for me with ld64-127. Once I rebuilt ld64 with ld64-97, I was able to restart the build successfully (not from scratch, just resume).

If you built ld64-127 initially, do this:
Code:
sudo port -v install ld64-97
sudo port -v upgrade --enforce-variants ld64 -ld64_127 +ld64_97
 

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,626
1,212
A small update: to break dependency cycle with libgcc11 depending on itself, just comment out or delete compiler.blacklist line in gcc11 portfile. I have just installed libgcc11 and gcc11 on 10A190 from scratch, so confirm this pathway.

That is, build gcc10-bootstrap, edit gcc11 portfile, build libgcc11, build gcc11. On 10.5.8 you will also need to edit libgcc portfile so that it uses libgcc11 and not libgcc7. On 10A190 libgcc is good as-is.
 
  • Like
Reactions: ChrisCharman

ChrisCharman

macrumors 6502
May 10, 2020
357
539
Bournemouth, UK
A small update: to break dependency cycle with libgcc11 depending on itself, just comment out or delete compiler.blacklist line in gcc11 portfile. I have just installed libgcc11 and gcc11 on 10A190 from scratch, so confirm this pathway.

That is, build gcc10-bootstrap, edit gcc11 portfile, build libgcc11, build gcc11. On 10.5.8 you will also need to edit libgcc portfile so that it uses libgcc11 and not libgcc7. On 10A190 libgcc is good as-is.
May be worth asking the mods to merge your two threads, instead of double posting to each one separately.
 

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,626
1,212
May be worth asking the mods to merge your two threads, instead of double posting to each one separately.

I only duplicated gcc11-relevant stuff. I think it still makes sense to have a dedicated thread for the main compiler, otherwise it gets buried in other stuff about Macports. Also, on Leopard gcc11 builds without Macports too.
 
  • Like
Reactions: ChrisCharman

Mirage256

macrumors newbie
Jul 8, 2022
27
24
Hawaii
Hello! Sorry to necro this thread, but I've been interested in building GCC 11.2 on my PowerBook G4 running 10.5, yet having issues getting gcc10-bootstrap to compile. In particular, it's been getting stuck on this error:

Code:
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_gcc10-bootstrap/gcc10-bootstrap/work/build/./gcc/xgcc -B/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_gcc10-bootstrap/gcc10-bootstrap/work/build/./gcc/ -B/opt/local/libexec/gcc10-bootstrap/powerpc-apple-darwin9/bin/ -B/opt/local/libexec/gcc10-bootstrap/powerpc-apple-darwin9/lib/ -isystem /opt/local/libexec/gcc10-bootstrap/powerpc-apple-darwin9/include -isystem /opt/local/libexec/gcc10-bootstrap/powerpc-apple-darwin9/sys-include   -fno-checking -g -O2 -pipe -arch ppc -O2  -g -O2 -pipe -arch ppc -DIN_GCC    -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -mmacosx-version-min=10.4 -Wa,-force_cpusubtype_ALL -fno-common -mlong-double-128 -maltivec -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -mmacosx-version-min=10.4 -Wa,-force_cpusubtype_ALL -fno-common -mlong-double-128 -maltivec -I. -I. -I../.././gcc -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_gcc10-bootstrap/gcc10-bootstrap/work/gcc-10.3.0/libgcc -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_gcc10-bootstrap/gcc10-bootstrap/work/gcc-10.3.0/libgcc/. -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_gcc10-bootstrap/gcc10-bootstrap/work/gcc-10.3.0/libgcc/../gcc -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_gcc10-bootstrap/gcc10-bootstrap/work/gcc-10.3.0/libgcc/../include    -o unwind-dw2_s.o -MT unwind-dw2_s.o -MD -MP -MF unwind-dw2_s.dep -DSHARED -fexceptions -c /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_gcc10-bootstrap/gcc10-bootstrap/work/gcc-10.3.0/libgcc/unwind-dw2.c
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_gcc10-bootstrap/gcc10-bootstrap/work/gcc-10.3.0/libgcc/unwind-dw2.c:31:10: fatal error: unwind.h: No such file or directory
   31 | #include "unwind.h"
      |          ^~~~~~~~~~
compilation terminated.
make[3]: *** [unwind-dw2_s.o] Error 1

I know that there's a warning about GCC not compiling while libunwind-headers is active, and this looks like a headers issue, so I de-activated it and ran
Code:
port clean gcc10-bootstrap
and started from scratch, but I still got this same exact error. My understanding above is that gcc10-bootstrap should work without any extra patches - is this true? If so, has something maybe broken the port on Leopard since then?
 
  • Like
Reactions: barracuda156

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,626
1,212
Awesome! Looked through, found the note about running make unwind.h inside the libgcc directory, and it seems to have worked. The build is back on track, although it's probably going to be a while until it finishes and I know for sure. Thanks so much for the tip!

Interesting that so far as I remember I never had this error on 10.5.8 (ppc+ppc64) or 10.6 (ppc). Glad to hear that worked for you!
 
  • Like
Reactions: Mirage256
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.