I got the same error today on a clean compile, it has happened to very many people, however I'm told we all have faulty pcs.
One suggestion is to not use the -j option, but if that doesn't fix it, go to mess/drivers/genesis.c, mame/includes/megadriv.h, and mame/drivers/megadriv.c and change the reference of DRIVER_INIT(_32x) to x32x. That always works. No idea why though.
If you get a segfault while compiling tms57002, open the file it complains about (tms57002.c), look for the first occurence of "cycles > 0" (without the quotes) (it's a IF statement) and enclose it in ( ) - so it looks like (cycles > 0) .. this always works too, again no idea what difference it could make.