GCC @VERSION@ for Mac OS X 10.4 Tiger

GCC @GCCV@, the GNU Compiler Collection, built to run on Mac OS X 10.4 on
a PowerPC Mac (G3, G4 and G5), with the tools that a build needs beside
it. Tiger's own compiler is Apple's GCC 4.0.1 of 2005, which knows no C11
and no C++11. This one compiles C up to C17 and most of C23, C++ up to
C++20 and most of C++23, Objective-C and Objective-C++, against the
headers and libraries that Xcode installs. Everything is in one folder:

  /opt/gcc13/bin
      gcc, g++, cc, c++, cpp, gcov: GCC @GCCV@
      as, ld, ar, ranlib, nm, otool, lipo, strip, libtool:
        Apple's cctools 855, with the linker ld64 236.3
      make: GNU make @MAKEV@ (Tiger's own is 3.80)
      cmake, ctest, cpack: CMake @CMAKEV@
      ninja: Ninja @NINJAV@
      pkgconf, pkg-config: pkgconf @PKGCONFV@
  /opt/gcc13/lib
      libstdc++, libgcc_s, libatomic, the GNU Objective-C
        runtime
  /opt/gcc13/libexec, /opt/gcc13/include
      the compilers themselves, the C++ headers
  /opt/gcc13/powerpc-apple-darwin8
      links to as and ld, where the compiler looks for them
  /opt/gcc13/share
      the manual pages, CMake's modules
  /opt/gcc13/share/doc/gcc-tiger
      this Read Me, the licenses, update-shell-profile.sh

It needs Xcode Tools for the system's headers and libraries (/usr/include
and /usr/lib): Xcode 2.5 is the newest for Tiger. The installer stops
with a message if they are not there.

Using it

The installer does not change your PATH. Apple's GCC stays what gcc
means, in Terminal and for Xcode, until you say otherwise:

  /opt/gcc13/bin/gcc -std=c11 -O2 -o hello hello.c
      this compiler, by its full name
  export PATH=/opt/gcc13/bin:$PATH
      for one Terminal window: gcc, g++, cc, make, cmake,
      ninja and pkg-config are now this package's
  sh /opt/gcc13/share/doc/gcc-tiger/update-shell-profile.sh
      the same for every new Terminal window, in your shell
      profile (the old one is kept beside it as .gcc13save)

A configure script or CMake takes the first cc in the PATH, so put the
folder first, or name the compiler: CC=/opt/gcc13/bin/gcc
CXX=/opt/gcc13/bin/g++. man -M /opt/gcc13/share/man gcc shows the
manual.

  g++ -std=c++20 -O2 -o prog prog.cc
  gcc -O2 -o app app.m -framework Cocoa
  cmake -S src -B build -G Ninja && cmake --build build

Programs for other Macs

A C program loads only Tiger's libSystem, and runs on any Mac with 10.4.
A C++ program loads this package's libstdc++ and libgcc_s from
/opt/gcc13/lib, so it runs only where the package is. To make one that
runs anywhere, link the two into it:

  g++ -std=c++17 -O2 -static-libstdc++ -static-libgcc \
      -o prog prog.cc

Code is for every PowerPC, a G3 too, unless you ask: -mcpu=7450
-maltivec for a G4, -mcpu=970 for a G5. 64-bit atomic types need
-latomic on a 32-bit Mac.

On Tiger

  - No link-time optimization (-flto), no OpenMP (-fopenmp) and no
    sanitizers: GCC has none of them for Mac OS X 10.4. No Fortran.
  - PowerPC code only. -arch i386 is ignored, with a warning, and
    there are no 64-bit PowerPC libraries (-m64).
  - -g works: the compiler runs Xcode's own dsymutil, and Xcode's gdb
    reads the result (breakpoints, a backtrace, variables).
  - Apple's own headers compile in C11, C++17 and C++20: Cocoa, Carbon,
    Foundation. Objective-C uses Apple's runtime (libobjc), as it must
    for Cocoa.
  - CMake fetches https addresses (file(DOWNLOAD), FetchContent) with
    OpenSSL @OSSLV@ and the roots in /usr/local/etc/ssl/cert.pem: install
    the Root certificates package from tiger.v2core.com. Without it,
    an https fetch fails with a certificate error.
  - CMake makes Ninja files or Makefiles. Its Xcode generator does not
    work here: it says "Xcode 2.5 not supported".
  - make is GNU make @MAKEV@ in /opt/gcc13/bin only. /usr/bin/make stays
    Tiger's 3.80.

Uninstalling

In Terminal:

  sudo rm -rf /opt/gcc13
  sudo rm -rf "/Library/Receipts/GCC @VERSION@.pkg"

If /opt is then empty, sudo rmdir /opt. If you ran
update-shell-profile.sh, take the "Setting PATH for GCC 13" lines out of
your shell profile.

How it was made

Everything was compiled on Linux for powerpc-apple-darwin8 (any G3 and
up) against the Mac OS X 10.4u SDK, by a cross compiler that is this same
GCC @GCCV@. The compiler is GCC 13.4 with Darwin 8 support
(github.com/Jazzzny/gcc-13-branch-panther) and two Objective-C++ fixes,
with GMP @GMPV@, MPFR @MPFRV@ and MPC @MPCV@ inside. Its libraries are
the ones that the programs of tiger.v2core.com are built with. The
assembler and the linker are Apple's cctools 855 and ld64 236.3 from
darwin-xtools (github.com/iains/darwin-xtools), with fixes for Mac OS X
10.4. Ninja and CMake have small patches for Tiger: it has no
posix_spawn(), and a few other calls of later systems are missing.
CMake is linked with OpenSSL @OSSLV@ and macports-legacy-support
@LEGACYV@. The programs load only Tiger's own libraries. The package
and this disk image were made on Mac OS X 10.4.11 with its own mkbom,
pax and hdiutil.

GCC, GNU make, GMP, MPFR and MPC are under the GNU General Public
License and Lesser General Public License, version 3 or later; GCC's
libraries have the GCC Runtime Library Exception, so a program that you
compile is yours to license. cctools and ld64 are under the Apple Public
Source License 2.0, CMake under the 3-clause BSD license, Ninja under the
Apache License 2.0, OpenSSL under the Apache License 2.0, pkgconf under
the ISC license: see License.txt.
Everything it was built from is in gcc-@VERSION@-tiger-source.tar.gz,
beside this disk image.

Built @DATE@.
