Apple: ARM GCC toolchain (arm-none-eabi-gcc) on Apple Silicon (M1)
ARM GCC toolchain compiler fails cmake "Check for working C compiler" on Apple Silicon (M1)
The ARM GCC toolchain, a version of GCC used for embedded development, does not support the -arch
option that many other compilers support. On Apple M1 chips, CMake automatically appends the -arch
flag to the "Checking for working C/C++ compiler" step of the build process. This causes CMake to be unable to run the compiler on Apple silicon resulting in issues brought up for the ARM GCC toolchain homebrew and for raspberry pi.
The error is as follows:
-- The C compiler identification is GNU 10.3.1
-- The CXX compiler identification is GNU 10.3.1
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - no
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /opt/homebrew/bin/arm-none-eabi-gcc
-- Check for working C compiler: /opt/homebrew/bin/arm-none-eabi-gcc - broken
CMake Error at /.../CMakeTestCCompiler.cmake:69 (message):
The C compiler
"/opt/homebrew/bin/arm-none-eabi-gcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/arthur/CLionProjects/test/cmake-build-debug-msp432/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make -f Makefile cmTC_8747d/fast && /Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_8747d.dir/build.make CMakeFiles/cmTC_8747d.dir/build
Building C object CMakeFiles/cmTC_8747d.dir/testCCompiler.c.o
/opt/homebrew/bin/arm-none-eabi-gcc -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk -o CMakeFiles/cmTC_8747d.dir/testCCompiler.c.o -c /Users/arthur/CLionProjects/test/cmake-build-debug-msp432/CMakeFiles/CMakeTmp/testCCompiler.c
arm-none-eabi-gcc: error: arm64: No such file or directory
arm-none-eabi-gcc: error: unrecognized command-line option '-arch'; did you mean '-march='?
make[1]: *** [CMakeFiles/cmTC_8747d.dir/testCCompiler.c.o] Error 1
make: *** [cmTC_8747d/fast] Error 2
CMake will not be able to correctly generate this project.
This issue occurs with CMake 3.22.1
Edited by Brad King