I am on an M3 Pro, MacOS 14.2. When I try echo $MACHTYPE
(in a default -zsh
shell) the output is x86_64
, whereas uname -mp
returns arm64 arm
. Zsh docs say that MACHTYPE
should be "the machine type (microprocessor class or machine model), as determined at compile time." Why is my compile time machine type set to x86_64
? I am not running Terminal with Rosetta. Perhaps a more robust question, what is the intended usage of the MACHTYPE
shell parameter on ARM-based MacOS?
1 Answer
I've highlighted the important part in the text you took from the ZSH documentation:
the machine type (microprocessor class or machine model), as determined at compile time.
This means that Apple compiled zsh
on an Intel machine, for both x64 and arm64. It also means that the practical use of MACHTYPE
is rather limited and (if you need to know the architecture at runtime) uname -m
is the more accurate option.
PS: In bash
, MACHTYPE
is defined as "describes the system type on which bash is executing". This explains why in /bin/bash
, I get arm64-apple-darwin23
, in Homebrew bash
it's aarch64-apple-darwin23.0.0
, and in Homebrew zsh
it's arm
. It also means that you need to check the shell used when following examples found online. If you need the MACHTYPE
equivalent of bash
in zsh
, use CPUTYPE
("The machine type (microprocessor class or machine model), as determined at run time.").
-
do
arm64-apple-darwin23
andaarch64-apple-darwin23.0.0.
refer to the same compile time machine type? also (perhaps not really a stackexchange appropriate question), why would Apple compilezsh
on an old architecture? a more comfortable/robust ecosystem for their in-house developers perhaps? i suppose i am particularly confused about the use ofx86_64
in light ofbash
compiling fine onarm64
.– sheaCommented Dec 31, 2023 at 4:47 -
1@shea Xcode cross-compilation works both ways, it doesn’t matter on which hardware Apple runs this. It could also be just a bug in the way
zsh
sets MACHTYPE.– nohillside ♦Commented Dec 31, 2023 at 7:43 -
1@shea You can see from the text quoted from the
bash
manpage, inbash
the variable MACHTYPE is set at execution time. Not at compile time. Commented Dec 31, 2023 at 19:04 -
@MarcWilson that's an intriguing difference! i wonder if
zsh
changed MACHTYPE's behavior in comparison tobash
due to the execution time machine type already being inuname -m
?– sheaCommented Dec 31, 2023 at 19:29 -
2There's no standard for what that variable is supposed to represent, while
uname -m
is specified by POSIX. Commented Dec 31, 2023 at 22:18