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.

Title: customize_compiler broken
Type: Stage:
Components: Distutils Versions: Python 3.1, Python 2.7
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: tarek Nosy List: cdavid, flub, tarek
Priority: critical Keywords: patch

Created on 2009-05-05 09:09 by cdavid, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
bug_5941.diff cdavid, 2009-05-07 11:33
Messages (10)
msg87231 - (view) Author: Cournapeau David (cdavid) Date: 2009-05-05 09:09
The customize_compiler function is broken in python 3.1. The archiver
for a 'standard' unix compiler is set as ['ar', '-cr'], but in python
3.*, customize_compiler overwrites self.archiver from
get_sysconfig_var('AR'), and AR is defined as ar, which breaks

I think the solution is to define a new env variable AR_something or to
set AR to 'ar -rc' (like LDSHARED is set to ['gcc', '-shared'] on gnu
systems, for example).
msg87233 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-05-05 09:14
Hi David, do you have an example that breaks, I can reuse to write the
test ?
msg87234 - (view) Author: Cournapeau David (cdavid) Date: 2009-05-05 09:18
Hi Tarek,

Yes, I have a simple example, which show both 5940 and 5941 bugs:

from distutils.core import setup

# How to install libfoo.a/foo.lib in say pkg_dir/lib ?
setup(name='yo', libraries=[('foo', {'sources': ['foo.c']})])

foo.c can be an empty file.
msg87237 - (view) Author: Cournapeau David (cdavid) Date: 2009-05-05 09:19
Both should be set as serious, in the sense that build_clib is totally
broken ATM, with no simple workaround. OTOH, maybe numpy is the only
user of build_clib, in which case it is not so serious (I use my own
fixed, copied versions of the original code for the time being in numpy
distutils extensions).
msg87313 - (view) Author: Cournapeau David (cdavid) Date: 2009-05-06 07:35
The bug is also present in python 2.7a
msg87319 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-05-06 08:24
what is your traceback ? I want to make sure I have the same in the 
test I built.

Also, just before the traceback, can you tell me the exact command
that is spawned in line 1036.
msg87320 - (view) Author: Cournapeau David (cdavid) Date: 2009-05-06 08:27
You can see the traceback in this recent email:
msg87323 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-05-06 08:42
Ok I am able to reproduce it. We can't change AR in the makefile,
so I think the best way is to add like you said the -cr option
in Python Makefile under a new variable, then use it in customize_compiler

I'll ask on python-dev because I am new to the Makefile.

A turnaround until then is to set AR with the correct option 
in os.environ['AR']
msg87367 - (view) Author: Cournapeau David (cdavid) Date: 2009-05-07 11:33
Ok, here is a patch which fixes the issue while retaining the AR
customization. Here is what it does:

 - configure defines both AR and ARFLAGS in the configure script, and
those are used in the Makefile
 - ARFLAGS is used instead of the harcoded rc (rc is the default value
for ARFLAGS in configure)
 - Both AR and ARFLAGS are used in customize_compiler in distutils. If
any of them is customized from the environment, they are overriden.

Some examples:
 - default: nothing changes, except that archiver is set to ar rc
instead of ar in customize_compiler, thus build_clib is not broken anymore
 - setting AR/ARFLAGS in configure: those are used in the python build
 - ARFLAGS=cru python build_clib will use ar cru instead of ar
cr for libraries.

The only thing I am a bit unsure is that instead of ar -cr, we have ar
cr used as archiver in distutils. Since ac cr is currently used in the
python makefile, I guess most unixes understand ar cr, though.
msg87409 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-05-07 21:30
Fixed in r72445 and r72446

Thanks David !
Date User Action Args
2022-04-11 14:56:48adminsetgithub: 50191
2009-05-07 21:30:20tareksetstatus: open -> closed

messages: + msg87409
versions: - Python 3.0
2009-05-07 11:33:50cdavidsetfiles: + bug_5941.diff
keywords: + patch
messages: + msg87367
2009-05-06 11:30:47flubsetnosy: + flub
2009-05-06 08:42:09tareksetmessages: + msg87323
2009-05-06 08:27:00cdavidsetmessages: + msg87320
2009-05-06 08:24:21tareksetmessages: + msg87319
2009-05-06 07:35:50cdavidsetmessages: + msg87313
versions: + Python 3.0, Python 2.7
2009-05-06 07:34:22tareksetpriority: critical
2009-05-05 09:19:56cdavidsetmessages: + msg87237
2009-05-05 09:18:33cdavidsetmessages: + msg87234
2009-05-05 09:14:47tareksetmessages: + msg87233
2009-05-05 09:09:21cdavidcreate