Just use a stock MSYS2 installation and install the necessary packages to compile MAME. It’s less fuss than trying to use the build tools package at this point. See here: https://docs.mamedev.org/initialsetup/compilingmame.html#using-a-standard-msys2-installation