Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lib/test/test_distutils.py tries to mix 32 and 64 bits object files, doesn't obey LDFLAGS #55779

Closed
jcea opened this issue Mar 16, 2011 · 5 comments
Assignees
Labels
build The build process and cross-build easy tests Tests in the Lib/test dir

Comments

@jcea
Copy link
Member

jcea commented Mar 16, 2011

BPO 11570
Nosy @jcea, @benjaminp

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/jcea'
closed_at = <Date 2011-03-16.19:42:35.092>
created_at = <Date 2011-03-16.12:22:50.353>
labels = ['easy', 'build', 'tests']
title = "Lib/test/test_distutils.py tries to mix 32 and 64 bits object files, doesn't obey LDFLAGS"
updated_at = <Date 2011-03-16.19:42:35.090>
user = 'https://github.com/jcea'

bugs.python.org fields:

activity = <Date 2011-03-16.19:42:35.090>
actor = 'python-dev'
assignee = 'jcea'
closed = True
closed_date = <Date 2011-03-16.19:42:35.092>
closer = 'python-dev'
components = ['Tests']
creation = <Date 2011-03-16.12:22:50.353>
creator = 'jcea'
dependencies = []
files = []
hgrepos = []
issue_num = 11570
keywords = ['easy', 'needs review']
message_count = 5.0
messages = ['131106', '131117', '131149', '131154', '131161']
nosy_count = 3.0
nosy_names = ['jcea', 'benjamin.peterson', 'python-dev']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'compile error'
url = 'https://bugs.python.org/issue11570'
versions = ['Python 3.1']

@jcea
Copy link
Member Author

jcea commented Mar 16, 2011

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.

@jcea jcea added tests Tests in the Lib/test dir easy build The build process and cross-build labels Mar 16, 2011
@jcea
Copy link
Member Author

jcea commented Mar 16, 2011

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.

@jcea
Copy link
Member Author

jcea commented Mar 16, 2011

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.

@jcea jcea self-assigned this Mar 16, 2011
@benjaminp
Copy link
Contributor

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\>


@python-dev
Copy link
Mannequin

python-dev mannequin commented Mar 16, 2011

New changeset d108a7dff2a0 by Jesus Cea in branch '3.1':
Close bpo-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

@python-dev python-dev mannequin closed this as completed Mar 16, 2011
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build The build process and cross-build easy tests Tests in the Lib/test dir
Projects
None yet
Development

No branches or pull requests

2 participants