[C++-sig] Re: Linux Intel compiler exception problems in Python

Raoul Gough RaoulGough at yahoo.co.uk
Fri Oct 10 18:01:07 CEST 2003


"Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com> writes:

> --- Raoul Gough <RaoulGough at yahoo.co.uk> wrote:
>> This could mean that if Python was compiled with gcc, then icc
>> compiled extension modules cannot use C++ exceptions (although the
>> copy of Python I'm using doesn't depend on anything called
>> libgcc_s.so).
>
> Thanks for the clue! I've compiled Python 2.3 with the icc
> compiler. When compiling Boost.Python modules against that Python
> installation the exception handling problems seem to be gone (I did
> not run all tests yet). Very, very good!

I managed to reduce the problem further, and isolated it to a specific
problem with the Intel libcxa.so.3 shared library. It seems that if
this doesn't get loaded before program execution begins, it doesn't
set up the exception handling correctly.  Fortunately, there is a way
to force it to load, even if the Python executable doesn't have a
dependency on it (which is what rebuilding Python with icc fixes, of
course).

Reading the linux ld.so man page, the linker/loader inspects the
environment variable LD_PRELOAD to allow the injection of libraries
before program startup. It accepts a space separated list of
libraries, and in this case we need:

/opt/intel/compiler70/ia32/lib/libunwind.so.3
/opt/intel/compiler70/ia32/lib/libcxa.so.3

e.g. (from bash, with the stock gcc-built python)

$ python $BOOST_DIST/libs/python/test/exception_translator.py
running...
Aborted
$ LD_PRELOAD="/opt/intel/compiler70/ia32/lib/libunwind.so.3 /opt/intel/compiler70/ia32/lib/libcxa.so.3" python $BOOST_DIST/libs/python/test/exception_translator.py
running...
Done.
$ alias python_icc='LD_PRELOAD="/opt/intel/compiler70/ia32/lib/libunwind.so.3 /opt/intel/compiler70/ia32/lib/libcxa.so.3" python'
$ python_icc $BOOST_DIST/libs/python/test/exception_translator.py
running...
Done.
$

Which turns out to be an amazingly easy workaround, once known.

-- 
Raoul Gough.
(setq dabbrev-case-fold-search nil)





More information about the Cplusplus-sig mailing list