[issue8027] distutils fail to determine c++ linker with unixcompiler if using ccache

Joshua J Cogliati report at bugs.python.org
Mon Feb 23 19:09:18 CET 2015


Joshua J Cogliati added the comment:

I can confirm this bug on Python 2.7.8 and Python 3.4.1, and given that the code is still in later versions, I expect that it will fail in them as well.

>From Python-3.4.2/Lib/distutils/unixcompiler.py, lines 179-189:
# skip over environment variable settings if /usr/bin/env
# is used to set up the linker's environment.
# This is needed on OSX. Note: this assumes that the
# normal and C++ compiler have the same environment
# settings.
i = 0
if os.path.basename(linker[0]) == "env":
    i = 1
    while '=' in linker[i]:
        i += 1
linker[i] = self.compiler_cxx[i]

First of all, as has been noted, this will fail if len(self.compiler_cxx) > 1.  

Second of all, I do not understand how this code was supposed to work correctly in the first place.  If env is in linker[0], then variable i will be greater than 0, so why are we then using self.compiler_cxx[i]?

As I understand the code, I should be able to do something like:
export CXX="env BAR=FOO g++"
and then have env work.  However, when I tried this, my python setup.py build failed.

However, if I do something like:
if target_lang == "c++" and self.compiler_cxx and False:
to the line in unixcompiler.py, then I can do:
export CXX="env BAR=FOO g++"
in the shell and have it compile.  I don't know if it would work if I actually needed BAR=FOO, but so far as I can tell this code is broken, and has been for a while, and therefore should be flat out removed.

----------
nosy: +Joshua.J.Cogliati, jrincayc
versions: +Python 3.4
Added file: http://bugs.python.org/file38213/fix-distutils-279.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8027>
_______________________________________


More information about the Python-bugs-list mailing list