Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

tangentially

macrumors newbie
Original poster
Dec 28, 2007
13
4
I was poking around in Snow Leopard and ran this command:
$ file /bin/bash
/bin/bash: Mach-O universal binary with 2 architectures
/bin/bash (for architecture x86_64): Mach-O 64-bit executable x86_64
/bin/bash (for architecture i386): Mach-O executable i386
I only see Intel binaries (as I expected.) Then I ran this command:

$ file /bin/ps
/bin/ps: setuid Mach-O universal binary with 3 architectures
/bin/ps (for architecture x86_64): Mach-O 64-bit executable x86_64
/bin/ps (for architecture i386): Mach-O executable i386
/bin/ps (for architecture ppc7400): Mach-O executable ppc

And I was surprised to see PPC code still in the binary?

in /bin alone, the following programs contain PPC code:

/bin/[ (for architecture ppc7400): Mach-O executable ppc
/bin/date (for architecture ppc7400): Mach-O executable ppc
/bin/domainname (for architecture ppc7400): Mach-O executable ppc
/bin/echo (for architecture ppc7400): Mach-O executable ppc
/bin/expr (for architecture ppc7400): Mach-O executable ppc
/bin/hostname (for architecture ppc7400): Mach-O executable ppc
/bin/kill (for architecture ppc7400): Mach-O executable ppc
/bin/launchctl (for architecture ppc7400): Mach-O executable ppc
/bin/ps (for architecture ppc7400): Mach-O executable ppc
/bin/pwd (for architecture ppc7400): Mach-O executable ppc
/bin/rcp (for architecture ppc7400): Mach-O executable ppc
/bin/sleep (for architecture ppc7400): Mach-O executable ppc
/bin/stty (for architecture ppc7400): Mach-O executable ppc
/bin/sync (for architecture ppc7400): Mach-O executable ppc
/bin/test (for architecture ppc7400): Mach-O executable ppc
/bin/wait4path (for architecture ppc7400): Mach-O executable ppc
/bin/zsh (for architecture ppc7400): Mach-O executable ppc

Why is that there, given that SL only runs on intel?
 
It will take Apple probably until 10.7 to get rid of all the PPC code. For example, Mac OS 8.1 was the last release to run on the 68k processor, but I believe it took them until Mac OS 8.6 or Mac OS 9 to remove all the 68k code.
 
It is there for Rosetta

Those programs are there to support Rosetta. PPC apps might need to run those other programs, and so there needs to be a PPC code stream ready to be loaded if they are called.

PPC code is in all the system libraries. (Frameworks)

The PPC code will be needed as long as compatibility to PPC apps is supported. Of course, removing it would also drop support for any app developed prior to 10.4.4. But Apple only sells disposable toys these days, so that probably will occur in 10.7.
 
Those programs are there to support Rosetta. PPC apps might need to run those other programs, and so there needs to be a PPC code stream ready to be loaded if they are called.
You can call one program from another of a different architecture without issue. Libraries (as you noted next) are the reason for some PPC code being leftover - though it's not required in binaries, I imagine either the binaries were built with PPC code because they were built alongside libraries that are needed for Rosetta, or they were simply overlooked this time (as others have said) in the transition away from PPC machines. Like the transition to 64-bit, getting rid of legacy PPC code entirely will take some time, particularly if Rosetta continues to exist.
 
You can call one program from another of a different architecture without issue.
Yes, but you're forgetting http://fuse4bsd.creo.hu/localcgi/man-cgi.cgi?execve+2

Libraries (as you noted next) are the reason for some PPC code being leftover - ... getting rid of legacy PPC code entirely will take some time, particularly if Rosetta continues to exist.
No, Rosetta is the only reason PPC code has to hang around. This isn't like System 8, where parts of the OS continued to be implemented in the previous CPU and ran in the emulator.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.