Mac – How to run command line software with Rosetta 1

macportspowerpcrosettaterminal

At the request of some PPC users, I'm trying to create a PPC-compatible installer package of some open source software. Naturally, this requires compiling a PPC binary. I have a Leopard Virtual Machine set up on my Intel Mac, but I don't have access to any actual PPC hardware.

MacPorts does not offer any C++11 compilers which can cross-compile PPC binaries on Intel, but I'd thought I'd be able to work around this by running the whole of MacPorts under Rosetta. With Rosetta 2, this would be easy—I'd just set the Terminal app to "Open using Rosetta", and everything the Terminal runs would also use Rosetta. This was a commonly recommended way to run Homebrew on M1 Macs, before Homebrew finally added native Apple Silicon support a few weeks ago.

Unfortunately, Rosetta 1 does not appear to be this intelligent. I can set the Terminal app to "Open using Rosetta," but this causes only the literal Terminal app to use Rosetta. Bash, MacPorts, etc are still running as Intel processes, according to Activity Monitor.

Is there an alternate way to run command line programs—and preferably all of MacPorts—under Rosetta?

Best Answer

Provided you're on a system where Rosetta v1 is available (up to and including Mac OS X 10.6), you can direct the system to execute the ppc segment of a universal binary using the arch command.

/usr/bin/arch -arch ppc /path/to/some/executable

I've found it useful to keep a virtual machine in Parallels Desktop running OS X Server 10.6 with Xcode and other developer tools installed for this scenario, of compiling older software for obsolete PowerPC Mac systems.