3

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 1

7

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.").

5
  • do arm64-apple-darwin23 and aarch64-apple-darwin23.0.0. refer to the same compile time machine type? also (perhaps not really a stackexchange appropriate question), why would Apple compile zsh on an old architecture? a more comfortable/robust ecosystem for their in-house developers perhaps? i suppose i am particularly confused about the use of x86_64 in light of bash compiling fine on arm64.
    – shea
    Commented 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, in bash 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 to bash due to the execution time machine type already being in uname -m?
    – shea
    Commented Dec 31, 2023 at 19:29
  • 2
    There'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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .