zzzcpan / nginx-perl

Full-featured perl support for nginx
Other
72 stars 6 forks source link

make fails with newer compiler e.g. from latest Ubuntu distro #9

Open simonhf opened 6 years ago

simonhf commented 6 years ago
$ make
make -f objs/Makefile
make[1]: Entering directory '/home/simon/20180226-swoole-proxy/nginx-perl'
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/nginx.o \
        src/core/nginx.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/ngx_log.o \
        src/core/ngx_log.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/ngx_palloc.o \
        src/core/ngx_palloc.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/ngx_array.o \
        src/core/ngx_array.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/ngx_list.o \
        src/core/ngx_list.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/ngx_hash.o \
        src/core/ngx_hash.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/ngx_buf.o \
        src/core/ngx_buf.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/ngx_queue.o \
        src/core/ngx_queue.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/ngx_output_chain.o \
        src/core/ngx_output_chain.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/ngx_string.o \
        src/core/ngx_string.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/ngx_parse.o \
        src/core/ngx_parse.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/ngx_inet.o \
        src/core/ngx_inet.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/ngx_file.o \
        src/core/ngx_file.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/ngx_crc32.o \
        src/core/ngx_crc32.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/ngx_murmurhash.o \
        src/core/ngx_murmurhash.c
src/core/ngx_murmurhash.c: In function ‘ngx_murmur_hash2’:
src/core/ngx_murmurhash.c:37:11: error: this statement may fall through [-Werror=implicit-fallthrough=]
         h ^= data[2] << 16;
         ~~^~~~~~~~~~~~~~~~
src/core/ngx_murmurhash.c:38:5: note: here
     case 2:
     ^~~~
src/core/ngx_murmurhash.c:39:11: error: this statement may fall through [-Werror=implicit-fallthrough=]
         h ^= data[1] << 8;
         ~~^~~~~~~~~~~~~~~
src/core/ngx_murmurhash.c:40:5: note: here
     case 1:
     ^~~~
cc1: all warnings being treated as errors
objs/Makefile:448: recipe for target 'objs/src/core/ngx_murmurhash.o' failed
make[1]: *** [objs/src/core/ngx_murmurhash.o] Error 1
make[1]: Leaving directory '/home/simon/20180226-swoole-proxy/nginx-perl'
Makefile:9: recipe for target 'build' failed
make: *** [build] Error 2
simonhf commented 6 years ago

Made these errors go away by adding these compiler attributes to the above file and several others:

$ diff src/core/ngx_murmurhash.c.orig src/core/ngx_murmurhash.c
37a38
>       __attribute__((fallthrough));
39a41
>       __attribute__((fallthrough));
simonhf commented 6 years ago

Also run into these compiler errors:

cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused -Werror -g -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/lib/x86_64-linux-gnu/perl/5.26/CORE  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules -I src/http/modules/perl \
        -o objs/src/http/modules/perl/ngx_http_perl_module.o \
        src/http/modules/perl/ngx_http_perl_module.c
In file included from src/http/modules/perl/ngx_http_perl_module.h:18:0,
                 from src/http/modules/perl/ngx_http_perl_module.c:22:
src/http/modules/perl/ngx_http_perl_module.c: In function ‘ngx_perl_resolver_handler’:
/usr/lib/x86_64-linux-gnu/perl/5.26/CORE/pp.h:338:41: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
 #  define _EXTEND_NEEDS_GROW(p,n) ( (n) < 0 || PL_stack_max - p < (n))
                                         ^
/usr/lib/x86_64-linux-gnu/perl/5.26/CORE/perl.h:3684:62: note: in definition of macro ‘EXPECT’
 #  define EXPECT(expr,val)                  __builtin_expect(expr,val)
                                                              ^~~~
/usr/lib/x86_64-linux-gnu/perl/5.26/CORE/perl.h:3689:52: note: in expansion of macro ‘cBOOL’
 #define UNLIKELY(cond)                      EXPECT(cBOOL(cond),FALSE)
                                                    ^~~~~
/usr/lib/x86_64-linux-gnu/perl/5.26/CORE/pp.h:341:30: note: in expansion of macro ‘UNLIKELY’
                          if (UNLIKELY(_EXTEND_NEEDS_GROW(p,n))) {       \
                              ^~~~~~~~
/usr/lib/x86_64-linux-gnu/perl/5.26/CORE/pp.h:341:39: note: in expansion of macro ‘_EXTEND_NEEDS_GROW’
                          if (UNLIKELY(_EXTEND_NEEDS_GROW(p,n))) {       \
                                       ^~~~~~~~~~~~~~~~~~
src/http/modules/perl/ngx_http_perl_module.c:1767:9: note: in expansion of macro ‘EXTEND’
         EXTEND(SP, ctx->naddrs);
         ^~~~~~
/usr/lib/x86_64-linux-gnu/perl/5.26/CORE/pp.h:338:65: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
 #  define _EXTEND_NEEDS_GROW(p,n) ( (n) < 0 || PL_stack_max - p < (n))
                                                                 ^
/usr/lib/x86_64-linux-gnu/perl/5.26/CORE/perl.h:3684:62: note: in definition of macro ‘EXPECT’
 #  define EXPECT(expr,val)                  __builtin_expect(expr,val)
                                                              ^~~~
/usr/lib/x86_64-linux-gnu/perl/5.26/CORE/perl.h:3689:52: note: in expansion of macro ‘cBOOL’
 #define UNLIKELY(cond)                      EXPECT(cBOOL(cond),FALSE)
                                                    ^~~~~
/usr/lib/x86_64-linux-gnu/perl/5.26/CORE/pp.h:341:30: note: in expansion of macro ‘UNLIKELY’
                          if (UNLIKELY(_EXTEND_NEEDS_GROW(p,n))) {       \
                              ^~~~~~~~
/usr/lib/x86_64-linux-gnu/perl/5.26/CORE/pp.h:341:39: note: in expansion of macro ‘_EXTEND_NEEDS_GROW’
                          if (UNLIKELY(_EXTEND_NEEDS_GROW(p,n))) {       \
                                       ^~~~~~~~~~~~~~~~~~
src/http/modules/perl/ngx_http_perl_module.c:1767:9: note: in expansion of macro ‘EXTEND’
         EXTEND(SP, ctx->naddrs);
         ^~~~~~
In file included from /usr/lib/x86_64-linux-gnu/perl/5.26/CORE/perl.h:5644:0,
                 from src/http/modules/perl/ngx_http_perl_module.h:18,
                 from src/http/modules/perl/ngx_http_perl_module.c:22:
/usr/lib/x86_64-linux-gnu/perl/5.26/CORE/pp.h:306:68: error: signed and unsigned type in conditional expression [-Werror=sign-compare]
         (sizeof(n) > sizeof(SSize_t) && ((SSize_t)(n) != (n)) ? -1 : (n))
                                                                    ^
/usr/lib/x86_64-linux-gnu/perl/5.26/CORE/embed.h:589:53: note: in definition of macro ‘stack_grow’
 #define stack_grow(a,b,c) Perl_stack_grow(aTHX_ a,b,c)
                                                     ^
/usr/lib/x86_64-linux-gnu/perl/5.26/CORE/pp.h:342:49: note: in expansion of macro ‘_EXTEND_SAFE_N’
                            sp = stack_grow(sp,p,_EXTEND_SAFE_N(n));     \
                                                 ^~~~~~~~~~~~~~
src/http/modules/perl/ngx_http_perl_module.c:1767:9: note: in expansion of macro ‘EXTEND’
         EXTEND(SP, ctx->naddrs);
         ^~~~~~
cc1: all warnings being treated as errors
objs/Makefile:1078: recipe for target 'objs/src/http/modules/perl/ngx_http_perl_module.o' failed
make[1]: *** [objs/src/http/modules/perl/ngx_http_perl_module.o] Error 1
make[1]: Leaving directory '/home/simon/20180226-swoole-proxy/nginx-perl'
Makefile:9: recipe for target 'build' failed
make: *** [build] Error 2
simonhf commented 6 years ago

Fixed these by turning the compiler warning off and on around that particular macro:

$ diff src/http/modules/perl/ngx_http_perl_module.c.orig src/http/modules/perl/ngx_http_perl_module.c
1766a1767,1768
>       #pragma GCC diagnostic ignored "-Wtype-limits"
>       #pragma GCC diagnostic ignored "-Wsign-compare"
1767a1770,1771
>       #pragma GCC diagnostic warning "-Wtype-limits"
>       #pragma GCC diagnostic warning "-Wsign-compare"