Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the '10.6: How much of Snow Leopard isn't yet 64-bit?' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.6: How much of Snow Leopard isn't yet 64-bit?
Authored by: mzso on Sep 19, '09 12:06:05AM
I've spotted one small problem with this: you get only the various architecture counts and not the count of all extensions. Thus you can tell how many extensions have a 64-bit binary, but not how many extensions do not have (which was the point of the original post).

Here's a one-liner that should provide all the info:
file /System/Library/Extensions/*.kext/Contents/MacOS/* | awk 'BEGIN {total=0} /^[^(]*$/ {total++} /([^)]*)/ { start=index($0, "(")+1; $0=substr($0, start, index($0, ")")-start); kexts[$NF]++ } END { print "kexts total: " total; for (kext in kexts) print kext ": " kexts[kext] } '

It provides an output (on a 10.5.x) like this:
kexts total: 220
ppc: 109
i386: 112
ppc7400: 3
The number of extensions without 64 bit arch is: "kexts total" - "x86_64" (and of course the latter is zero in my case since I'm still running 10.5).

[ Reply to This | # ]
10.6: How much of Snow Leopard isn't yet 64-bit?
Authored by: mzso on Sep 19, '09 01:30:21AM
Unfortunately the previous one was still buggy. :-(
For non-universal binaries the file command outputs only a single line like this:
/System/Library/Extensions/AppleEFIRuntime.kext/Contents/MacOS/AppleEFIRuntime: Mach-O object i386
However, in case of a universal binary the "(for architecture ...)" section contains the real thing, since the "Mach-O object ..." section contains only the main architecture class.
/System/Library/Extensions/TMSafetyNet.kext/Contents/MacOS/TMSafetyNet: Mach-O universal binary with 2 architectures
/System/Library/Extensions/TMSafetyNet.kext/Contents/MacOS/TMSafetyNet (for architecture i386): Mach-O object i386
/System/Library/Extensions/TMSafetyNet.kext/Contents/MacOS/TMSafetyNet (for architecture ppc7400): Mach-O object ppc
Taking this into account, here's a (hopefully now) correct one-liner:
file /System/Library/Extensions/*.kext/Contents/MacOS/* | awk '/Mach-O +[^ ]+ +[^ ]+$/ {if (match($0, "\\(for +architecture +")) { arch=substr($0, RSTART + RLENGTH); arch=substr(arch, 1, index(arch, ")")-1) } else { arch=$NF }; archs[arch]++; sub("( \\(for +architecture +[^ )]+\\))?:[^:]+Mach-O +[^ ]+ +[^ ]+$", ""); binaries[$0]=1 } END { total=0; for (bin in binaries) total++; print "total: " total; for (arch in archs) print arch ": " archs[arch] } '
It produces an output like this (on 10.5):
total: 220
ppc: 188
i386: 141
ppc7400: 3
And you can run it on /Applications/*.app/Contents/MacOS/* too and get a result like this:
total: 127
ppc: 6
i386: 123
For the latter I should mention that I've already cleaned up /Applications with Xslimmer and Monolingual.

[ Reply to This | # ]