This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Lib/test/test_distutils.py tries to mix 32 and 64 bits object files, doesn't obey LDFLAGS
Type: compile error Stage: resolved
Components: Tests Versions: Python 3.1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: jcea Nosy List: benjamin.peterson, jcea, python-dev
Priority: normal Keywords: easy, needs review

Created on 2011-03-16 12:22 by jcea, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (5)
msg131106 - (view) Author: Jesús Cea Avión (jcea) * (Python committer) Date: 2011-03-16 12:22
Example of faulting build: http://www.python.org/dev/buildbot/all/builders/AMD64%20OpenIndiana%203.1/builds/297

Problem: "test_distutils.py" tests the generation of shared libraries. It correctly compile the ".c" to ".o" as 64 bits, but when linking the resulting file object, it tries to link in 32 bits mode, failing miserably.

Manually adding:

"""
--- a/Lib/distutils/unixccompiler.py    Wed Mar 16 12:48:54 2011 +0200
+++ b/Lib/distutils/unixccompiler.py    Wed Mar 16 12:14:37 2011 +0000
@@ -251,6 +252,8 @@
                 if sys.platform == 'darwin':
                     linker = _darwin_compiler_fixup(linker, ld_args)
 
+                print("*****************", repr(linker + ld_args))
+                ld_args = ["-m64"]+ld_args
                 self.spawn(linker + ld_args)
             except DistutilsExecError as msg:
                 raise LinkError(msg)

"""

solves the issue.

Notes:

- Python is compiled with this configuration:

  ./configure --with-pydebug --with-computed-gotos "CFLAGS=-I/usr/local/include/ncursesw -m64" LDFLAGS=-m64

- "test_distutils.py" compilation step works OK, and obey CFLAGS. The command line used is "['gcc', '-I/usr/local/include/ncursesw', '-m64', '-g', '-Wall', '-Wstrict-prototypes', '-fPIC', '-IInclude', '-I/tmp/z/3.1', '-c', '/tmp/tmp8M7aOH/xxmodule.c', '-o', '/tmp/tmp8M7aOH/tmp/tmp8M7aOH/xxmodule.o']".

- "test_distutils.py" linking steps fails. The command line used is "'gcc', '-shared', '/tmp/tmp8M7aOH/tmp/tmp8M7aOH/xxmodule.o', '-o', '/tmp/tmp8M7aOH/xx.so'". It doesn't include the "LDFLAGS" parameter we want.

- Modifying the source code to add a "-m64" to the linking step solved the issue.

- Python 2.7, 3.2 and 3.x works ok.
msg131117 - (view) Author: Jesús Cea Avión (jcea) * (Python committer) Date: 2011-03-16 14:13
This patch is hacky, but 3.1 is in maintenance mode.

This patch should be safe. It only touch SunOS compilation. It passes the testsuite, and it should allow 64 bit compilation of extension packages.

This patch is not needed in 3.2 and 3.x. It only affects 3.1.

The patch:

"""
diff -r f2ac5bbc1623 configure.in
--- a/configure.in      Wed Mar 16 12:48:54 2011 +0200
+++ b/configure.in      Wed Mar 16 14:10:53 2011 +0000
@@ -1758,8 +1758,8 @@
        IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
        SunOS/5*) 
                if test "$GCC" = "yes"
-               then LDSHARED='$(CC) -shared'
-               else LDSHARED='$(CC) -G';
+               then LDSHARED='$(CC) -shared $(LDFLAGS)'
+               else LDSHARED='$(CC) -G $(LDFLAGS)';
                fi ;;
        hp*|HP*)
                if test "$GCC" = "yes"
"""

Please, review. If everything is OK, I will commit the patch myself.
msg131149 - (view) Author: Jesús Cea Avión (jcea) * (Python committer) Date: 2011-03-16 17:46
Benjamin, could you possibly accept this for 3.1?. It solves a buildbot issue that cold mask othe problems. It seems pretty trivial and safe.

If you approve, I will commit the patch myself.

Thanks.
msg131154 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2011-03-16 18:16
That should be okay. 3.1 is still open for normal bugfixes.

2011/3/16 Jesús Cea Avión <report@bugs.python.org>:
>
> Jesús Cea Avión <jcea@jcea.es> added the comment:
>
> Benjamin, could you possibly accept this for 3.1?. It solves a buildbot issue that cold mask othe problems. It seems pretty trivial and safe.
>
> If you approve, I will commit the patch myself.
>
> Thanks.
>
> ----------
> assignee:  -> jcea
> nosy: +benjamin.peterson
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue11570>
> _______________________________________
>
msg131161 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-03-16 19:42
New changeset d108a7dff2a0 by Jesus Cea in branch '3.1':
Close Issue 11570: Lib/test/test_distutils.py tries to mix 32 and 64 bits object files, doesn't obey LDFLAGS
http://hg.python.org/cpython/rev/d108a7dff2a0
History
Date User Action Args
2022-04-11 14:57:14adminsetgithub: 55779
2011-03-16 19:42:35python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg131161

resolution: fixed
stage: patch review -> resolved
2011-03-16 18:16:36benjamin.petersonsetmessages: + msg131154
2011-03-16 17:46:32jceasetassignee: jcea

messages: + msg131149
nosy: + benjamin.peterson
2011-03-16 14:13:28jceasetkeywords: + needs review
messages: + msg131117
stage: needs patch -> patch review
2011-03-16 12:22:50jceacreate