Menu

#313 MySQL-python setup_posix.py strips -R runpath ldflags

open
MySQLdb (285)
5
2012-09-19
2011-06-13
No

Hi,

As an added incentive, I'll commit to donating £50 to the project when this bug gets fixed and pushed out in a release! :-)

This issue affects all versions of MySQL-python.

Basically setup_posix.py doesn't use all the linker flags given by mysql_config when building _mysql.so, and only passes through "-l" and "-L" flags. On platforms where MySQL has been installed in a non-standard location, mysql_config may have been be configured to return a -R flag, for example:

: mysql_config --libs

-L/opt/mysql/5.5/lib -R/opt/mysql/5.5/lib -lmysqlclient -lthread -lsocket -lz -lnsl -lm -lrt

The -R flag tells the linker to encode the given run path in the resulting binary or shared object, so that it can find the libraries in the non-standard location:

dump -Lvp ./build/lib.solaris-2.10-i86pc-2.6/_mysql.so | egrep 'RUNPATH|RPATH'

[12] RUNPATH /opt/mysql/5.5/lib
[13] RPATH /opt/mysql/5.5/lib

Unfortunately since setup_posix.py strips out these -R flags, the resulting _mysql.so object when loaded can't find the MySQL libraries.

It's possible to work around this with an LD_LIBRARY_PATH or by modifying the systems runtime linker search path, however this isn't always desirable or recommended.

I guess the logic behind setup_posix.py filtering the compiler flags given by mysql_config is to strip out optimisation flags/unnecessary flags, but the -R flag should be passed through; not passing this through should definitely be considered a bug, since it will trip up many users who are on otherwise correctly configured systems, but where the MySQL libraries aren't in the standard system library search path.

It's a trivial change to setup_posix.py to pass the flag through, and I can supply a patch if desirable.

Thanks for your continued work on MySQL-python!

Kind Regards,

Alasdair

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.