Bug #59858 WITH_MYSQLD_LDFLAGS="-all-static" still generates shared
Submitted: 31 Jan 2011 23:52 Modified: 17 Jun 2013 17:55
Reporter: Sean Jenkins Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.5.8, 5.5.10, 5.5.19 OS:Linux
Assigned to: Tor Didriksen CPU Architecture:Any
Tags: regression

[31 Jan 2011 23:52] Sean Jenkins
Description:
Building MySQL 5.5.8 with -DWITH_MYSQLD_LDFLAGS="-all-static" still generates a shared binary, whereas in previous versions of MySQL (ie, 5.1.x), something like:

            --with-mysqld-ldflags='-all-static' \
            --with-client-ldflags='-all-static' \

generated a truly static binary.  I'm not sure if this is an issue with cmake not inheriting variables properly, but modifying the mysql-5.5.8/sql/CMakeLists.txt file to force the WITH_MYSQLD_LDFLAGS to "-all-static", doesn't have any impact.

How to repeat:
Build MySQL 5.5.8 with -DWITH_MYSQLD_LDFLAGS='-all-static' and perform an ldd on the resultant mysqld binary.  It should be 0, but in my case is always 23+ shared libraries linked in.

Suggested fix:
If the problem is in fact cmake, have it properly inherit the values for WITH_MYSQLD_LDFLAGS.  Additionally, add similar functionality for WITH_CLIENT_LDFLAGS
[1 Feb 2011 0:07] Sean Jenkins
Little info about the build environment:

CentOS release 5.5 (Final)

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 20080704 (Red Hat 4.1.2-48)

uname -r
2.6.28-10.40.intel.IGB.BHsmp
[1 Feb 2011 10:18] Valeriy Kravchuk
Verified just as described with current mysql-5.5 tree on 32-bit Ubuntu 10.04.
[11 Feb 2011 2:57] Gustavo Baratto
I'm seeing the same behavior here.
I also tried with this, and it didn't work:

-DWITH_MYSQLD_LDFLAGS="-all-static --disable-shared"
[21 Sep 2011 3:13] Sean Jenkins
Even on CentOS 5.7 with MySQL 5.5.16, I'm still seeing this issue.  Any chance that we're going to see a patch for this anytime soon?
[29 Dec 2011 19:53] Denis TRUFFAUT
Did you try -DDISABLE_SHARED=1 ?
[29 Dec 2011 22:28] Sean Jenkins
I hadn't, but I just tried that on 5.5.19 and got the same results as before.  This is even after moving my test server from CentOS 5.7 to CentOS 6.2, same results on both OS'.
[29 Dec 2011 22:29] Sean Jenkins
Applies to 5.5.19 as well
[21 Jun 2012 5:44] Sean Jenkins
Still applies to latest version.  Any chance of getting this fixed as its a show-stopper for our company to even remotely consider using 5.5 until this is fixed
[17 Jun 2013 11:13] Tor Didriksen
We no longer build statically, but as far as I can tell, it still works.
Please use cmake, rather than configure.
http://dev.mysql.com/doc/internals/en/cmake-howto-long-version.html#configure-emulation

I just tested Mysql 5.5, 5.6 and trunk, on
Fedora release 17 (Beefy Miracle)

cmake -DDISABLE_SHARED=1

I did a quick mtr run as well, only a handful of plugin tests failed,
but that's to be expected when there are no plugins.
[17 Jun 2013 17:55] Sean Jenkins
I've been using CMAKE, not configure, as was originally stated.  Was just drawing a comparison.  However, I'm testing this with '-DDISABLE_SHARED=1' in the mysql spec file now on MySQL 5.5.32 and 5.6.12 to see if it'll reduce the # of shared objects, even if it doesn't generate a 100% static build.

Thanks for this btw.