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,620
1,212
So I have built libgcc12 and gcc12 now on 10.6.8 Rosetta for PPC:
Code:
10:~ svacchanda$ port -v installed libgcc12
The following ports are currently installed:
  libgcc12 @12.1.0_3+stdlib_flag (active) requested_variants='' platform='darwin 10' archs='ppc' date='2022-07-17T15:46:00+0700'
10:~ svacchanda$ port -v installed gcc12
The following ports are currently installed:
  gcc12 @12.1.0_3 (active) requested_variants='' platform='darwin 10' archs='ppc' date='2022-07-18T01:31:17+0700'
10:~ svacchanda$ /opt/local/bin/gcc-mp-12 -v
Using built-in specs.
COLLECT_GCC=/opt/local/bin/gcc-mp-12
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/ppc-apple-darwin10/12.1.0/lto-wrapper
Target: ppc-apple-darwin10
Configured with: /opt/local/var/macports/build/_opt_PPCRosettaPorts_lang_gcc12/gcc12/work/gcc-12.1.0/configure --prefix=/opt/local --build=ppc-apple-darwin10 --enable-languages=c,c++,objc,obj-c++,lto,fortran,jit --libdir=/opt/local/lib/gcc12 --includedir=/opt/local/include/gcc12 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-12 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-12 --with-gxx-include-dir=/opt/local/include/gcc12/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-isl=/opt/local --with-zstd=/opt/local --enable-checking=release --disable-multilib --enable-lto --enable-libstdcxx-time --without-build-config --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --enable-host-shared --with-darwin-extra-rpath=/opt/local/lib/libgcc --with-libiconv-prefix=/opt/local --with-tune-cpu=G4 --disable-tls --with-pkgversion='MacPorts gcc12 12.1.0_3'
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.1.0 (MacPorts gcc12 12.1.0_3)

No special patches needed anymore on 10.6.8 (and presumably on 10.5.8), though in the portfile some minor changes are required for this to work.
gcc12_ppc.png
 

Mirage256

macrumors newbie
Jul 8, 2022
27
24
Hawaii
I'm almost finished with GCC 11, and I'd love to try GCC 12 on 10.5 and confirm that it works. What were the changes you needed to make to the Portfile? (I know for sure one I'll need to do is comment out the version check for Darwin < 10)
 
  • Like
Reactions: barracuda156

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,620
1,212
I'm almost finished with GCC 11, and I'd love to try GCC 12 on 10.5 and confirm that it works. What were the changes you needed to make to the Portfile? (I know for sure one I'll need to do is comment out the version check for Darwin < 10)

Here are the changes to gcc11 portfile in order to build it with gcc10-bootstrap (typography corrections can safely be ignored, of course): https://github.com/macports/macports-ports/commit/e575bfcfe049d0a79a435fbbac6f730cffe707bd

Basically, remove older gcc bans, specify gcc10-bootstrap, and you are good to go. Without the former I was getting a dependency cycle which was otherwise rather annoying to bypass: https://trac.macports.org/ticket/65146

For gcc12 I made identical changes, and have it built now on 10.6.8 for ppc32.

--with-tune-cpu=G4 is optional and obviously good for G4 and Rosetta (this is from Rosetta tree), while on G5 you can use --with-tune-cpu=G5 instead.
JIT builds on PPC, at least using gcc10. (I did not try using gcc7 to build gcc11–gcc12.)

P. S. There might be some extra complications on 10.5.8 if you build as +universal (ppc + ppc64). If you face errors with that and don’t find an easy fix, let me know, I will try to figure out what to do. (Cannot test anything for ppc64 atm, no access to my PowerMacs.)
 
  • Like
Reactions: Mirage256

Mirage256

macrumors newbie
Jul 8, 2022
27
24
Hawaii
Alright, thanks! I applied all of your changes to GCC 12's Portfile. I substituted --with-tune-cpu=7450 instead of G4, since my PowerBook's CPU is a 7447A and it's compatible with the 7450. I also had to make one additional change; I had to comment out the default_variants-append +stdlib_flag line, inside of the stdlib_flag variant section, it otherwise adds a newer version of Clang to the dependencies list. But after that, everything seems to be going great, and hopefully it'll be finished by tomorrow morning.

Thanks for your help and for all your work porting software, it's really exciting being able to compile and run such modern programs on these old PowerPC machines!
 
  • Like
Reactions: barracuda156

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,620
1,212
Alright, thanks! I applied all of your changes to GCC 12's Portfile. I substituted --with-tune-cpu=7450 instead of G4, since my PowerBook's CPU is a 7447A and it's compatible with the 7450. I also had to make one additional change; I had to comment out the default_variants-append +stdlib_flag line, inside of the stdlib_flag variant section, it otherwise adds a newer version of Clang to the dependencies list. But after that, everything seems to be going great, and hopefully it'll be finished by tomorrow morning.

Thanks for your help and for all your work porting software, it's really exciting being able to compile and run such modern programs on these old PowerPC machines!
Sorry, I forgot about stdlib flag thing. Yeah, it’s not tested with PPC and is done in a portfile in a wrong way which asks for clang. In fact only libcxx is required for it, which doesn’t need clang. But at the moment it won’t work anyway: Iain says extra fixes are needed for libcxx. (I have patches to build libcxx for PPC, but functionality is untested, and we will likely need a later version of it than Macports has in a portfile – I think it is from clang5.)
 
  • Like
Reactions: Mirage256

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,620
1,212
Anyone interested to build it, below is the config I used for a build outside Macports.
As the necessary prerequisite install gcc10-bootstrap from Macports: https://ports.macports.org/port/gcc10-bootstrap
On 10A190 use my portfile: https://github.com/barracuda156/macports-ports/tree/snow-ppc/lang/gcc10-bootstrap
And also this branch of GCC: https://github.com/barracuda156/gcc-git/tree/snow

Code:
mkdir ${builddir}
cd ${builddir}
export PATH=/opt/local/libexec/gcc10-bootstrap/bin:/bin:/sbin:/usr/bin:/usr/sbin

${gcc_sourcedir}/configure --prefix=${installdir} --build=powerpc-apple-darwin${ver} --host=powerpc-apple-darwin${ver} --target=powerpc-apple-darwin${ver} --enable-languages=all --with-as=/usr/bin/as --with-ld=/usr/bin/ld CC="/opt/local/libexec/gcc10-bootstrap/bin/gcc -arch ${arch}" CXX="/opt/local/libexec/gcc10-bootstrap/bin/g++ -arch ${arch}" --with-sysroot=/ --disable-multilib --disable-nls --disable-target-libsanitizer --enable-host-shared --with-tune-cpu=${cpu} >conf.txt

time nice make -j${jobs} STAGE1_CFLAGS="-O1 -pipe -mdynamic-no-pic" STAGE1_CXXFLAGS="-O1 -pipe -mdynamic-no-pic" >b.txt 2>e.txt

Replace ${ver} with 9 for Leopard and with 10 for Snow Leo (10A190 or Rosetta), ${arch} with ppc or ppc64 (only Leopard), ${cpu} with G4 or G5. Rest should be obvious.
 
Last edited:

rdircio

macrumors newbie
Apr 14, 2023
1
1
I have 10.5.8 ppc, and i already built gcc10 using gcc10-bootstrap (4 days in my powerbook g4 17" 1.67ghz)

Can any of you kindly tell me how to get gcc11 built?

Please? :)
 
  • Like
Reactions: barracuda156

dpogue

macrumors newbie
Aug 20, 2023
7
32
@barracuda156 Sincere thanks for all the work you've put in to getting modern software building on Leopard. I've seen your pull requests across numerous diverse GitHub repos, and it's very appreciated.

I've been trying to build either gcc11 or gcc12 on a new Leopard installation, and I was able to gcc10-bootstrap installed with no problems, but after applying the fixes from the above pull request to my local Portfiles, both newer gcc versions seem to be wanting to install gcc7 as a dependency. Do you happen to know if something has changed with other dependencies such that there's now an unwanted gcc7 requirement?

It seems like gcc12 is the recommended option, but I also saw the threads about random build failures with TLS stuff. I had reasonably good luck with gcc11 on a previous attempt. Do you recommend going with 11 or 12?
 

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,620
1,212
@barracuda156 Sincere thanks for all the work you've put in to getting modern software building on Leopard. I've seen your pull requests across numerous diverse GitHub repos, and it's very appreciated.

I've been trying to build either gcc11 or gcc12 on a new Leopard installation, and I was able to gcc10-bootstrap installed with no problems, but after applying the fixes from the above pull request to my local Portfiles, both newer gcc versions seem to be wanting to install gcc7 as a dependency. Do you happen to know if something has changed with other dependencies such that there's now an unwanted gcc7 requirement?

It seems like gcc12 is the recommended option, but I also saw the threads about random build failures with TLS stuff. I had reasonably good luck with gcc11 on a previous attempt. Do you recommend going with 11 or 12?

I beg a pardon if something is missed in that PR, I did not touch it for quite some time for unrelated reasons.

To begin with: you may be aware of this, but in just case: Macports will override settings for everything in its /var/macports/sources on every sync, so unless you have everything in a local repo, so it is a bit annoying on 10.5.

To make a newer GCC usable on 10.5 (AFAIK, there is no difference here, if you pick gcc11, gcc12 or possibly gcc-devel), it is needed to:
– change the latest supported libgcc to the chosen one, this requires modifying gcc7 portfile, otherwise it will try using gcc7;
– modify libgcc portfile;
– modify _resources/group/compilers-1.0.tcl portgroup;
– modify _resources/compilers/gcc_compilers.tcl.

Then deal with a can of worms, if you care about MPICH:
– modify _resources/group/mpi-1.0.tcl;
– perhaps mpich portfile.

(Ping me specifically if you need fortran PG working, it needs a custom build of gcc at the moment. Probably you don’t though – most of Fortran works fine as is, only FMP won’t and select Fortran ports using IEEE modules.)

I will try to find time and enough caffeine to go through specific stuff, then I can say for sure what and where to change. (Nothing esoteric aside of MPICH though.)

Some random warnings:

If you had gcc7 built, then once you move to gcc11/gcc12 setup, gcc7 will be broken and gonna need a rebuild. That is expected.
Another issue, if you really need gcc4.8 or gcc5 to work, getting it from gcc12 will require building every libgcc down to libgcc6. This takes time even of the Quad. Don’t ask why it is done this way.
Finally, universal builds are essentially broken, so for the sanity sake either build for ppc or ppc64 but not +universal. The latter is possible, but painful and gonna require time and effort, much of those.

P. S. Re gcc11 vs gcc12: if you already have a working setup with gcc11, don’t bother. I cannot name a real-life case where gcc11 fails but gcc12 works (not that this means much, since I mostly use gcc12 now, but I used gcc11 before). gcc12 indeed had some thing broken which worked fine with gcc11; I think those have been fixed for the most part.
On 10.6 gcc12 makes a better sense since it is the default, so you don’t need to change every setting in portgroups. Otherwise gcc11 is fine, I believe, and provisionally more reliable.
 
  • Like
Reactions: doctor_dog

Mirage256

macrumors newbie
Jul 8, 2022
27
24
Hawaii
I noticed today that GCC 13 was changed to be the new default GCC version - however, the Portfile has platforms set to >= 10, which suggests the port apparently won't build on PPC Leopard. I was wondering if this is just because no one's tested it, or if it's indeed accurate and the macports version of GCC 13 is a no-go at the moment?
 

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,620
1,212
I noticed today that GCC 13 was changed to be the new default GCC version - however, the Portfile has platforms set to >= 10, which suggests the port apparently won't build on PPC Leopard. I was wondering if this is just because no one's tested it, or if it's indeed accurate and the macports version of GCC 13 is a no-go at the moment?

Hold on, I am just building it myself :)
If everything works, I will update my GH branch to use gcc13/libgcc13, and then a forever-hanging PR to move older systems to the new gcc too.

gcc13 should build fine in fact, I did build it from master branch a few months ago, with modula2 and rust enabled. But did not move to it back then.
 
  • Like
Reactions: Mirage256

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,620
1,212
I noticed today that GCC 13 was changed to be the new default GCC version - however, the Portfile has platforms set to >= 10, which suggests the port apparently won't build on PPC Leopard. I was wondering if this is just because no one's tested it, or if it's indeed accurate and the macports version of GCC 13 is a no-go at the moment?

Okay, I can confirm that gcc13 builds fine for PowerPC. 10A190 needs a 3-line patch :) Rosetta and Leopard should be good as-is.
 

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,620
1,212
Here we go:
gcc13.png


Did not enable Rust and Modula2 here yet, should be done in a variant, but this was painless. Just took some hours.
 
  • Like
Reactions: eastone

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,620
1,212
Anyone interested to try, this should build: https://github.com/barracuda156/macports-ports/tree/gcc13
Notice, that this branch does not include a fix for gcc10-bootstrap for 10A190, which is needed on 10.6 PPC if you start from scratch. You can find it in snow-ppc branch.

Leopard will require extra fixes to build everything correctly – not to gcc13 as such, but to Macports logic of compilers and runtime choice. I will return to that soon.

Finally, my Fortran fixes are experimental, so do not use it for rocket science :)
 
  • Love
Reactions: Romain_H

Mirage256

macrumors newbie
Jul 8, 2022
27
24
Hawaii
Okay, I can confirm that gcc13 builds fine for PowerPC. 10A190 needs a 3-line patch :) Rosetta and Leopard should be good as-is.
Thanks for the confirmation! I'll upgrade to GCC 13 then. The ol' PowerBook appreciates the heads up, it takes quite a while to get through a modern version of GCC on just a single core G4 running at 1.5GHz. Definitely not a build you want interrupted if you can avoid it haha.

Look forward to giving your Fortran enabled fork a try once it works with Macports!
 

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,620
1,212
Thanks for the confirmation! I'll upgrade to GCC 13 then. The ol' PowerBook appreciates the heads up, it takes quite a while to get through a modern version of GCC on just a single core G4 running at 1.5GHz. Definitely not a build you want interrupted if you can avoid it haha.

Look forward to giving your Fortran enabled fork a try once it works with Macports!

Which OS are you running, 10.5.8? On 10.6 ppc (10a190) Macports choice of compilers should work fine, provided you make needed settings in macports.conf (which are described in a dedicated thread here) and pick a few fixes to some required ports (my snow-ppc branch should have everything, reasonably up-to-date). Leopard should not need custom settings and overlay fix-ups, but yeah, it needs a few changes to compilers logic.

Fortran in GCC is supported for PowerPC as-is, in the upstream (but you rather build GCC from Iain’s repo instead, if not Macports). What I add is ieee_arithmetic module, which is used in some modern Fortran software (and without it that software won’t build at all).

You can manually add those patches (borrowing from my gfortran branch of gcc-git or patches to Macports from gcc13 branch). It should build and work to build other software. Why it is experimental is that some tests from Fortran test suite for IEEE module still fail (most of tests pass).

Notice, if you build outside of Macports, you need to build gcc10 first in order to build gcc13. But you won’t need to build libgcc13 at least.
 
  • Like
Reactions: Mirage256

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,620
1,212
UPD. All should be good now on 10A190. Rebuilt gcc13, used it to build python312, the error did not show up.
I have updated my gcc13 branch: https://github.com/barracuda156/macports-ports/tree/gcc13

P. S. If you get an error re circular dependencies, delete temporarily macports-gcc-13 from ports/_resources/port1.0/compilers/gcc_compilers.tcl
You do not need it there to build gcc13. Other trick was to remove blacklisted old gcc in gcc1* portfile.

Ask here if issues persist.
 
Last edited:
  • Like
Reactions: doctor_dog

Mirage256

macrumors newbie
Jul 8, 2022
27
24
Hawaii
Which OS are you running, 10.5.8? On 10.6 ppc (10a190) Macports choice of compilers should work fine, provided you make needed settings in macports.conf (which are described in a dedicated thread here) and pick a few fixes to some required ports (my snow-ppc branch should have everything, reasonably up-to-date). Leopard should not need custom settings and overlay fix-ups, but yeah, it needs a few changes to compilers logic.

Fortran in GCC is supported for PowerPC as-is, in the upstream (but you rather build GCC from Iain’s repo instead, if not Macports). What I add is ieee_arithmetic module, which is used in some modern Fortran software (and without it that software won’t build at all).

You can manually add those patches (borrowing from my gfortran branch of gcc-git or patches to Macports from gcc13 branch). It should build and work to build other software. Why it is experimental is that some tests from Fortran test suite for IEEE module still fail (most of tests pass).

Notice, if you build outside of Macports, you need to build gcc10 first in order to build gcc13. But you won’t need to build libgcc13 at least.
Yup, 10.5.8. That's cool to hear - I don't have any Fortran software that would take advantage of it at the moment, but I'll try adding the patches next time I rebuild GCC. No rocket software, I promise :p

Actually, I do have another question about compiler logic in macports though. Is it possible to eliminate GCC 7 / libgcc7 completely? I've tried making a custom overlay with GCC 7 and the libgcc port and commenting out any explicit dependency on libgcc7 or libgcc8, as well as setting GCC 13 as the preferred compiler in compilers-1.0.tcl and gcc_compilers.tcl - but Macports keeps wanting to reinstall libgcc7 any time it gets removed.

The issue is that I build macports-base from source (for mp-stats to work), so it uses libgcc13, but then the base breaks whenever I have to reinstall libgcc7 after port reclaim uninstalls it (since it needs to deactivate libgcc13 first to reinstall libgcc7, and then the port utility doesn't work anymore after that).
 
Last edited:

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,620
1,212
Actually, I do have another question about compiler logic in macports though. Is it possible to eliminate GCC 7 / libgcc7 completely? I've tried making a custom overlay with GCC 7 and the libgcc port and commenting out any explicit dependency on libgcc7 or libgcc8, as well as setting GCC 13 as the preferred compiler in compilers-1.0.tcl and gcc_compilers.tcl - but Macports keeps wanting to reinstall libgcc7 any time it gets removed.

The issue is that I build macports-base from source (for mp-stats to work), so it uses libgcc13, but then the base breaks whenever I have to reinstall libgcc7 after port reclaim uninstalls it (since it needs to deactivate libgcc13 first to reinstall libgcc7, and then the port utility doesn't work anymore after that).

Well, yes. What is needed should roughly be here: https://github.com/barracuda156/macports-ports/tree/leopard-gcc

1. I suspect that universal builds are broken. Save yourself from the pain and build either ppc or ppc64. The first is better tested.
2. Something might be missing in that tree, and it is gcc12-based, so obviously you need to do the same for gcc13 instead, or wait until I rebase. I remember about that, but been short on time.
 

Mirage256

macrumors newbie
Jul 8, 2022
27
24
Hawaii
Well, yes. What is needed should roughly be here: https://github.com/barracuda156/macports-ports/tree/leopard-gcc

1. I suspect that universal builds are broken. Save yourself from the pain and build either ppc or ppc64. The first is better tested.
2. Something might be missing in that tree, and it is gcc12-based, so obviously you need to do the same for gcc13 instead, or wait until I rebase. I remember about that, but been short on time.
Ah that did the trick! I realized I had an older repo for GCC 11 and I think perhaps the stale version of the libgcc port in there was still pulling in libgcc7. After nuking it and applying your changes (substituting in GCC 13 instead of 12) to a fresh copy of the libgcc port from Macports, everything works great now, I no longer get gcc7 in the dependency tree. Thanks for your help!
 
  • Like
Reactions: barracuda156

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,620
1,212
Ah that did the trick! I realized I had an older repo for GCC 11 and I think perhaps the stale version of the libgcc port in there was still pulling in libgcc7. After nuking it and applying your changes (substituting in GCC 13 instead of 12) to a fresh copy of the libgcc port from Macports, everything works great now, I no longer get gcc7 in the dependency tree. Thanks for your help!

I have rebased the PR linked above to use gcc13.
 
  • Like
Reactions: Mirage256

barracuda156

macrumors 68000
Original poster
Sep 3, 2021
1,620
1,212
I have rebased the PR linked above to use gcc13.

Ironically, I cannot get ppc64 build working atm. Likely because I have gcc10-bootstrap as +universal on Leopard, but it is still a bug, from what it looks.

To be on a safe side, start from building -universal, and I guess, avoid ppc64 for the time-being.

We will try to sort this out shortly.
 
  • Love
Reactions: Romain_H

3uc1id

macrumors newbie
Nov 29, 2018
3
4
Hello everyone, I have a couple questions. I have built gcc10-bootstrap on my G5 using macports. Can this be used to build ports other than newer versions of gcc? I'm trying to get numpy building again on ppc and one of the issues is the lack of gcc >= 8.4. My second question is, does it take much more than adding three lines to the gcc11+ portfiles to get them to build?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.