Mac M1: Build GNU Arm toolchain fails!

Asked by Markus Handell


I downloaded the 2021.10 source tarball and tried to build according to the instructions. Unfortunately the build fails as the Mac M1 Monterey compiler can't assemble x86 instructions it seems.

Is there something I can do to make this work? Running the tools via Rosetta is painfully slow...

/bin/sh ../libtool --mode=compile --tag=CC /Users/markus/src/gcc-arm-none-eabi-10.3-2021.10/src/gmp-6.1.0/mpn/m4-ccas --m4="m4" gcc -c -DHAVE_CONFIG_H -I. -I/Users/markus/src/gcc-arm-none-eabi-10.3-2021.10/src/gmp-6.1.0/mpn -I.. -D__GMP_WITHIN_GMP -I/Users/markus/src/gcc-arm-none-eabi-10.3-2021.10/src/gmp-6.1.0 -DOPERATION_`echo cnd_sub_n | sed 's/_$//'` -fexceptions -O2 -pedantic -fomit-frame-pointer -m64 `test -f 'cnd_sub_n.asm' || echo '/Users/markus/src/gcc-arm-none-eabi-10.3-2021.10/src/gmp-6.1.0/mpn/'`cnd_sub_n.asm
/bin/sh ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I/Users/markus/src/gcc-arm-none-eabi-10.3-2021.10/src/gmp-6.1.0/mpn -I.. -D__GMP_WITHIN_GMP -I/Users/markus/src/gcc-arm-none-eabi-10.3-2021.10/src/gmp-6.1.0 -DOPERATION_`echo cnd_swap | sed 's/_$//'` -fexceptions -O2 -pedantic -fomit-frame-pointer -m64 -c -o cnd_swap.lo cnd_swap.c
/bin/sh ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I/Users/markus/src/gcc-arm-none-eabi-10.3-2021.10/src/gmp-6.1.0/mpn -I.. -D__GMP_WITHIN_GMP -I/Users/markus/src/gcc-arm-none-eabi-10.3-2021.10/src/gmp-6.1.0 -DOPERATION_`echo neg | sed 's/_$//'` -fexceptions -O2 -pedantic -fomit-frame-pointer -m64 -c -o neg.lo neg.c
/bin/sh ../libtool --mode=compile --tag=CC /Users/markus/src/gcc-arm-none-eabi-10.3-2021.10/src/gmp-6.1.0/mpn/m4-ccas --m4="m4" gcc -c -DHAVE_CONFIG_H -I. -I/Users/markus/src/gcc-arm-none-eabi-10.3-2021.10/src/gmp-6.1.0/mpn -I.. -D__GMP_WITHIN_GMP -I/Users/markus/src/gcc-arm-none-eabi-10.3-2021.10/src/gmp-6.1.0 -DOPERATION_`echo com | sed 's/_$//'` -fexceptions -O2 -pedantic -fomit-frame-pointer -m64 `test -f 'com.asm' || echo '/Users/markus/src/gcc-arm-none-eabi-10.3-2021.10/src/gmp-6.1.0/mpn/'`com.asm
tmp-add_n.s:86:6: error: unknown token in expression
 mov %ecx, %eax
tmp-add_n.s:86:6: error: invalid operand
 mov %ecx, %eax
tmp-add_n.s:87:10: error: unknown token in expression
 shr $2, %rcx
tmp-add_n.s:87:10: error: invalid operand
 shr $2, %rcx
tmp-add_n.s:88:10: error: unknown token in expression
 and $3, %eax
tmp-add_n.s:88:10: error: invalid operand
 and $3, %eax
tmp-add_n.s:89:9: error: unknown token in expression
 bt $0, %r8

Question information

English Edit question
GNU Arm Embedded Toolchain Edit question
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Mitchell Johnson (ehntoo) said (last edit ):

I ran into this today - you'll need to replace all instances of "x86_64-apple-darwin10" in the,, and files with "aarch64-apple-darwin11". I'm not actually clear on what the "-10" or "-11" means in the target here, but -11 seemed to work fine.

Additionally, you'll need to:
- bump the version of GMP built from 6.1.0 to something newer (I used 6.2.1) by editing the version in
- run "autoreconf -fiv" in the libelf sources directory to fix this issue:
- apply this patch to the GCC sources: to fix this issue
- add "LDFLAGS=-L/opt/homebrew/opt/gettext/lib" to the flags used to compile GDB to use homebrew's gettext and fix gdb with python builds

You may want to update the binutils version included while you're at it - GNU ld 2.37 fixes issues with -g3 debug info, and 2.38 came out recently.

*edit Mar 2, 2022*
Another option I've just discovered - the xPack project has already built the toolchain for Apple Silicon, along with some updated build scripts.

Can you help with this problem?

Provide an answer of your own, or ask Markus Handell for more information if necessary.

To post a message you must log in.