As mentioned, gcc7 needs some tweaks to build properly for PPC SnowLeopard. Basically in a few places, you have to tell gcc7 to behave like Leopard instead of SnowLeopard, because the System in PPC SnowLeopard does not have the expected symbols and features that are found in the System on SnowLeopard 10.6.8. I did that with a patch in the gcc7 source code, and that is automatically added when you build gcc7 using my "Portfile Overlay" (new term, description coming shortly).
When using MacPorts, if you want to make changes to the ports to suit certain purposes you may have, you set up a folder that is laid out the way the MacPorts main portfile folder is set up. Then you tell MacPorts to look in your folder FIRST for a Portfile. If MacPorts finds your folder has the Portfile it is looking for (eg gcc7) then it will use that and stop looking. If MacPorts does not find a Portfile for the port it is looking for in your folder, then it goes on (falls back) to the main MacPorts portfile repository.
To do this, you generate the required folder in the required layout (very simple) and then then tell macports to use it.
I have made a folder of portfiles that are tweaked for PPC SnowLeopard, and I have uploaded that folder to here:
<
https://github.com/kencu/PPCSnowLeopardPorts>
I have been doing this for a long time, years in fact, and you will find other overlays on that github site, but the only one you are interested in right now is PPCSnowLeopardPorts. You would download that folder (using git if you can, but some other way such as using a web browser if you can't use git yet on this system). Then you put that folder somewhere with permissions that MacPorts can accept. I like to use
/opt/PPCSnowLeopardPorts
so if you are following this along, I suggest you use that too. If you don't want to do what I suggest, and want to put that folder somewhere else, OK, but be careful about permissions -- it will often not work right if you put in your home folder somewhere, for example, because MacPorts has some trouble reading from there (sandboxing again -- your home folder is usually protected from MacPorts looking in there).
Then you tell MacPorts you want to use that folder as an overlay. To do that, you edit another configuration file (surprised? I think not ... ) /opt/local/etc/macports/sources.conf and you add your folder ABOVE the defaults portfile folder (so it will be found first). I added mine like this:
Code:
$ diff -u /opt/local/etc/macports/sources.conf.default /opt/local/etc/macports/sources.conf
--- /opt/local/etc/macports/sources.conf.default 2021-08-22 14:16:52.000000000 -0700
+++ /opt/local/etc/macports/sources.conf 2021-08-24 00:30:40.000000000 -0700
@@ -27,4 +27,7 @@
# sites, etc.), the primary MacPorts source must always be tagged
# "[default]", even if switched from the default "rsync://" URL.
+# override repo
+file:///opt/PPCSnowLeopardPorts
+
rsync://rsync.macports.org/macports/release/tarballs/ports.tar [default]
or, if diff files still seem hard to read to you, then the working part of the file looks like this now:
Code:
# For proper functionality of various resources (port groups, mirror
# sites, etc.), the primary MacPorts source must always be tagged
# "[default]", even if switched from the default "rsync://" URL.
# override repo
file:///opt/PPCSnowLeopardPorts
rsync://rsync.macports.org/macports/release/tarballs/ports.tar [default]
Now if you have got this far, you need to run "sudo port -v sync" one more time (to generate the PortIndex in my overlay repo that MacPorts will now use). This only takes a few seconds, because there are only 12 ports in there (so far) that I have had to tweak.
Now, if you are like me, more ports will build (the ones I fixed in that repo) and MacPorts will no longer try to use gcc11 on PPC SnowLeopard (which does not work). It will instead use gcc7/libgcc7 which does work. And when you try to install gcc7, you will use my very slightly patched version that appears to be correctly fixed for PPC SnowLeopard. If you are interested in the gcc7 patches needed, you can view them here:
a local repository of MacPorts that are configured for an installation of Snow Leopard for PPC and shadow newer incompatible versions of ports - PPCSnowLeopardPorts/patch-gcc7-darwin-config-for-PPC...
github.com
If you are a gcc genius and can improve upon my tweaks, I welcome the input!
We are getting close now to a working setup, but we have one more tweak to make. MacPorts compiler selection will try to use clang compilers on SnowLeopard, but we need to force it to never use clang compilers on PPC SnowLeopard, as they don't work there. Also, MacPorts base will try to use gcc 11, 10, 9, and 8 on SnowLeopard, but on PPC SnowLeopard, we currently only have gcc7 working. To override this, the PPCSnowLeopardPorts overlay repo has made a few tiny edits to the compiler selection process in these files:
Code:
$ diff -ur /opt/macports-ports/_resources/port1.0/compilers /opt/PPCSnowLeopardPorts/_resources/port1.0/compilers
diff -ur /opt/macports-ports/_resources/port1.0/compilers/clang_compilers.tcl /opt/PPCSnowLeopardPorts/_resources/port1.0/compilers/clang_compilers.tcl
--- /opt/macports-ports/_resources/port1.0/compilers/clang_compilers.tcl 2021-08-24 22:45:43.000000000 -0700
+++ /opt/PPCSnowLeopardPorts/_resources/port1.0/compilers/clang_compilers.tcl 2021-08-29 19:13:24.000000000 -0700
@@ -11,7 +11,7 @@
# Clang 9.0 and newer only on 11+ (Darwin 20)
global os.major os.arch
-
+if { ${os.arch} ne "pcc" } {
#if { $${os.major} >= 10 } {
# TODO: evaluate compatibility of clang-{10,11} as defaults instead of 9.0
#lappend compilers macports-clang-11
@@ -53,3 +53,4 @@
lappend compilers macports-clang-3.3
}
}
+}
\ No newline at end of file
diff -ur /opt/macports-ports/_resources/port1.0/compilers/gcc_compilers.tcl /opt/PPCSnowLeopardPorts/_resources/port1.0/compilers/gcc_compilers.tcl
--- /opt/macports-ports/_resources/port1.0/compilers/gcc_compilers.tcl 2021-08-24 22:45:43.000000000 -0700
+++ /opt/PPCSnowLeopardPorts/_resources/port1.0/compilers/gcc_compilers.tcl 2021-08-29 19:15:00.000000000 -0700
@@ -5,12 +5,12 @@
global os.major os.arch
-if { ${os.major} >= 10 } {
+if { ${os.major} >= 11 } {
lappend compilers macports-gcc-11 macports-gcc-10
}
if { ${os.arch} ne "arm" } {
- if { ${os.major} >= 10 } {
+ if { ${os.major} >= 11 } {
lappend compilers macports-gcc-9 macports-gcc-8
}
if { ${os.major} < 20 } {
You can see that if the os.arch is "ppc" (such as on PPC SnowLeopard) then clang compilers will never be selected. And the gcc compiler selection has been tweaked so the newer gcc versions past gcc7 are only used on Lion and above. So on our SnowLeopard system, gcc7 will be the newest one used (which works).
This is great, and now many more things will build.
But there is still one problem. The way MacPorts works, it will look in the directory
where the portfile is for the _resources folder that contains the compiler selection code. So for all the ports that are still in the main MacPorts repo, it will look in that _resources folder instead of the one in PPCSnowLeopardPorts, and it will select the (wrong for us) default compilers again.
To fix that, you can edit the compiler selection as above in the main macports portfile repo as well (the folder of interest is here):
/opt/local/var/macports/sources/rsync.macports.org/macports/release/tarballs/ports/_resources/port1.0/compilers
Note, that every time you run "sudo port -v sync" that editing will be erased and the old defaults will be put back. So what I do is this after I run "sudo port -v sync"
Code:
$ sudo mv /opt/local/var/macports/sources/rsync.macports.org/macports/release/tarballs/ports/_resources/port1.0/compilers /opt/local/var/macports/sources/rsync.macports.org/macports/release/tarballs/ports/_resources/port1.0/compilers-moved
$ sudo ln -s /opt/PPCSnowLeopardPorts/_resources/port1.0/compilers /opt/local/var/macports/sources/rsync.macports.org/macports/release/tarballs/ports/_resources/port1.0/compilers
And then the main MacPorts portfile repo will use the newer files we want to use in /opt/PPCSnowLeopardPorts/_resources/port1.0/compilers
Finally, you will note I always keep saying to use
sudo port -v sync
instead of
sudo port -v selfupdate
that is because for the moment we NEVER want to update MacPorts base code (the edit we made to the sandboxing file will be removed and the default would return). If you do accidentally run
sudo port -v selfupdate
no big harm done. Just do the edit to portsandbox.tcl again.
After that, lots of ports will build. There are hiccups and you can expect more, but many of them will be fixable with a look at the portfile that is failing for you. You can usually spot in a few seconds why it might be failing, if it is just configuration thing where the Portfile expects i386. If the issue is the older SDK on PPC SnowLeopard does not match the SDK found in SnowLeopard 10.6.8, well that is harder to fix.
You can view and edit a portfile like this:
bbedit `port file MYPORTFILE`
if you make some some changes to Portfiles in the main macports collection, it's OK. They will disappear every time you run
sudo port -v sync
Don't forget to make the symlink to our new compilers folder after you sync, or the compiler selection will be wrong! See above.
I hope this helps some or most of you get some current ports built. I know a few of you have been eagerly awaiting this information. I wanted to have it as workable as possible before I offered it up. Some of you might find it plainly too confusing, at least for now, and prefer to cob over binaries built on PPC Leopard instead. That is just fine if you want to do that... that is what I originally recommended to people, as it is trivially easy to do.
But I was intrigued by PPC SnowLeopard, and set it up, so I thought I would share how to do this for anyone who is interested.
There will be broken ports. Please don't report them to MacPorts bug tracker or they will think you foolish and me foolisher for telling you how to do this :>