MinGW build failure for GDB 8.2.90 with source-highlight

Eli Zaretskii
2019-03-07T14:36:03Z

I've rebuilt the 8.2.90 pretest today on MinGW with source-highlight,
and the link step failed with this error message:

CXXLD gdb.exe
d:/usr/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: source-cache.o: in function `ZNSt13basic_filebufIcSt11char_traitsIcEED4Ev':
d:/usr/lib/gcc/mingw32/6.3.0/include/c++/fstream:239: undefined reference to `std::basic_filebuf<char, std::char_traits<char> >::rpl_close()'
d:/usr/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: source-cache.o: in function `ZNSt14basic_ifstreamIcSt11char_traitsIcEE8rpl_openEPKcSt13_Ios_Openmode':
d:/usr/lib/gcc/mingw32/6.3.0/include/c++/fstream:597: undefined reference to `std::basic_filebuf<char, std::char_traits<char> >::rpl_open(char const*, std::_Ios_Openmode)'
d:/usr/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: source-cache.o: in function `ZNSt13basic_filebufIcSt11char_traitsIcEED4Ev':
d:/usr/lib/gcc/mingw32/6.3.0/include/c++/fstream:239: undefined reference to `std::basic_filebuf<char, std::char_traits<char> >::rpl_close()'
collect2.exe: error: ld returned 1 exit status
Makefile:1888: recipe for target `gdb.exe' failed
make[2]: *** [gdb.exe] Error 1
make[2]: Leaving directory `/d/usr/eli/utils/gdb-8.2.90/gdb'
Makefile:8831: recipe for target `all-gdb' failed
make[1]: *** [all-gdb] Error 2
make[1]: Leaving directory `/d/usr/eli/utils/gdb-8.2.90'
Makefile:856: recipe for target `all' failed
make: *** [all] Error 2

The rpl_open and rpl_close thingies come from Gnulib: in the MinGW
build it replaces 'open' and 'close' with its versions by using
#define. Then when we include <fstream> in source-cache.c, the C++
compiler barfs.

Is this a Gnulib bug that I should report to its developers, or is
this our problem? Perhaps we should simply #undef these two symbols
before including <fstream>?