Scratch that; looks like a manual git build works, but not mesa-9999 in the Gentoo repository. I've tested with minimal cflags too and the problem remains, so I'm not sure what the difference is.