From 4f81ab38bf18aacdc5f2e2f2a82cf577989ae39b Mon Sep 17 00:00:00 2001 From: Cholerae Hu Date: Thu, 3 Aug 2017 20:55:01 -0700 Subject: [PATCH] Makefile: fix for GCC 7+ and clang 4+ Summary: maysamyabandeh IslamAbdelRahman PTAL Fix https://github.com/facebook/rocksdb/issues/2672 Signed-off-by: Cholerae Hu Closes https://github.com/facebook/rocksdb/pull/2681 Differential Revision: D5561515 Pulled By: ajkr fbshipit-source-id: 676187802ebd8a87a6c051bb565818a1bf89d0a9 --- Makefile | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Makefile b/Makefile index a01c74e95..fc413e1d6 100644 --- a/Makefile +++ b/Makefile @@ -255,6 +255,19 @@ default: all WARNING_FLAGS = -W -Wextra -Wall -Wsign-compare -Wshadow \ -Wno-unused-parameter +CCVERSION = $(shell $(CXX) -dumpversion) +CCNAME = $(shell $(CXX) --version | awk 'NR==1' | cut -f1 -d " ") + +ifeq ($(CCNAME), clang) +ifeq ($(CCVERSION), 4*) + CXXFLAGS += -faligned-new +endif +else +ifeq ($(CCVERSION), 7) + CXXFLAGS += -faligned-new +endif +endif + ifndef DISABLE_WARNING_AS_ERROR WARNING_FLAGS += -Werror endif