[Pythonmac-SIG] -Wl,-x in distutils module linking causes crashes

Nicholas Riley njriley at uiuc.edu
Mon Sep 22 01:06:58 EDT 2003


Hi,

I'm working on moving the Mk4py Python bindings for Metakit
<http://www.equi4.com/metakit/> to a distutils-based build system.

The old build system's link line (using libtool) looks like this:

g++ -bundle -Wl,-bind_at_load -flat_namespace -undefined suppress -o .libs/libmk4py.so  .libs/PyProperty.o .libs/PyRowRef.o .libs/PyStorage.o .libs/PyView.o .libs/PWOImp.o .libs/column.o .libs/custom.o .libs/derived.o .libs/fileio.o .libs/field.o .libs/format.o .libs/handler.o .libs/persist.o .libs/remap.o .libs/std.o.libs/store.o .libs/string.o .libs/table.o .libs/univ.o .libs/view.o .libs/viewx.o  -lstdc++

This is suboptimal in several ways, in particular because of the
-flat_namespace option.  Distutils generates a link line like this:

c++ -Wl,-x -Wl,-F. -bundle -framework Python ../builds/temp.darwin-6.6-Power_Macintosh-2.3/PyProperty.o ../builds/temp.darwin-6.6-Power_Macintosh-2.3/PyRowRef.o ../builds/temp.darwin-6.6-Power_Macintosh-2.3/PyStorage.o ../builds/temp.darwin-6.6-Power_Macintosh-2.3/PyView.o ../builds/temp.darwin-6.6-Power_Macintosh-2.3/scxx/PWOImp.o ../builds/column.o ../builds/custom.o ../builds/derived.o ../builds/fileio.o ../builds/field.o ../builds/format.o ../builds/handler.o ../builds/persist.o ../builds/remap.o ../builds/std.o ../builds/store.o ../builds/string.o ../builds/table.o ../builds/univ.o ../builds/view.o ../builds/viewx.o -o ../builds/lib.darwin-6.6-Power_Macintosh-2.3/Mk4py.so

This looks better, but the resulting module does not work:

>>> x = Mk4py.storage()

Program received signal EXC_BAD_INSTRUCTION, Illegal instruction/operand.
0x002f5114 in Z15f4_CreateFilterR11c4_Sequence9c4_CursorS1_.eh ()
(gdb) bt
#0  0x002f5114 in Z15f4_CreateFilterR11c4_Sequence9c4_CursorS1_.eh ()
#1  0x002baf9c in c4_PyStream::Write(void const*, int) ()
#2  0x10077090 in call_function (pp_stack=0x75880, oparg=0) at /Users/jack/src/python-23/Python/ceval.c:3439
[...]

After many hours of pain and suffering, I finally tracked down the
problem to the "-Wl,-x" option.  Apparently it's stripping some
symbols which are needed.

I don't know whether the problem is in the linker or Mk4py.  For the
time being, I added an ugly hack to remove the linker option, but I
wonder if it would be better to remove it from the default Python link
line.

-- 
=Nicholas Riley <njriley at uiuc.edu> | <http://www.uiuc.edu/ph/www/njriley>



More information about the Pythonmac-SIG mailing list