M2
M2 copied to clipboard
gcc-9 C++ mangling ABI
We keep having build failures due to gcc-9 mangling (?) some C++ names in a way different from the way clang on Mac OS does. Here is an experiment to do at home that shows the problem: build mpsolve 3.2.1 with both compilers with gmp installed by homebrew, and compare the symbols:
einsteinium$ nm -o build*/src/libmps/formal/formal-monomial.o | grep ' U .*mpq_stru'
build-gcc/src/libmps/formal/formal-monomial.o: U __ZlsRNSt3__113basic_ostreamIcNS_11char_traitsIcEEEEPK12__mpq_struct
build-gcc9/src/libmps/formal/formal-monomial.o: U __ZlsRSoPK12__mpq_struct
einsteinium$ nm -o --demangle build*/src/libmps/formal/formal-monomial.o | grep ' U .*mpq_stru'
build-gcc/src/libmps/formal/formal-monomial.o: U operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, __mpq_struct const*)
build-gcc9/src/libmps/formal/formal-monomial.o: U operator<<(std::ostream&, __mpq_struct const*)
Here is the configure line I used:
../configure CC=gcc-9 CXX=g++-9 CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib
The build with gcc-9 fails this way:
CXXLD libmps.la
Undefined symbols for architecture x86_64:
"operator<<(std::basic_ostream<char, std::char_traits<char> >&, __mpq_struct const*)", referenced from:
mps::formal::operator<<(std::basic_ostream<char, std::char_traits<char> >&, mps::formal::Monomial const&) in formal-monomial.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[4]: *** [Makefile:1150: libmps.la] Error 1
make[4]: Leaving directory '/private/tmp/mpsolve-3.2.1/build-gcc9/src/libmps'
@radoslavraynov