On Mon, Jan 25, 2010 at 1:50 PM, "Martin v. Löwis" <mar...@v.loewis.de> wrote: >> We really do need precise descriptions of the problems so we can avoid them. > > One family of problems is platform lack of initializer support in the > object file format; any system with traditional a.out (or b.out) is > vulnerable (also, COFF is, IIRC). > > The solution e.g. g++ came up with is to have the collect2 linker > replacement combine all such initializers into a synthesized function > __main; this function then gets "magically" called by main(), provided > that main() itself gets compiled by a C++ compiler. Python used to have > a ccpython.cc entry point to support such systems. > > This machinery is known to fail in the following ways: > a) main() is not compiled with g++: static objects get not constructed > b) code that gets linked into shared libraries (assuming the system > supports them) does not get its initializers invoked. > c) compilation of main() with a C++ compiler, but then linking with ld > results in an unresolved symbol __main.
Thank you for the details. I'm pretty confident that (a) and (c) will not be a problem for the Unladen Swallow merge because we switched python.c (which holds main()) and linking to use the C++ compiler when LLVM's enabled at all: http://code.google.com/p/unladen-swallow/source/browse/trunk/Makefile.pre.in. Python already had some support for this through the LINKCC configure variable, but it wasn't being used to compile main(), just to link. (b) could be a problem if we depend on LLVM as a shared library on one of these platforms (and, of course, if LLVM's JIT supports these systems at all). The obvious answers are: 1) --without-llvm on these systems, 2) link statically on these systems, 3) eliminate the static constructors. There may also be less obvious answers. > Not sure whether U-S has any global C++ objects that need construction > (but I would be surprised if it didn't). I checked with them, and LLVM would welcome patches to remove these if we need to. They already have a llvm::ManagedStatic class (http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ManagedStatic.h?view=markup) with no constructor that we can replace most of them with. Jeffrey _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com