Can you provide the full build logs for the Arduino IDE?
Arduino IDE → File → Preferences → Show verbose Output during compile
And for PlatformIO: CLI →
pio run -t clean && pio run -v -j1 > compile.txt 2>&1
Then upload both logs to https://pastebin.com/ and link them here.
Also provide a screenshot of your Arduino IDE “Tools” menu.