Thursday, January 14, 2010 at 1:23 pm
Python: Building MySQL-python 1.2.3c1 on Solaris 10 with MySQL 5.1.42
Trying to build MySQL-python from source on Solaris 10 when using MySQL 5.1.42 (pkg from mysql.com) may fail with something like this:
gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,3,'gamma',1) -D__version__=1.2.3c1 -I/opt/mysql/mysql/include -I/opt/alcatel/logger/include/python2.6 -c _mysql.c -o build/temp.solaris-2.10-sun4u-2.6/_mysql.o -g -mt -m32 -xarch=sparc -DHAVE_RWLOCK_T -DUNIV_SOLARIS -DUNIV_SOLARIS gcc: warning: `-x arch=sparc' after last input file has no effect cc1: error: invalid option `t' error: command 'gcc' failed with exit status 1
It happened to me on a Sun Fire V240 (sparc), but may also happen on i386.
The problem here is the “-mt” option. As mentioned in this forum post the “-mt” option is targeted at IA-64 platforms. This option is used because it is also used in MySQLs “–cflags” and setup.py uses mysql_config to determine build options. If you run mysql_config you probably get something like this:
# /opt/mysql/mysql/bin/mysql_config --cflags -I/opt/mysql/mysql/include -g -mt -m32 -xarch=sparc -DHAVE_RWLOCK_T -DUNIV_SOLARIS -DUNIV_SOLARIS
To overcome this I added “m” to the compiler options to ignore in setup_posix.py in line 55:
removable_compile_args = [ compiler_flag(f) for f in "ILlm" ]
This makes it not use the “-mt -m32″ options from mysql_config. The “-m32″ option makes gcc generate code for 32-bit systems and regarding the “-x arch=sparc”: gcc ignores it anyway:
gcc: warning: `-x arch=sparc' after last input file has no effect
Furthermore there is a bug in the setup.py that seems to link dynamically even if you configure it to link statically in site.cfg. There is a patch attached to this ticket.

