numpy / numpy

The fundamental package for scientific computing with Python.
https://numpy.org
Other
28.16k stars 10.16k forks source link

xlocale.h definition conflicts with IBM advanced toolchain #17347

Open anands-repo opened 4 years ago

anands-repo commented 4 years ago

I am using a POWER8 machine with a CentOS docker container. I do not use the system gcc but the compiler that comes with the IBM Advance Toolchain. It is common to use this alternative compiler for IBM POWER systems.

The advance tool chain's gcc libraries do not contain the xlocale.h header, but the system gcc contains the header. In this case, the OPTIONAL_HEADER checks described in https://github.com/numpy/numpy/pull/8367 come out successful for xlocale.h. However this causes conflicts between some definitions in the advance tool chain's gcc library and the system libraries.

To get a successful build, I needed to comment xlocale.h in numpy/core/setup_common.py. I have two concerns:

  1. The build comes out fine, and some numpy functionality works, but it would be great to know whether this is an appropriate way to deal with this.
  2. Is there a cleaner way to do the same thing? I am not sure this is a fair request since this probably occurs due to having an alternative library. However I am also wondering whether this is a common case for a subset of users who need to use a different compiler from the standard system compiler.

Reproducing code example:

CC=/opt/at11.0/bin/gcc python setup.py install

Error message:

/usr/include/xlocale.h:27:16: error: redefinition of 'struct __locale_struct'
 typedef struct __locale_struct
                ^~~~~~~~~~~~~~~
In file included from /opt/at11.0/include/bits/types/locale_t.h:22:0,
                 from /opt/at11.0/include/string.h:152,
                 from /root/install/include/python3.6m/Python.h:30,
                 from numpy/core/src/common/numpyos.c:2:
/opt/at11.0/include/bits/types/__locale_t.h:28:8: note: originally defined here
 struct __locale_struct
        ^~~~~~~~~~~~~~~
In file included from numpy/core/src/common/numpyos.c:23:0:
/usr/include/xlocale.h:39:4: error: conflicting types for '__locale_t'
 } *__locale_t;
    ^~~~~~~~~~

NumPy/Python version information:

Version is 1.19.2

mattip commented 4 years ago

xref gh-13280 which was solved for conda compilers via gh-12135. I guess that fix was only partial.