#1259 closed defect (fixed)
nginx build fails when using gcc7 compiler
Reported by: | Dariusz Bogdanski | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | other | Version: | 1.9.x |
Keywords: | Cc: | ||
uname -a: | Linux dbrpi01 4.9.24-v7+ #991 SMP Sat Apr 22 20:26:57 BST 2017 armv7l GNU/Linux | ||
nginx -V: | N/A |
Description
Nginx build fails when using gcc7 compiler. I have experienced it on Raspberry Pi running rasbian but given nature of the problem results will be the same on other platforms when gcc7 is used.
Example make error:
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:
~ ==
Reason for compilation errors like these is that GCC 7 added (https://gcc.gnu.org/gcc-7/changes.html) a new -Wimplicit-fallthrough which generates a message for case statements that implicitly fallthrough to the next case.
Change History (7)
comment:2 by , 8 years ago
Thanks. With your patch it compiles without any issues with gcc7
Just curious why nginx has -Werror enabled.. It breaks builds for new compilers with new warnings introduced. IMHO it makes perfect sense during development but not for code to be shipped. Without -Werror it would be more future proof...
comment:3 by , 8 years ago
Thanks for testing.
Without -Werror
it is very easy to miss important warnings, including ones that only appear on some exotic platforms developers do not have access to, so we prefer to always use -Werror
. Not to mention that there is no real difference between "development" and "code to be shipped". If needed, -Werror
can be easily disabled with ./configure --with-cc-opt="-Wno-error"
.
Try the following patch: