Reputation: 4232
When using Rosetta on macOS running on an ARM processor, the arch
command can be used to force a wrapped command to execute as a specific architecture. In other words, arch -arch x86_64 mycommand
will try to launch mycommand
as an x86/Intel program. If mycommand
is ARM-only, it will fail; if mycommand
is a universal binary, it will be run as x86.
But how does the arch -arch ...
command actually work? Specifically, I have these questions:
arch -arch $arch $program
select a $arch
from a universal binary $program
and run it?arch -arch $arch $program
try to run a non-universal binary $program
as the selected architecture $arch
, causing a failure if the binary doesn't support it?arch
does here, without shelling out to arch
? Even if it's possible-but-not-recommended/a private macOS API, I'm still interested in how it happens.I'm asking this out of curiosity, not because I need to get around what arch
does.
I've tried:
lipo
while making universal binaries. lipo
seems to be concatenating binaries for different architectures together in a Mach-O "fat binary" container with some magic bits at the top to indicate what contents are where. This helps a little bit with the first question above, but doesn't help with the second or third.Upvotes: 2
Views: 384