Search code examples
travis-cianacondapython-c-api

Compiling C extension with anaconda on Travis-CI missing __log_finite symbol


A C extension module that compiles fine on Travis-CI without anaconda fails when installed with anaconda. It appears to install just fine, but when I try to import it, I get the following error:

ImportError: /home/travis/anaconda/lib/python2.7/site-packages/quaternion/numpy_quaternion.so: undefined symbol: __log_finite

The full error can be seen here. Obviously, this looks like a linker error, where it can't find glibc (which I believe is where __log_finite is found). But why should it fail to find glibc?

When I run nm on that .so file (through Travis), it shows that __log_finite is indeed undefined, but shouldn't it find it through the usual process?

I've tried installing quaternion through pip and I've tried installing it by directly downloading it and running python setup.py install. Both seem to work, in the sense that it looks like all the files are where they should be. But both fail on import because they can't find that symbol.

I've even tried installing the full version of anaconda (rather than just miniconda, which is recommended). Nothing seems to work. How can I make Travis find that symbol, and is this something I'll have to worry about ordinarily with my distribution?


Solution

  • It appears to be a problem with a -ffast-math flag in my quaternion package. One thing that flag does is make the code assume that the numbers are finite, so that instead of using the log function, it uses some log_finite function, which for some reason Travis doesn't have --- or something. Anyway, I have my numba package set an environment variable in Travis builds, which the quaternion package then looks for on installation, and turns off fast-math. This is unfortunate, because it means I'm not actually testing the code as it's actually used. But it means my code builds and tests pass.

    There seems to be about one mention of this on the internet. Or not; I can't tell.