Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUILD: Various macOS build fixes for Tiger/Leopard #3878

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

dwatteau
Copy link
Contributor

@dwatteau dwatteau commented May 14, 2022

ScummVM 2.2.0 was the last official release for Mac PowerPC; it still builds if you set up a C++11 toolchain for it, but you need dynamic plugins now (see PR #3877) because a single binary with all engines is too big for the PowerPC Mach-O linker.

You also need this small set of fixes:

  • don't use the -Os -mlongcall workaround on Mac PPC anymore: the engines are too big for a single Mach-O PowerPC binary, now (ELF has better workarounds for this). I tried some other linker or compiler workarounds, but it wouldn't be enough, or it would cause internal linker errors. So I suggest relying on dynamic plugins for a full build in this particular setup (see PR #3877 for this).
    • Going back to default GCC flags could also mean fewer GCC bugs on this old platform with its old toolchain.
  • don't run codesign when targeting Leopard or Tiger: Tiger didn't have it at all, and Leopard didn't have the --deep flag. The OS didn't really care for that yet, anyway.
  • work around limited sed -i'' before macOS 10.9: it's just impossible to have a sed -i'' syntax that will be accepted by older BSD sed, newer BSD sed, and GNU sed (source). So here, always use a suffix, and delete the backup files afterward (otherwise, the bundle will embed some strange -e files).
    • (There are other calls to sed -i'' but the Tiger/Leopard build doesn't hit them.)
  • reject GNU Make 3.80 and older: that's the default version on macOS Tiger, but it's very old and it has some bugs and parsing issues, so it shouldn't be used.
    • It's easy to have at least GNU Make 3.81 everywhere, and we know that 3.81 is OK because that's what Apple still ships on modern macOS (because of GPLv3).
    • Parsing $(MAKE_VERSION) is quite inconvenient and not very reliable, so it's usually easier to look for a feature which appeared in the minimum version you require (here, the .FEATURES variable). Putting this at the top of the main Makefile will also "help" BSD make fail early on (since we require GNU Make but don't use GNUmakefile).
  • remove old hacks for CoreAudio on macOS 10.2 and 10.3. I'm pretty sure the rest of the macOS code didn't compile on macOS 10.2/10.3 for a long time, and there's no C++11 toolchain before macOS 10.4 anyway.

Tested on macos Tiger, Leopard and Monterey.

dwatteau added 4 commits May 6, 2022
codesign didn't exist on Tiger, and didn't have a --deep option on
Leopard.

Moreover, it was rarely used on these older systems, and previous
releases of ScummVM on Mac PowerPC weren't signed either.
On older macOS releases, this would leave `-e` suffixed files, and
there is no easy way to have a portable sed -i'' syntax.

Just force a creating a suffixed backup and immediately delete it.
…ugins

-mlongcall -Os would work until ScummVM 2.2.0, but now the engines are
too big to fit in a single static binary on Mac PowerPC.

(On ELF platforms, some flags like -Wl,--relax or -Wl,--gc-sections
can be used as well, but macOS uses Mach-O, and its old linker doesn't
have as many workarounds.  -Wl,-dead_strip helped a bit but that's not
enough and you start hitting ld internal errors.)

So, recommend dynamic plugins on Mac PPC, now, and drop -Os -mlongcall
since working around the linker limits is not possible anymore.  Using
compiler defaults probably means less bugs when using such an obscure
toolchain, anyway.

(Making a static release it still possible, but only with a very small
set of engines.)
GNU Make 3.80 is the default version on macOS Tiger, and it shouldn't be
used because it has various parsing problems and bugs.

The .FEATURES variable was added in GNU Make 3.81, and that's the
easiest and most reliable way of detecting this version.

We know that GNU Make 3.81 is OK since that's still what Apple ships
by default on modern macOS (because of GPLv3).
@raziel-
Copy link
Contributor

@raziel- raziel- commented May 14, 2022

Nice to have another PPC platform targeted, maybe we can help out with BE bugs in the future?

@dwatteau
Copy link
Contributor Author

@dwatteau dwatteau commented May 14, 2022

Nice to have another PPC platform targeted, maybe we can help out with BE bugs in the future?

Thanks, yeah there's still a retro PPC audience, so if you take all Mac PPC + PS3 + Wii + AmigaOS users you get a higher chance of finding and fixing some bugs here and there. My old PowerBook was helpful in fixing big-endian bugs in Duckman, Full Pipe, Galador, Blazing Dragons… and I think your AmigaOS work helped Grim Fandango work out of the box there :)

@raziel-
Copy link
Contributor

@raziel- raziel- commented May 14, 2022

Yep :-)

Just you don't go anywhere ;-)

@bonki
Copy link
Member

@bonki bonki commented May 15, 2022

I have an old PPC iMac G4 lying around in the attic which I have been meaning to resurrect for ScummVM for years now. Maybe it's time to do some spring cleaning after all :-)

@dwatteau
Copy link
Contributor Author

@dwatteau dwatteau commented May 15, 2022

I have an old PPC iMac G4 lying around in the attic which I have been meaning to resurrect for ScummVM for years now. Maybe it's time to do some spring cleaning after all :-)

Ha, thanks ;) I've put a 2.6.0git build (with default engines) here, if you're interested:
https://github.com/dwatteau/scummvm/releases

I need to submit something for the toolchain, too…

There's still code for macOS 10.4 in the codebase, but everything before
that has probably been KO for years.  And no C++11 toolchain exists for
macOS < 10.4 either.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants