Mac M1: Build GNU Arm toolchain fails!

Asked by Markus Handell

Hello,

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

Language:
English Edit question
Status:
Answered
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Mitchell Johnson (ehntoo) said (last edit ):
#1

I ran into this today - you'll need to replace all instances of "x86_64-apple-darwin10" in the build-toolchain.sh, build-common.sh, and build-prerequisites.sh 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 build-common.sh
- run "autoreconf -fiv" in the libelf sources directory to fix this issue: https://github.com/conan-io/conan-center-index/issues/2795
- apply this patch to the GCC sources: https://github.com/riscv-software-src/homebrew-riscv/commit/f54a2bc1e66d182a00521d519446854f2eee27e8 to fix this issue https://github.com/riscv-software-src/homebrew-riscv/issues/47
- 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. https://sourceware.org/bugzilla/show_bug.cgi?id=27754

*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. https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/tag/v10.3.1-2.3

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.