Bug #41587 Mysql 5.1.30 fails to compile with CXXFLAGS
Submitted: 18 Dec 2008 11:52 Modified: 28 Dec 2008 6:39
Reporter: Abidoon Nadeem Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Compiling Severity:S1 (Critical)
Version:5.1.30 source package OS:Linux (CentOS 5.2)
Assigned to: Kent Boortz CPU Architecture:Any
Tags: Mysql 5.1.30 source compiler error gcc

[18 Dec 2008 11:52] Abidoon Nadeem
Description:
No matter what I do the compile fails. The only way to make this compile is to pass nothing in the CXXFLAGS. As soon as I pass something the compile fails.

My Machine is Quad Core Opteron Dual Processor  with 4GB of RAM running CentOS 5.2.
gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)

yum list | grep gcc
compat-gcc-34.x86_64     3.4.6-4                installed
compat-gcc-34-c++.x86_64 3.4.6-4                installed
compat-gcc-34-g77.x86_64 3.4.6-4                installed
compat-libgcc-296.i386   2.96-138               installed
gcc.x86_64               4.1.2-42.el5           installed
gcc-c++.x86_64           4.1.2-42.el5           installed
gcc-gfortran.x86_64      4.1.2-42.el5           installed
gcc-gnat.x86_64          4.1.2-42.el5           installed
gcc-java.x86_64          4.1.2-42.el5           installed
gcc-objc.x86_64          4.1.2-42.el5           installed
gcc-objc++.x86_64        4.1.2-42.el5           installed
libgcc.i386              4.1.2-42.el5           installed
libgcc.x86_64            4.1.2-42.el5           installed

How to repeat:
export CFLAGS="-O3 -march=opteron -pipe -msse2 -m3dnow -fomit-frame-pointer -mtune=opteron" 
export CXX="gcc" 
CXXFLAGS="-O3 -opteron -felide-constructors -fno-exceptions -fno-rtti"

./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static --disable-dependency-tracking --enable-local-infile --with-plugin-sphinx --with-plugin-heap --with-plugin-myisam --with-plugin-innobase --with-plugin-partition --enable-thread-safe-client --enable-big-tables --with-extra-charsets=complex --with-readline --with-comment='MySQL 5.1.30 Optimized' --without-debug --without-docs --without-man

make

Suggested fix:
only way to fix this is to make CXXFLAGS=""
and this results in a binary which is not properly optimized I guess.
[18 Dec 2008 11:54] Abidoon Nadeem
The error I get is too few arguments to function `gethostbyname_r'
[19 Dec 2008 10:25] Sveta Smirnova
Thank you for the report.

You wrote:

> export CXX="gcc" 

Do you get same error if CXX is g++?
[19 Dec 2008 11:05] Abidoon Nadeem
I am not sure. I did not try I will have to check with g++.
[28 Dec 2008 6:39] Kent Boortz
You don't show the actual error message, but I suspect the problem is that
you give "-opteron" in CXXFLAGS, not "-march=opteron" as in CFLAGS.

If I'm incorrect, please reopen this bug, and include the actual error
message. If it is configure that fails, please attache "config.log", if
the compilation please paste the failing text in the bug report.