diff --git a/Makefile b/Makefile index a0692f38d20..ec88bd3926c 100644 --- a/Makefile +++ b/Makefile @@ -330,6 +330,12 @@ ifeq ($(HAS_WORKING_NO_MAYBE_UNINITIALIZED),true) W_NO_MAYBE_UNINITIALIZED=-Wno-maybe-uninitialized NO_W_NO_MAYBE_UNINITIALIZED=-Wmaybe-uninitialized endif +CHECK_NO_UNKNOWN_WARNING_OPTION_WORKS_CMD = $(CC) -std=c99 -Werror -Wno-unknown-warning-option -o $(TMPOUT) -c test/build/no-unknown-warning-option.c +HAS_WORKING_NO_UNKNOWN_WARNING_OPTION = $(shell $(CHECK_NO_UNKNOWN_WARNING_OPTION_WORKS_CMD) 2> /dev/null && echo true || echo false) +ifeq ($(HAS_WORKING_NO_UNKNOWN_WARNING_OPTION),true) +W_NO_UNKNOWN_WARNING_OPTION=-Wno-unknown-warning-option +NO_W_NO_UNKNOWN_WARNING_OPTION=-Wunknown-warning-option +endif # The HOST compiler settings are used to compile the protoc plugins. # In most cases, you won't have to change anything, but if you are @@ -348,7 +354,7 @@ CXXFLAGS += -stdlib=libc++ LDFLAGS += -framework CoreFoundation endif CXXFLAGS += -Wnon-virtual-dtor -CPPFLAGS += -g -Wall -Wextra -Werror -Wno-unknown-warning-option -Wno-long-long -Wno-unused-parameter -Wno-deprecated-declarations -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-maybe-uninitialized -DPB_FIELD_32BIT -DOSATOMIC_USE_INLINED=1 -Ithird_party/nanopb -Ithird_party/upb -Isrc/core/ext/upb-generated +CPPFLAGS += -g -Wall -Wextra -Werror $(W_NO_UNKNOWN_WARNING_OPTION) -Wno-long-long -Wno-unused-parameter -Wno-deprecated-declarations -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-maybe-uninitialized -DPB_FIELD_32BIT -DOSATOMIC_USE_INLINED=1 -Ithird_party/nanopb -Ithird_party/upb -Isrc/core/ext/upb-generated COREFLAGS += -fno-rtti -fno-exceptions LDFLAGS += -g diff --git a/build.yaml b/build.yaml index 7431dbb2a53..f43964408d4 100644 --- a/build.yaml +++ b/build.yaml @@ -6199,7 +6199,7 @@ defaults: CXXFLAGS: $(W_NO_CXX14_COMPAT) global: COREFLAGS: -fno-rtti -fno-exceptions - CPPFLAGS: -g -Wall -Wextra -Werror -Wno-unknown-warning-option -Wno-long-long + CPPFLAGS: -g -Wall -Wextra -Werror $(W_NO_UNKNOWN_WARNING_OPTION) -Wno-long-long -Wno-unused-parameter -Wno-deprecated-declarations -Wno-sign-conversion -Wno-shadow -Wno-conversion -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-maybe-uninitialized -DPB_FIELD_32BIT -DOSATOMIC_USE_INLINED=1 -Ithird_party/nanopb diff --git a/grpc.gyp b/grpc.gyp index ba847d99548..1e0a0f766ee 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -55,7 +55,7 @@ '-Wall', '-Wextra', '-Werror', - '-Wno-unknown-warning-option', + '$(W_NO_UNKNOWN_WARNING_OPTION)', '-Wno-long-long', '-Wno-unused-parameter', '-Wno-deprecated-declarations', @@ -146,7 +146,7 @@ '-Wall', '-Wextra', '-Werror', - '-Wno-unknown-warning-option', + '$(W_NO_UNKNOWN_WARNING_OPTION)', '-Wno-long-long', '-Wno-unused-parameter', '-Wno-deprecated-declarations', @@ -168,7 +168,7 @@ '-Wall', '-Wextra', '-Werror', - '-Wno-unknown-warning-option', + '$(W_NO_UNKNOWN_WARNING_OPTION)', '-Wno-long-long', '-Wno-unused-parameter', '-Wno-deprecated-declarations', diff --git a/templates/Makefile.template b/templates/Makefile.template index c7f8a05739e..89415fa69b5 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -37,7 +37,7 @@ # warnings we'd like, but that dont exist in all compilers PREFERRED_WARNINGS=['extra-semi'] - CHECK_WARNINGS=PREFERRED_WARNINGS + ['no-shift-negative-value', 'no-unused-but-set-variable', 'no-maybe-uninitialized'] + CHECK_WARNINGS=PREFERRED_WARNINGS + ['no-shift-negative-value', 'no-unused-but-set-variable', 'no-maybe-uninitialized', 'no-unknown-warning-option'] def warning_var(fmt, warning): return fmt % warning.replace('-', '_').replace('+', 'X').upper() diff --git a/test/build/no-unknown-warning-option.c b/test/build/no-unknown-warning-option.c new file mode 100644 index 00000000000..0c1771c7bbd --- /dev/null +++ b/test/build/no-unknown-warning-option.c @@ -0,0 +1,19 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +int main(void) {}