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

Jack Jansen Jack.Jansen at cwi.nl
Mon Sep 22 05:24:21 EDT 2003


Are you sure you completely cleaned out any objects from the old build? 
Because the
"-Wl,-bind_at_load -flat_namespace -undefined suppress" is bit is 
really very bad practice.
It basically tells the linker "don't worry about any external symbol, 
and just hack something
together at runtime".

The "-Wl,-x" shouldn't cause any problems: it only strips non-global 
symbols. While this
could hinder debugging it shouldn't have any effect on linking. Unless 
it is somehow C++-related:
does anyone know whether stripping non-global symbols could cause 
problems for the G++ RTTI
stuff or exception handling or something?

On Monday, September 22, 2003, at 07:06 AM, Nicholas Riley wrote:

> 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>
>
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
>
--
Jack Jansen, <Jack.Jansen at cwi.nl>, http://www.cwi.nl/~jack
If I can't dance I don't want to be part of your revolution -- Emma 
Goldman




More information about the Pythonmac-SIG mailing list