One of the compilation commands is missing an essential flag that tells the compiler that you are compiling for the ATmega32U4 microcontroller.
Please try this:
- Select Tools > Board > Boards Manager from the Arduino IDE's menus.
- Wait for the updates to finish.
- Scroll down through the list of boards platforms until you see "Arduino AVR Boards by Arduino" Click on it.
- Click the Remove button.
- A confirmation dialog will now open. Click the Yes button.
- Wait for the removal to finish.
- Click the Close button.
Now try compiling the sketch again.
The instructions above will cause the IDE to use the version of the "Arduino AVR Boards" platform that comes bundled with the Arduino IDE installation rather than the previous installation you had installed via Boards Manager. My thought is that it's possible the Boards Manager installation has been modified.