having my Board as mega 2560 everything is fine. All compilers are found and perfectly used. But now i have burned Optiboot onto my mega and selected the optiboot2560 board. Now it searches avr-gcc ...
Arduino can be built with C20/C++20 or C17/C++17 by switching to the latest gcc-arm-none-eabi. Below shows 2 different ways one using arduino-cli and the other using a Makefile included in this repo.