Compile error on Apple M4 silicon

Hi,
On a MacBook with M4 silicon, I've installed IDE 2.3.4 and I'm having compile issues. Installed rosetta, worked on ctags and other suggestions made in the forum and online, but am stuck with the following error. Your help is much appreciated.

Compiling for Arduino Uno the sketch:

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
}

Error message:

FQBN: arduino:avr:uno
Using board 'uno' from platform in folder: /Users/paulhoekstra/Library/Arduino15/packages/arduino/hardware/avr/1.8.6
Using core 'arduino' from platform in folder: /Users/paulhoekstra/Library/Arduino15/packages/arduino/hardware/avr/1.8.6

Detecting libraries used...
/Users/paulhoekstra/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Users/paulhoekstra/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/Users/paulhoekstra/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/variants/standard /Users/paulhoekstra/Library/Caches/arduino/sketches/B5095DA671140EB8CED4EBDFC0F550B9/sketch/sketch_feb20a.ino.cpp -o /dev/null
Generating function prototypes...
/Users/paulhoekstra/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Users/paulhoekstra/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/Users/paulhoekstra/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/variants/standard /Users/paulhoekstra/Library/Caches/arduino/sketches/B5095DA671140EB8CED4EBDFC0F550B9/sketch/sketch_feb20a.ino.cpp -o /private/var/folders/pl/_r5rrj0n2bbgwj55hpxqk02c0000gn/T/1863722175/sketch_merged.cpp
/Users/paulhoekstra/Library/Arduino15/packages/builtin/tools/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /private/var/folders/pl/_r5rrj0n2bbgwj55hpxqk02c0000gn/T/1863722175/sketch_merged.cpp
/Library/Developer/CommandLineTools/usr/bin/ctags: illegal option -- -
usage: ctags [-BFTaduwvx] [-f tagsfile] file ...
exit status 1

Compilation error: exit status 1

The error seems to be that the ctags version on your system does not accept the options the Arduino IDE uses.

You might need to install Universal Ctags (may be via Homebrew) and adjust your PATH so the IDE uses it instead of the default macOS ctags.

Hi @flying_dutchman.

My guess is that the things you did to try to fix the unspecified original problem you encountered have caused the problem you are experiencing now.

Please provide a detailed description of us exactly what you did regarding ctags.

Did you replace /Users/paulhoekstra/Library/Arduino15/packages/builtin/tools/ctags/5.8-arduino11/ctags with a symlink to /Library/Developer/CommandLineTools/usr/bin/ctags?

Thank you, THANK you - it is resolved!

These are the steps taken:
Solution:

  1. installed brew --prefix universal-ctags
  • unlink: brew unlink ctags
  • brew install universal-ctags
  • which ctags
  • brew --prefix universal-ctags
  1. Create a Symbolic Link to Homebrew's ctags
  • rm -rf ~/Library/Arduino15/packages/builtin/tools/ctags
  • mkdir -p ~/Library/Arduino15/packages/builtin/tools/ctags/5.8-arduino11
    ln -s /opt/homebrew/opt/universal-ctags/bin/ctags ~/Library/Arduino15/packages/builtin/tools/ctags/5.8-arduino11/ctags
  1. New error: Issue: fork/exec ... avr-gcc-ar: no such file or directory, This error indicates that Arduino IDE is missing avr-gcc-ar, which is part of the AVR-GCC toolchain.

  2. Solution: Use an ARM64-Compatible AVR-GCC
    To fix this:

  3. Remove the broken AVR-GCC: rm -rf ~/Library/Arduino15/packages/arduino/tools/avr-gcc

  4. Install an ARM64-compatible AVR-GCC from Homebrew.
    brew tap osx-cross/avr
    brew install avr-gcc

  5. Link the correct version to Arduino IDE.
    which avr-gcc
    mkdir -p ~/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/
    ln -sf /opt/homebrew/bin/avr-g++ ~/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++
    ln -sf /opt/homebrew/bin/avr-gcc ~/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-gcc
    ln -sf /opt/homebrew/bin/avr-ar ~/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-ar
    ln -sf /opt/homebrew/bin/avr-objcopy ~/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy
    ln -sf /opt/homebrew/bin/avr-objdump ~/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-objdump
    ln -sf /opt/homebrew/bin/avr-size ~/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-size
    ln -sf /opt/homebrew/bin/avr-ranlib ~/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-ranlib
    ln -sf /opt/homebrew/bin/avr-gcc-ar ~/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-gcc-ar

Thank you for taking the time to post an update with your findings @flying_dutchman. I'm glad you were able to find a way to get it working.

For the benefit of others who might find this topic while researching for a solution to a problem, I will state that it is not required to install these tools yourself. Arduino IDE automatically installs a dedicated copy of Ctags and avr-gcc. The tools installed by Arduino IDE are the specific variants and versions it is intended to be used with, while the tools you install via brew will have differences, and may have incompatibilities, and even if compatible at the time of the initial installation, incompatibilities might be introduced as Homebrew updates the installations to newer versions over time.

So you should not do this purely as a workaround for some problem you are having with the functionality of Arduino IDE. It will be better to instead find a true fix for that problem.

It is true that the macOS builds of these tools distributed by Arduino are x86 (AKA "Intel") and thus require the Rosetta 2 binary translator to be installed in order to work on Apple Silicon machines, and may have inferior performance when compared to a native Apple Silicon build. The Arduino developers are tracking the task of distributing native Apple Silicon builds of the tools here:

So for an advanced user who is concerned about performance, is aware of the potential pitfalls, and who is capable of resolving any problems that might be caused by that, it might be reasonable to replace the builds distributed by Arduino with manual managed installations of native Apple Silicon builds from an alternative source like Homebrew. Those users might be interested in the information shared here (which is similar to the technique used by @flying_dutchman, but a bit different in that it uses Arduino's own variant of Ctags, built from source to get a native binary):

That’s too bad, diverging from source code of something very "standard" and maintained by the community leads to more workload for your small IDE team .

I’d be curious to understand why this decision was made.

I only know what can be inferred from the limited information in the GitHub repository:

who said an image is worth 1000 words...