Flac 1.3.1's configure script runs sed on the CFLAGS environment variable, removing -g. However, it doesn't take into account that the -g option can have an argument, so -ggdb becomes a stray gdb in your CFLAGS, causing compilation to fail.
Even worse, something like -fdiagnostics-generate-patch becomes -fdiagnosticsenerate-patch!
In general, configure should not try to mess with the CFLAGS. If the user wants debug info, then they should pass CFLAGS=-g on the configure command line. If they don't want debug info, then they should pass other flags.
Seems to have already been fixed in Git. See:
https://github.com/xiph/flac/blob/master/configure.ac