[Cython] Minor issue with running tests and -Wlong-long

Stefan Behnel stefan_ml at behnel.de
Sat Sep 3 04:46:35 EDT 2016


Erik Bray schrieb am 25.04.2016 um 17:18:
> As some of you already know I've been doing some work on Cython on
> Cygwin [in the process I I'm constantly mixing the two up in speech,
> but maybe in writing I'll do better :)].
> 
> There are several issues with the tests on Cygwin, and that's one
> thing I'll work on.  But a major annoyance I've encountered when
> running any tests is a huge number of warnings from gcc such as:
> 
> embray at PC-pret-47 ~/src/cython
> $ CFLAGS="-O0" ./runtests.py -vv --no-cpp addloop
> Python 2.7.10 (default, Jun  1 2015, 18:05:38)
> [GCC 4.9.2]
> 
> Running tests against Cython 0.24 f68b5bd0fa620d0dc26166bffe5fe42d94068720
> Backends: c
> 
> runTest (__main__.CythonRunTestCase)
> compiling (c) and running addloop ...
> === C/C++ compiler error output: ===
> In file included from /usr/include/python2.7/Python.h:58:0,
>                  from addloop.c:4:
> /usr/include/python2.7/pyport.h:69:27: warning: ISO C90 does not
> support ‘long long’ [-Wlong-long]
>  #define PY_LONG_LONG long long
>                            ^
> /usr/include/python2.7/pyport.h:793:34: note: in definition of macro
> ‘PyAPI_FUNC’
>  #       define PyAPI_FUNC(RTYPE) RTYPE
>                                   ^
> /usr/include/python2.7/intobject.h:46:21: note: in expansion of macro
> ‘PY_LONG_LONG’
>  PyAPI_FUNC(unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *);
>                      ^
> In file included from /usr/include/python2.7/Python.h:58:0,
>                  from addloop.c:4:
> ...
> 
> And so on.
> 
> For now an easy workaround is to add -Wno-long-long to the compiler
> flags.  But I was curious why I was seeing this in Cygwin but not on
> my Ubuntu system, and here's why:
> 
> In runtests.py there is a check
> 
> https://github.com/cython/cython/blob/master/runtests.py#L829
> 
> if self.language=='c' and compiler='gcc':
>     ext_compile_flags.extend(['-std=c89', '-pedantic'])
> 
> where in this case `compiler` is assigned
> `sysconfig.get_config_var('CC')`.  On my Linux system this expands to
> "x86_64-linux-gnu-gcc -pthread".  Whereas on Cygwin (and probably many
> other systems) it expands simply to "gcc".
> 
> I'm guessing that to do what it intended the above line should read
> "and 'gcc' in compiler".

Yes.

> But this also raises the question: Why are the tests run with these
> flags?  If Python was configured with HAVE_LONG_LONG, then these
> warnings will be inevitable.

Thanks for bringing this up. Adding "-Wno-long-long" seems the right thing
to do, given that this depends on CPython and not Cython.

Given that CPython *can* be configured without PY_LONG_LONG support,
however, we should then guard any such code in Cython with HAVE_LONG_LONG,
as CPython does internally, so that it actually compiles without it.

I would otherwise like to keep those compiler flags, even if they didn't
serve us yet, because it is not intended to put all too many constraints on
the C compiler. Supporting C89, at least whenever possible, would be nice.

Stefan



More information about the cython-devel mailing list