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: ext module generation problem
Type: Stage:
Components: Distutils Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, fdrake, mwh, stefan
Priority: normal Keywords:

Created on 2002-08-23 14:01 by stefan, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ccompiler-patch akuchling, 2002-11-13 21:47 Patch to not strip directories from temp. obj. names
ugly-patch akuchling, 2002-12-04 18:13 Icky hack.
ccompiler.diff akuchling, 2002-12-26 15:00 Strip dirs if python_build is true
Messages (18)
msg12118 - (view) Author: Stefan Seefeld (stefan) * (Python committer) Date: 2002-08-23 14:01
when compiling an extension module, the source file
location
is not mirrored into the object file location, i.e.
subdirectories
are ignored (foo/bar/baz.c is compiled to baz.o, not
foo/bar/baz.o)
msg12119 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2002-08-23 19:26
Logged In: YES 
user_id=3066

Why is this a problem?  Are you running into name clashes?
msg12120 - (view) Author: Stefan Seefeld (stefan) * (Python committer) Date: 2002-08-23 19:31
Logged In: YES 
user_id=764

precisely.
msg12121 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2002-11-06 15:14
Logged In: YES 
user_id=11375

Hm, this is supposed to work, judging by the docstring of 
Compiler.compile().  Maybe some  subclass of Compiler gets it wrong; what platform are you on?
msg12122 - (view) Author: Stefan Seefeld (stefan) * (Python committer) Date: 2002-11-06 15:21
Logged In: YES 
user_id=764

I experienced it with linux / gcc
msg12123 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2002-11-13 21:38
Logged In: YES 
user_id=11375

Hm.  Compiling my cryptography modules, it mirrors the location for the final source file (Crypto/Cipher/DES.so), but not for the intermediate 
.o file, which gets written to  build/temp.linux-i686-2.3/DES.o.  Is that 
the problem you're seeing?

(In any case, the temp. directory should use full paths, so this is a bug.)
msg12124 - (view) Author: Stefan Seefeld (stefan) * (Python committer) Date: 2002-11-13 21:42
Logged In: YES 
user_id=764

yes, precisely !
msg12125 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2002-11-13 21:47
Logged In: YES 
user_id=11375

OK, then try the attached patch.  Does it fix the problem?

msg12126 - (view) Author: Stefan Seefeld (stefan) * (Python committer) Date: 2002-11-13 21:59
Logged In: YES 
user_id=764

I 'applied' the patch to my python2.2 installation, i.e. I
replaced the (single)
call to 'object_filenames' by your version. That works.

Thanks !
msg12127 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2002-11-14 01:30
Logged In: YES 
user_id=11375

Great!  Checked in as rev 1.52 of ccompiler.py, and I'll
backport it to 
the 2.2 maintenance branch.
msg12128 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2002-12-04 13:27
Logged In: YES 
user_id=6656

This broke out-of-tree builds of Python.

Any quick ideas on what to do?
msg12129 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2002-12-04 14:54
Logged In: YES 
user_id=11375

Not sure.  I'm trying to replicate it, but current CVS out-of-tree builds 
are failing much earlier for me, when it tries to link Parser/pgen.
msg12130 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2002-12-04 15:12
Logged In: YES 
user_id=11375

One "make distclean" later, out-of-the-tree builds work fine for me.  How do they fail?
msg12131 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2002-12-04 15:18
Logged In: YES 
user_id=6656

OK, they don't actually break, but .o files end up in 
  src/Modules/ 
rather than 
  src/build-temp/build/temp.foo/
so multiple oot builds don't so what you'd expect.

This came up on python-dev in the thread
"extension module .o files wind up in the wrong place"
starting here:
http://mail.python.org/pipermail/python-dev/2002-December/030644.html
msg12132 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2002-12-04 18:13
Logged In: YES 
user_id=11375

Now I get it. 

In an in-tree build, the source path is something relative, such as 
../Modules/foo.c, but in an out-of-tree build it's absolute.  This is due to a line in setup.py, but I can't remember why this is done.

One fix that's an egregious hack is to modify CCompiler.object_filenames: if strip_dir is false and
the path is absolute, strip off the path to the source directory; see the attached patch.  The patch also modifies setup.py to leave the path names alone.

I'll keep thinking about this.



msg12133 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2002-12-26 15:00
Logged In: YES 
user_id=11375

A much simpler change is to modify the original patch that caused the problem, and strip the directory prefixes when python_build is true, trusting that there won't be conflicting filenames in the Python distribution.


msg12134 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2002-12-26 21:05
Logged In: YES 
user_id=6656

That would do, yes.
msg12135 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2002-12-29 18:18
Logged In: YES 
user_id=11375

Checked in.
History
Date User Action Args
2022-04-10 16:05:36adminsetgithub: 37076
2002-08-23 14:01:04stefancreate