From 505e4ec646d965e6ee730c5e4826a4dabe095ccb Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 14 Dec 2015 13:20:59 -0800 Subject: [PATCH] Be smarter about stack-protector on the host. Some projects are still built with our host GCC 4.8, which doesn't support -fstack-protector-strong. The combo .mk files are used by GCC and clang, so it's not safe to turn on -fstack-protector-strong there. Instead, do it in the clang-specific .mk for now. We can clean this up when elfutils (the last code built for the host with GCC that I'm aware of) is built by clang. We'll be able to remove the host GCC prebuilts too! Change-Id: I314b9eab071c132a8e2cb8cc779a75ae8abb12e2 --- core/clang/HOST_x86_common.mk | 4 ++++ core/combo/HOST_linux-x86.mk | 2 +- core/combo/HOST_linux-x86_64.mk | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/clang/HOST_x86_common.mk b/core/clang/HOST_x86_common.mk index fc98dd583..8b94209f0 100644 --- a/core/clang/HOST_x86_common.mk +++ b/core/clang/HOST_x86_common.mk @@ -6,6 +6,8 @@ CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_ASFLAGS := \ CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_CFLAGS := \ -integrated-as + +CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_CFLAGS += -fstack-protector-strong endif ifeq ($(HOST_OS),linux) @@ -16,6 +18,8 @@ CLANG_CONFIG_x86_LINUX_HOST_EXTRA_ASFLAGS := \ CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CFLAGS := \ --gcc-toolchain=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG) +CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CFLAGS += -fstack-protector-strong + ifneq ($(strip $($(clang_2nd_arch_prefix)HOST_IS_64_BIT)),) CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CPPFLAGS := \ --gcc-toolchain=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG) \ diff --git a/core/combo/HOST_linux-x86.mk b/core/combo/HOST_linux-x86.mk index 9f6510408..169e2d244 100644 --- a/core/combo/HOST_linux-x86.mk +++ b/core/combo/HOST_linux-x86.mk @@ -45,7 +45,7 @@ endif # BUILD_HOST_static $(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -fPIC \ -no-canonical-prefixes \ -$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong +$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector # Workaround differences in inttypes.h between host and target. # See bug 12708004. diff --git a/core/combo/HOST_linux-x86_64.mk b/core/combo/HOST_linux-x86_64.mk index cd04e4e2d..9766f2bde 100644 --- a/core/combo/HOST_linux-x86_64.mk +++ b/core/combo/HOST_linux-x86_64.mk @@ -44,7 +44,7 @@ endif # BUILD_HOST_static HOST_GLOBAL_CFLAGS += -fPIC \ -no-canonical-prefixes \ -HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong +HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector # Workaround differences in inttypes.h between host and target. # See bug 12708004.