Title: Solaris extension building does not work with 64 bit python
Type: compile error Stage:
Components: Distutils, Distutils2, Extension Modules Versions: Python 3.1, Python 3.2, Python 2.7, 3rd party
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: tarek Nosy List: eric.araujo, pitrou, redcomet, tarek
Priority: normal Keywords:

Created on 2010-07-06 15:17 by redcomet, last changed 2011-03-28 16:12 by pitrou. This issue is now closed.

Messages (8)
msg109396 - (view) Author: Charles Solar (redcomet) Date: 2010-07-06 15:17
On solaris, if you build a 64 bit python and use it to build an extension, it will not properly link the module.

Apparently solaris requires the -m64 flag in the linker as well as the compile steps.  Python distutils successfully compiles all the object files using -m64, but it fails to link with -m64 causing the entire build to fail if the extension needs a 64 bit library dependency ( will get 'incompatible library' errors from the linker ).

To reproduce:
build python with CFLAGS="-m64 -O3" LDFLAGS="-m64"
build a C extension that depends on a 64 bit library (python install)

I assume that it would work if the C extension does not need a specific 64 bit library as the linker will not go and look for the wrong version of file.  So its a very uncommon but annoying bug.

> ld --version
GNU ld (GNU Binutils)
Copyright 2009 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
msg116255 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-09-12 23:56
Thank you for the report.  Do you want to work on a patch?  The usual process is that someone makes a patch for the active version (branch named py3k, the future 3.2), then the committer backports to stable versions (3.1 and 2.7) and forward-ports to distutils2.  See also guidelines at
msg116306 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-09-13 14:05
Can you try using CC="cc -m64" OPT="-O3" instead?
(replace "cc" with the proper compiler name, of course)
msg116310 - (view) Author: Charles Solar (redcomet) Date: 2010-09-13 14:46
I just recompiled using your suggested flags and it is now properly linking my extensions.  I guess using CFLAGS and LDFLAGS was causing the problem.
Is specifying CC the recommended way to build 64 bit python?  If so when I guess this issue is not really an issue at all.
msg116311 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-09-13 14:57
> Is specifying CC the recommended way to build 64 bit python?

Currently, yes. LDFLAGS is supposed to work, but it doesn't (open bug: #9437).
msg131597 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-03-21 01:20
Charles, can you still reproduce your bug now that #9437 has been fixed?
msg132403 - (view) Author: Charles Solar (redcomet) Date: 2011-03-28 16:11
Hello again, I got a copy of the latest python from the 2.7 branch, recompiled with CFLAGS="-m64 -O3" and LDFLAGS="-m64" and my extension compiled just fine.
So I can verify this bug fixed
msg132404 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-03-28 16:12
Thanks for checking. Closing as fixed.
Date User Action Args
2011-03-28 16:12:11pitrousetstatus: open -> closed
resolution: fixed
messages: + msg132404
2011-03-28 16:11:26redcometsetmessages: + msg132403
2011-03-21 01:20:03eric.araujosetnosy: pitrou, tarek, eric.araujo, redcomet
messages: + msg131597
2010-09-29 23:44:02eric.araujosetversions: + 3rd party
2010-09-13 14:57:09pitrousetmessages: + msg116311
2010-09-13 14:46:49redcometsetmessages: + msg116310
2010-09-13 14:05:19pitrousetnosy: + pitrou
messages: + msg116306
2010-09-12 23:56:08eric.araujosetnosy: + eric.araujo

messages: + msg116255
versions: + Python 3.1, Python 3.2
2010-07-06 15:17:11redcometcreate