DOC: Missing -std=c99 flags somewhere? · Issue #12766 · numpy/numpy · GitHub
Skip to content

DOC: Missing -std=c99 flags somewhere? #12766

Description

@madphysicist

When I attempt to build on RHEL 7.3, I get an error unless I manually do

(numpy-testing-py3) [jfoxrabi@... numpy]$ export CFLAGS=-std=c99

Here is my console session without setting the flag (forgive me for using ./runtests.py. I still haven't figured out a better shortcut for getting the log and running the test simultaneously):

(numpy-testing-py3) [jfoxrabi@... numpy]$ echo $CFLAGS

(numpy-testing-py3) [jfoxrabi@... numpy]$ ./runtests.py 
Building, see build.log...
    ... build in progress
Processing numpy/random/mtrand/randint_helpers.pxi.in
Processing numpy/random/mtrand/mtrand.pyx
Cythonizing sources
blas_opt_info:
blas_mkl_info:
customize UnixCCompiler
  FOUND:
    libraries = ['mkl_rt', 'pthread']
    library_dirs = ['/home/jfoxrabi/miniconda3/envs/numpy-testing-py3/lib']
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['/usr/local/include', '/usr/include', '/home/jfoxrabi/miniconda3/envs/numpy-testing-py3/include']

  FOUND:
    libraries = ['mkl_rt', 'pthread']
    library_dirs = ['/home/jfoxrabi/miniconda3/envs/numpy-testing-py3/lib']
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['/usr/local/include', '/usr/include', '/home/jfoxrabi/miniconda3/envs/numpy-testing-py3/include']

non-existing path in 'numpy/distutils': 'site.cfg'
lapack_opt_info:
lapack_mkl_info:
customize UnixCCompiler
  FOUND:
    libraries = ['mkl_rt', 'pthread']
    library_dirs = ['/home/jfoxrabi/miniconda3/envs/numpy-testing-py3/lib']
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['/usr/local/include', '/usr/include', '/home/jfoxrabi/miniconda3/envs/numpy-testing-py3/include']

  FOUND:
    libraries = ['mkl_rt', 'pthread']
    library_dirs = ['/home/jfoxrabi/miniconda3/envs/numpy-testing-py3/lib']
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['/usr/local/include', '/usr/include', '/home/jfoxrabi/miniconda3/envs/numpy-testing-py3/include']

running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building py_modules sources
creating build/src.linux-x86_64-3.6
creating build/src.linux-x86_64-3.6/numpy
creating build/src.linux-x86_64-3.6/numpy/distutils
building library "npymath" sources
get_default_fcompiler: matching types: '['gnu95', 'intel', 'lahey', 'pg', 'absoft', 'nag', 'vast', 'compaq', 'intele', 'intelem', 'gnu', 'g95', 'pathf95', 'nagfor']'
customize Gnu95FCompiler
Found executable /home/jfoxrabi/miniconda3/envs/numpy-testing-py3/bin/gfortran
customize Gnu95FCompiler
customize Gnu95FCompiler using config
C compiler: gcc -pthread -B /home/jfoxrabi/miniconda3/envs/numpy-testing-py3/compiler_compat -Wl,--sysroot=/ -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Werror=vla -Werror=nonnull -Werror=pointer-arith -Wlogical-op -Werror=unused-function -fPIC

compile options: '-Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/home/jfoxrabi/miniconda3/envs/numpy-testing-py3/include/python3.6m -c'
gcc: _configtest.c
gcc -pthread -B /home/jfoxrabi/miniconda3/envs/numpy-testing-py3/compiler_compat -Wl,--sysroot=/ _configtest.o -o _configtest
success!
removing: _configtest.c _configtest.o _configtest.o.d _configtest
C compiler: gcc -pthread -B /home/jfoxrabi/miniconda3/envs/numpy-testing-py3/compiler_compat -Wl,--sysroot=/ -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Werror=vla -Werror=nonnull -Werror=pointer-arith -Wlogical-op -Werror=unused-function -fPIC

compile options: '-Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/home/jfoxrabi/miniconda3/envs/numpy-testing-py3/include/python3.6m -c'
gcc: _configtest.c
_configtest.c:1:5: warning: conflicting types for built-in function ‘exp’ [enabled by default]
 int exp (void);
     ^
gcc -pthread -B /home/jfoxrabi/miniconda3/envs/numpy-testing-py3/compiler_compat -Wl,--sysroot=/ _configtest.o -o _configtest
/home/jfoxrabi/miniconda3/envs/numpy-testing-py3/compiler_compat/ld: _configtest.o: in function `main':
/home/jfoxrabi/Documents/OTS/numpy/_configtest.c:6: undefined reference to `exp'
collect2: error: ld returned 1 exit status

<... SNIP ...>

numpy/fft/pocketfft.c:2042:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
   for (size_t m=0; m<n; ++m)
   ^
numpy/fft/pocketfft.c: In function ‘rfftblue_forward’:
numpy/fft/pocketfft.c:2054:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
   for (size_t m=0; m<n; ++m)
   ^
numpy/fft/pocketfft.c: In function ‘execute_complex’:
numpy/fft/pocketfft.c:2213:7: error: ‘for’ loop initial declarations are only allowed in C99 mode
       for (int i = 0; i < nrepeats; i++) {
       ^
numpy/fft/pocketfft.c: In function ‘execute_real_forward’:
numpy/fft/pocketfft.c:2246:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
     for (int d=0; d<ndim-1; ++d)
     ^
numpy/fft/pocketfft.c:2265:9: error: ‘for’ loop initial declarations are only allowed in C99 mode
         for (int i = 0; i < nrepeats; i++) {
         ^
numpy/fft/pocketfft.c: In function ‘execute_real_backward’:
numpy/fft/pocketfft.c:2310:9: error: ‘for’ loop initial declarations are only allowed in C99 mode
         for (int i = 0; i < nrepeats; i++) {
         ^
Running from numpy source directory.
/home/jfoxrabi/miniconda3/envs/numpy-testing-py3/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'define_macros'
  warnings.warn(msg)
error: Command "gcc -pthread -B /home/jfoxrabi/miniconda3/envs/numpy-testing-py3/compiler_compat -Wl,--sysroot=/ -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Werror=vla -Werror=nonnull -Werror=pointer-arith -Wlogical-op -Werror=unused-function -fPIC -Inumpy/core/include -Ibuild/src.linux-x86_64-3.6/numpy/core/include/numpy -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/home/jfoxrabi/miniconda3/envs/numpy-testing-py3/include/python3.6m -Ibuild/src.linux-x86_64-3.6/numpy/core/src/common -Ibuild/src.linux-x86_64-3.6/numpy/core/src/npymath -Ibuild/src.linux-x86_64-3.6/numpy/core/src/common -Ibuild/src.linux-x86_64-3.6/numpy/core/src/npymath -c numpy/fft/pocketfft.c -o build/temp.linux-x86_64-3.6/numpy/fft/pocketfft.o -MMD -MF build/temp.linux-x86_64-3.6/numpy/fft/pocketfft.o.d" failed with exit status 1

Build failed!

Complete failed build.log

As soon as I set CFLAGS, the build completes and the tests start to run:

(numpy-testing-py3) [jfoxrabi@... numpy]$ export CFLAGS=-std=c99
(numpy-testing-py3) [jfoxrabi@... numpy]$ ./runtests.py 
Building, see build.log...
Build OK
NumPy version 1.17.0.dev0+8aedcc0
NumPy relaxed strides checking option: True
.................x...................................................... [  0%]
........................................................................ [  1%]
........................................................................ [  2%]
........................................................................ [  3%]
......................ssss................................x............s [  4%]
........................................................................ [  5%]
........................................................................ [  6%]
........................................................................ [  7%]
........................................................................ [  8%]
........................................................................ [  9%]
.................................................................sss.... [ 10%]
........................................................................ [ 11%]
...........................s.......................xx........s.......... [ 12%]

<... SNIP ...>

Complete successful build.log

This looks like the -std=c99 flag is not being set explicitly somewhere, and my compiler does not assume it.

For completeness, I am running in an Anaconda environment (named numpy-testing-py3), running Python 3.6.8, installing numpy commit 8aedcc0129b9fa7e1785aa11779cbc1c1b3d3395 (my branch for #10855), which is effectively master at 49689f7.

I have edited out my hostname, but not the paths or user name because the former are at fairly standard locations, and the latter is publicly available.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions