PY_ARRAY_UNIQUE_SYMBOL not unique enough #2039

Closed
bfroehle opened this Issue May 21, 2013 · 0 comments

Comments

Projects
None yet
1 participant
Contributor

bfroehle commented May 21, 2013

I'm attempting to compile a statically linked Python interpreter which includes matplotlib. In general this works fine, except that I get errors during the linking phase:

multiple definition of `MPL_ARRAY_API'
.../matplotlib/_delaunay.a(_delaunay.o):.../build/matplotlib-1.2.1/lib/matplotlib/delaunay/_delaunay.cpp:313: first defined here
.../matplotlib/backends/_backend_agg.a(backend_agg.o): In function `__exchange_and_add_dispatch':
multiple definition of `MPL_ARRAY_API'
.../matplotlib/_delaunay.a(_delaunay.o):.../build/matplotlib-1.2.1/lib/matplotlib/delaunay/_delaunay.cpp:313: first defined here
.../matplotlib/_png.a(_png.o): In function `__exchange_and_add_dispatch':
multiple definition of `MPL_ARRAY_API'
.../matplotlib/_delaunay.a(_delaunay.o):.../build/matplotlib-1.2.1/lib/matplotlib/delaunay/_delaunay.cpp:313: first defined here
.../matplotlib/_tri.a(_tri.o): In function `__exchange_and_add_dispatch':
multiple definition of `MPL_ARRAY_API'
.../matplotlib/_delaunay.a(_delaunay.o):.../build/matplotlib-1.2.1/lib/matplotlib/delaunay/_delaunay.cpp:313: first defined here
.../matplotlib/ft2font.a(ft2font.o): In function `__exchange_and_add_dispatch':
multiple definition of `MPL_ARRAY_API'
.../matplotlib/_delaunay.a(_delaunay.o):.../build/matplotlib-1.2.1/lib/matplotlib/delaunay/_delaunay.cpp:313: first defined here
.../matplotlib/_path.a(path.o): In function `__exchange_and_add_dispatch':
multiple definition of `MPL_ARRAY_API'
.../matplotlib/_delaunay.a(_delaunay.o):.../build/matplotlib-1.2.1/lib/matplotlib/delaunay/_delaunay.cpp:313: first defined here

These errors are ignorable, using -Wl,-z,muldefs or similar, but if possible I'd like to clean them up.

Would there by any objection to using a differently named PY_ARRAY_UNIQUE_SYMBOL per extension module? This would be best-practice anyway.

I was thinking the name could be something like MPL_matplotlib__png_ARRAY_API which could be constructed like:

name = ext.name.replace('.', '_')
ext.define_macros.append(('PY_ARRAY_UNIQUE_SYMBOL',
                          'MPL_' + name + '_ARRAY_API'))

The change would be minimally intrusive in the master branch (only a few lines of code changed in the Numpy class in setupext.py). It would require more extensive changes in the 1.2.x branch so I would recommend not backporting the change.

I'm happy to provide a pull request if you think it would be accepted.

@mdboom mdboom closed this in 40bbb9b May 22, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment