Commit e0b25398 authored by Kirill Smelkov's avatar Kirill Smelkov

Fix build with Python that enables -Werror=declaration-after-statement

In C99 declaration after statement is ok, and we explicitly compile with -std=gnu99.

Python >= 3.4 however adds -Werror=declaration-after-statement even for extension
modules irregardless of their compilation flags:

  https://bugs.python.org/issue21121

and the build fails this way:

    building 'wendelin.bigfile._bigfile' extension
    creating build/temp.linux-x86_64-3.4
    creating build/temp.linux-x86_64-3.4/bigfile
    creating build/temp.linux-x86_64-3.4/lib
    gcc -pthread -Wno-unused-result -Werror=declaration-after-statement -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -O2 -Wall
-D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -DOPENSSL_LOAD_CONF -fPIC -D_GNU_SOURCE
-I./include -I./3rdparty/ccan -I./3rdparty/include -I/usr/include/python3.4m -c bigfile/_bigfile.c -o build/temp.linux-x86_64-3.4/bigfile/_bigfile.o
-std=gnu99 -fplan9-extensions -fvisibility=hidden
    bigfile/_bigfile.c: In function ‘pyfile_new’:
    bigfile/_bigfile.c:679:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
         static char *kw_list[] = {"blksize", NULL};
         ^
    cc1: some warnings being treated as errors
    error: command 'gcc' failed with exit status 1

Ensure we turn off this warning and error because we already rely on compiling in C99 mode.
Reported-and-tested-by: default avatarIvan Tyagov <ivan@tyagov.com>
parent 4b6821f4
......@@ -57,7 +57,9 @@ FORCE :
# XXX dup with setup.py
CPPFLAGS:= -Iinclude -I3rdparty/ccan -I3rdparty/include
CFLAGS := -g -Wall -D_GNU_SOURCE -std=gnu99 -fplan9-extensions
CFLAGS := -g -Wall -D_GNU_SOURCE -std=gnu99 -fplan9-extensions \
-Wno-declaration-after-statement \
-Wno-error=declaration-after-statement \
# XXX hack ugly
LOADLIBES=lib/bug.c lib/utils.c 3rdparty/ccan/ccan/tap/tap.c
......
......@@ -46,6 +46,16 @@ _bigfile = Extension('wendelin.bigfile._bigfile',
'-std=gnu99', # declarations inside for-loop
'-fplan9-extensions', # anonymous-structs + simple inheritance
'-fvisibility=hidden', # by default symbols not visible outside DSO
# in C99 declaration after statement is ok, and we explicitly compile with -std=gnu99.
# Python >= 3.4 however adds -Werror=declaration-after-statement even for extension
# modules irregardless of their compilation flags:
#
# https://bugs.python.org/issue21121
#
# ensure there is no warnings / errors for decl-after-statements.
'-Wno-declaration-after-statement',
'-Wno-error=declaration-after-statement',
],
# can't - at runtime links with either python (without libpython) or libpython
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment