This is actually a useful warning, since -ffunction-sections not only
affects debugging but also adds unnecessary size to executables on
PE-COFF targets (and others where ld does not support --gc-sections).
One way to avoid is to add --enable-cxx-flags='-fno-function-sections
-fno-data-sections' to configure
libstdc++ configure is already probing to see if the target supports the
use of this flag without errors. It thinks AIX and cygwin can use this
flag without errors or warnings, which is clearly wrong.
So, something needs to be fixed.
Can you try
int i;
with "-Werror -ffunction-sections -fdata-sections" and see if you get an
error with g++?
if not, can you try
int i;
void bar() { }
with the same flags and see if you get the error?
best,
benjamin