Eric5h5 said:
All of it. Funny thing is, which I learned from an Anandtech article, is that it's compiled with this switch: -Os. It'd be nice if Apple would make a downloadable distribution compiled with -O3 or better yet -fast, for those of us with G5s and more than 512MB.
--Eric
So, from my (borderline-layman's) point of view, it looks like the key components of OS X working across multiple architectures are:
- Multi-binary executable packaging format (fat binaries)
- A compiler (C++, C, Objective C) for the target architecture
- A ported Mach kernel and BSD-layer + userland toolchain (I'd imagine these would be written in C or C++, since they're so low-level and/or have a history outside of Apple. BSD's famous for its portability, and I believe Mach has existed on a couple of archs already).
- A successful compilation of higher-level, obj-C frameworks on top of the ported kernel and BSD layer on the target arch.
Of course, this is far from the whole story -- a CPU architecture does not a platform make!
From my own limited experience, 'platform independent code' is almost as much to do with coding style as what language is used. NEXTSTEP, Mach and BSD are historically portable, suggesting that they're written in a style that doesn't take the underlying architecture for granted. Perhaps this would ease the implementation of the OS on further architectures?
On another note, I seem to remember reading that OS X's installer does indeed install different kernels and system libraries based on the underlying CPU. For example, you'd expect the math libraries on a G4 and G5 install to have been compiled with Altivec support, yet those on a G3 would not.
There may be other reasons for Apple not using certain optimisation settings. I've seen a Samba compilation on one of my Linux boxes die when using particular combinations of flags, and even had the binaries built by a 'successful' compile act oddly due my tinkering with compiler optimisations.
I'm working on the assumption that Apple's engineers aren't mad enough to ignore a possibly significant speed gain that could be obtained with a minor tweak to the build process

So there's probably some hairy and arcane reason why they do what they do!