Bug #16520 solaris package does not include shared/relocatable libraries
Submitted: 15 Jan 2006 20:05 Modified: 27 Apr 2007 3:55
Reporter: james ozone Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: Packaging Severity:S1 (Critical)
Version:5.0.18 OS:Solaris (solaris 9/sparc64)
Assigned to: Kent Boortz CPU Architecture:Any

[15 Jan 2006 20:05] james ozone
some packages (notably, php 5.1.1 and newer) will not compile because the linker is unable to resolve dependencies. this issue does not surface with the mysql binary distribution for linux -- that distribution either includes relocatable static libraries, or the linker on that platform is "smart enough" to untangle the difficulty.

xref http://bugs.php.net/36020

How to repeat:
0. build solaris 9 system with gnu toolchain
1. install mysql 5.0.18 with pkgadd
2. unpack php-5.1.2 sources
3. configure php as desired
4. type make
5. (optional) if hardware runs at < 1ghz, go get a cup of coffee
6. php build fails during final linkage, with

ld: fatal: relocations remain against allocatable but non-writable sections

after numerous references of the form

Text relocation remains                         referenced
    against symbol                  offset      in file
strlen                              0x3354      /opt/mysql/mysql/lib/libmysqlclient.a(client.o)
strlen                              0xcc        /opt/mysql/mysql/lib/libmysqlclient.a(default.o)
strlen                              0x120       /opt/mysql/mysql/lib/libmysqlclient.a(default.o)
strlen                              0x358       /opt/mysql/mysql/lib/libmysqlclient.a(default.o)

Suggested fix:
if mysql.com is unable/unwilling to provide shared libraries with the solaris distribution, at least mention in a FAQ or README that this problem is currently best solved by building mysql from source.
[17 Jan 2006 13:49] Valeriy Kravchuk
Thank you for a problem report. Verified just as described. It is a known issue, in the TODO list of our build team already. But, please, do not expect fast fix.
[19 Jan 2006 23:44] Bill Adams
I would like to report the same issue.  To deploy PHP 5.1.2 Apache 2 module on Solaris 9, I need to compile 32-bit shared libraries.
[6 Feb 2006 15:56] [ name withheld ]
I have the same problem with Solaris 10, have you an idea when you could fix it (for a new version 4.1.17 or later) ?

[9 Feb 2006 10:36] [ name withheld ]
For information, the problem remains with Solaris 10/PHP 5.1.2 and the brand new MySQL 4.1.18...
[22 Feb 2006 9:03] Michael O'Rourke
The problem is not shared vs. static libraries. It is the relocatable part. Taking a hint from the rpath.README in GNU's gettext (0.14.5; autoconf-lib-link/tests), which says:
"* Solaris: the tests
    rpath-3bae rpath-3bbe
    rpath-3aaf rpath-3abf
    rpath-3baf rpath-3bbf
  fail, because code from static libraries not compiled with -fPIC cannot
  be integrated into shared libraries: linker error "Text relocation remains"."
I tried this with mysql-5.0.18 and PHP-5.1.2.

I used the following environment:
export CC=/opt/sfw/gcc-3/bin/gcc
export CXX=/opt/sfw/gcc-3/bin/g++
export CFLAGS="-O3 -mcpu=v8 -Wa,-xarch=v8plusa -I/opt/sfw/gcc-3/include -I
/usr/sfw/include -I/opt/sfw/include -I/usr/local/include -I/usr/local/ssl/include"
export CPPFLAGS="-O3 -mcpu=v8 -Wa,-xarch=v8plusa -I/opt/sfw/gcc-3/include
-I/usr/sfw/include -I/opt/sfw/include -I/usr/local/include -I/usr/local/ssl/include"
export CXXFLAGS="-O3 -mcpu=v8 -Wa,-xarch=v8plusa -felide-constructors -fno-exceptions -fno-rtti -I/opt/sfw/gcc-3/include -I/usr/sfw/include -I/opt/sfw/include -I/usr/local/include -I/usr/local/ssl/include"
export LDFLAGS="-L/opt/sfw/gcc-3/lib -L/usr/sfw/lib -L/opt/sfw/lib -L/usr/local/
lib -L/usr/local/ssl/lib -R/opt/sfw/gcc-3/lib:/usr/sfw/lib:/opt/sfw/lib:/usr/local/lib:/usr/local/ssl/lib -lsocket -lnsl -lrt -lresolv -lcrypt -lssl -lcrypto"
export LIBS="-R/opt/sfw/gcc-3/lib:/usr/sfw/lib:/opt/sfw/lib:/usr/local/lib:/usr/
local/ssl/lib -lsocket -lnsl -lrt -lresolv -lcrypt -lssl -lcrypto"

./configure --prefix=/usr/local/mysql \
  --enable-thread-safe-client --enable-assembler \
  --enable-shared=no --enable-static=yes \
  --with-charset=utf8 --with-extra-charsets=all --with-mysqld-user=mysql \
  --with-zlib-dir=/usr/local --without-debug --with-embedded-server \
  --with-embedded-privilege-control --with-openssl=/usr/local/ssl \
  --with-openssl-includes=/usr/local/ssl/include \

When I build MySQL with this environment and configure command, PHP-5.1.2 will not link its shared library with the regular error. When I explicitely add "-fPIC" to the CFLAGS, CPPFLAGS, CXXFLAGS and LDFLAGS variables and re-compile MySQL, it properly builds, passes all tests and installs and runs fine. PHP then compiles but fails its "crypt" test (as well as a few others, but I am working on those!).

I am not sure why the configure script chooses not to use -fPIC on solaris. Perhaps there is some other problem down the line that will surface.

What is the possibility of compiling the binary distributions for solaris with only static libraries, but using -fPIC?

My current problem is with the crypt functions in MySQL and PHP. If I do not include "-lcrypt" in the LIBS variable, MySQL fails the "func_crypt" test; but when I do include it, PHP fails its crypt test (PHP compiled without MySQL passes the crypt test fine.). MySQL does not seem to pay any attention to the presence of libmcrypt for the use of its crypt functions either.
[22 Feb 2006 12:21] Kent Boortz
On some platforms position independent binaries are running slower.
Now for the client library performance is not critical, and we will most likely
changing the builds to create position independent static client libraries.
[11 May 2006 13:50] [ name withheld ]
Is there something new about this bug ?
For the moment, I use PHP 5.0.5 (with MySQL 4.1.19 binaries for Solaris 9) and i can't upgrade PHP in 5.1 version...
Should I recompile MySQL or wait for resolution of the bug ?
[19 May 2006 19:30] Ionut AIVANESEI

I also have problems with solaris binaries (tar.gz SPARC 32 bit).
When compiling PHP 5.x.x on Solaris 8/9/10 I have the folowing errors when running ild:

ild: (error) __1cFmySTLHdestroy4Cpn0AEpair4CiCpF_pnFyaSSLHMessage____6FTA8_v_ is defined in files [...]/mysql/lib/libmysqlclient.a(yassl_imp.o) and [...]/mysql/lib/libmysqlclient.a(yassl_int.o)
ild: (error) __1cFmySTLHdestroy4Cpn0AEpair4CiCpF_pnFyaSSLNHandShakeBase____6FTA8_v_ is defined in files [...]/mysql/lib/libmysqlclient.a(yassl_imp.o) and [...]/mysql/lib/libmysqlclient.a(yassl_int.o)


ild: (error) __1cITaoCryptEHASH2T6M_v_ is defined in files [...]/mysql/lib/libmysqlclient.a(libtaocrypt_la-asn.o) and [...]/mysql/lib/libmysqlclient.a(libtaocrypt_la-ripemd.o)
ild: (error) __1cITaoCryptMvirtual_base2k6Fpv_v_ is defined in files [...]/mysql/lib/libmysqlclient.a(libtaocrypt_la-asn.o) and [...]/mysql/lib/libmysqlclient.a(libtaocrypt_la-ripemd.o)
ild: exiting because of errors in link

I would like to try to build php with shared mysql libraries, but i dont find any so file in mysql/lib.

[24 Jul 2006 16:15] Robert Thomas
You guys need to add "-mimpure-text -lrt" to the extra libraries line in the Makefile.

EXTRA_LIBS = (bla bla bla)... -mimpure-text -lrt

BTW you have to use a real editor like Emacs to edit the Makefile.  VI can't deal with it.  Before you flame me, try it and find out I'm right. At least every time I try to use VI on this file it can't handle it.
[28 Jul 2006 9:02] [ name withheld ]
Thank you Robert, I've tried your solution (with VIM as Makefile editor...) but now I've this error :

Undefined                       first referenced
 symbol                             in file
libiconv_close                      ext/gd/libgd/.libs/gdkanji.o
libiconv_open                       ext/gd/libgd/.libs/gdkanji.o
libiconv                            ext/gd/libgd/.libs/gdkanji.o
ld: fatal: Symbol referencing errors. No output written to sapi/cli/php
collect2: ld returned 1 exit status

Any solution ?

[27 Sep 2006 22:01] Randal Columb
I installed the MySQL 5.0.24a and MySQLdb 1.2.1_p2 packages on my Solaris 10 SPARC server.  When I tried to use MySQLdb it complained that libmysqlclient_r.so.12 was missing.  I searched the whole system for it and couldn't find it.  I ended up copying it from an identical machine that I had installed MySQL 5.0.22 on.  It works for me now, but it would be nice to have libmysqlclient_r.so.12 in the 5.0.24a package.
[27 Apr 2007 3:55] Paul Dubois
Noted in 5.0.40 changelog.

Binary distributions for Solaris and Mac OS X 
did not include shared libraries.
[9 Jan 2009 9:34] Maurizio Broglia
I've still this problem....Has the bug been resolved or have I to install a previous version of php ?

(ps: I'm using php 5.2.8, Solaris SPARC 10 and mysql  Ver 12.22 Distrib 4.0.24, for sun-solaris2.10 (sparc)
[9 Jan 2009 17:24] Valeriy Kravchuk
The bug was reported on 5.0.18 and fixed in 5.0.40 and newer versions. 

It will NOT be fixed in 4.0.x anyway, as even extended support for 4.0.x ended already (see http://www.mysql.com/about/legal/lifecycle/). Sorry.