From 16872b82394d0671fbec4fa8d67f1a3a20aa42ea Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 25 Jan 2016 10:55:20 -0800 Subject: [PATCH 1/2] Fix *SAN compilation --- Makefile | 8 +++++++- templates/Makefile.template | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0dba95ea464..56515378e39 100644 --- a/Makefile +++ b/Makefile @@ -261,6 +261,12 @@ endif CXX11_CHECK_CMD = $(CXX) -std=c++11 -o $(TMPOUT) -c test/build/c++11.cc HAS_CXX11 = $(shell $(CXX11_CHECK_CMD) 2> /dev/null && echo true || echo false) +CHECK_NO_SHIFT_NEGATIVE_VALUE_CMD = $(CC) -std=c99 -Wno-shift-negative-value -o $(TMPOUT) -c test/build/empty.c +HAS_NO_SHIFT_NEGATIVE_VALUE = $(shell $(CHECK_NO_SHIFT_NEGATIVE_VALUE_CMD) 2> /dev/null && echo true || echo false) +ifeq ($(HAS_NO_SHIFT_NEGATIVE_VALUE),true) +W_NO_SHIFT_NEGATIVE_VALUE=-Wno-shift-negative-value +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 # cross-compiling, you can override these variables from GNU make's @@ -5486,7 +5492,7 @@ LIBZ_SRC = \ LIBZ_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBZ_SRC)))) -$(LIBZ_OBJS): CFLAGS := $(CFLAGS) -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-implicit-function-declaration -Wno-shift-negative-value -fvisibility=hidden +$(LIBZ_OBJS): CFLAGS := $(CFLAGS) -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-implicit-function-declaration $(W_NO_SHIFT_NEGATIVE_VALUE) -fvisibility=hidden $(LIBDIR)/$(CONFIG)/libz.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(LIBZ_OBJS) $(E) "[AR] Creating $@" diff --git a/templates/Makefile.template b/templates/Makefile.template index 5db2c4cbd8c..b52354c1a00 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -165,6 +165,12 @@ CXX11_CHECK_CMD = $(CXX) -std=c++11 -o $(TMPOUT) -c test/build/c++11.cc HAS_CXX11 = $(shell $(CXX11_CHECK_CMD) 2> /dev/null && echo true || echo false) + CHECK_NO_SHIFT_NEGATIVE_VALUE_CMD = $(CC) -std=c99 -Wno-shift-negative-value -o $(TMPOUT) -c test/build/empty.c + HAS_NO_SHIFT_NEGATIVE_VALUE = $(shell $(CHECK_NO_SHIFT_NEGATIVE_VALUE_CMD) 2> /dev/null && echo true || echo false) + ifeq ($(HAS_NO_SHIFT_NEGATIVE_VALUE),true) + W_NO_SHIFT_NEGATIVE_VALUE=-Wno-shift-negative-value + 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 # cross-compiling, you can override these variables from GNU make's @@ -1438,7 +1444,7 @@ $(LIB${lib.name.upper()}_OBJS): CXXFLAGS := -Ithird_party/boringssl/include $(CXXFLAGS) -fvisibility=hidden $(LIB${lib.name.upper()}_OBJS): CPPFLAGS += -DOPENSSL_NO_ASM -D_GNU_SOURCE % elif lib.zlib: - $(LIB${lib.name.upper()}_OBJS): CFLAGS := $(CFLAGS) -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-implicit-function-declaration -Wno-shift-negative-value -fvisibility=hidden + $(LIB${lib.name.upper()}_OBJS): CFLAGS := $(CFLAGS) -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-implicit-function-declaration $(W_NO_SHIFT_NEGATIVE_VALUE) -fvisibility=hidden % else: % endif From 82f3f0d1782558acd11fa4794d7351164bb0790c Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 25 Jan 2016 11:27:42 -0800 Subject: [PATCH 2/2] Fix compiler flags --- Makefile | 2 +- templates/Makefile.template | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 56515378e39..01ca6bf5944 100644 --- a/Makefile +++ b/Makefile @@ -261,7 +261,7 @@ endif CXX11_CHECK_CMD = $(CXX) -std=c++11 -o $(TMPOUT) -c test/build/c++11.cc HAS_CXX11 = $(shell $(CXX11_CHECK_CMD) 2> /dev/null && echo true || echo false) -CHECK_NO_SHIFT_NEGATIVE_VALUE_CMD = $(CC) -std=c99 -Wno-shift-negative-value -o $(TMPOUT) -c test/build/empty.c +CHECK_NO_SHIFT_NEGATIVE_VALUE_CMD = $(CC) -std=c99 -Werror -Wno-shift-negative-value -o $(TMPOUT) -c test/build/empty.c HAS_NO_SHIFT_NEGATIVE_VALUE = $(shell $(CHECK_NO_SHIFT_NEGATIVE_VALUE_CMD) 2> /dev/null && echo true || echo false) ifeq ($(HAS_NO_SHIFT_NEGATIVE_VALUE),true) W_NO_SHIFT_NEGATIVE_VALUE=-Wno-shift-negative-value diff --git a/templates/Makefile.template b/templates/Makefile.template index b52354c1a00..91f26a37d56 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -165,7 +165,7 @@ CXX11_CHECK_CMD = $(CXX) -std=c++11 -o $(TMPOUT) -c test/build/c++11.cc HAS_CXX11 = $(shell $(CXX11_CHECK_CMD) 2> /dev/null && echo true || echo false) - CHECK_NO_SHIFT_NEGATIVE_VALUE_CMD = $(CC) -std=c99 -Wno-shift-negative-value -o $(TMPOUT) -c test/build/empty.c + CHECK_NO_SHIFT_NEGATIVE_VALUE_CMD = $(CC) -std=c99 -Werror -Wno-shift-negative-value -o $(TMPOUT) -c test/build/empty.c HAS_NO_SHIFT_NEGATIVE_VALUE = $(shell $(CHECK_NO_SHIFT_NEGATIVE_VALUE_CMD) 2> /dev/null && echo true || echo false) ifeq ($(HAS_NO_SHIFT_NEGATIVE_VALUE),true) W_NO_SHIFT_NEGATIVE_VALUE=-Wno-shift-negative-value