From 4c40141a91c987551451d8d773c6a7b18f172fd7 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Wed, 19 Aug 2015 20:13:33 -0700 Subject: [PATCH] Fix sanitizer choice for global vs module. The sanitizer chosen by the environment (either by SANITIZE_TARGET or SANITIZE_HOST) should be chosen over the one specified by the module. Bug: http://b/23330588 Change-Id: I835b7d76e071fc0db2f859f98dfb9d7ff76af245 --- core/config_sanitizers.mk | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/core/config_sanitizers.mk b/core/config_sanitizers.mk index 8d285b1d8..1efc9324c 100644 --- a/core/config_sanitizers.mk +++ b/core/config_sanitizers.mk @@ -4,33 +4,33 @@ my_sanitize := $(strip $(LOCAL_SANITIZE)) -# Don't apply sanitizers to NDK code. -ifdef LOCAL_SDK_VERSION - my_sanitize := never -endif - -# Configure SANITIZE_HOST / SANITIZE_TARGET. -ifeq ($(my_sanitize),) +# SANITIZE_HOST is only in effect if the module is already using clang (host +# modules that haven't set `LOCAL_CLANG := false` and device modules that +# have set `LOCAL_CLANG := true`. +my_global_sanitize := +ifeq ($(my_clang),true) ifdef LOCAL_IS_HOST_MODULE - my_sanitize := $(strip $(SANITIZE_HOST)) + my_global_sanitize := $(strip $(SANITIZE_HOST)) + + # SANITIZE_HOST=true is a deprecated way to say SANITIZE_HOST=address. + my_global_sanitize := $(subst true,address,$(my_global_sanitize)) else - my_sanitize := $(strip $(SANITIZE_TARGET)) + my_global_sanitize := $(strip $(SANITIZE_TARGET)) endif +endif - # SANITIZE_HOST=true is a deprecated way to say SANITIZE_HOST=address. - ifeq ($(my_sanitize),true) - my_sanitize := address - endif +# The sanitizer specified by the environment wins over the module. +ifneq ($(my_global_sanitize),) + my_sanitize := $(my_global_sanitize) +endif - # SANITIZE_HOST is only in effect if the module is already using clang (host - # modules that haven't set `LOCAL_CLANG := false` and device modules that - # have set `LOCAL_CLANG := true`. - ifneq ($(my_clang),true) - my_sanitize := - endif +# Don't apply sanitizers to NDK code. +ifdef LOCAL_SDK_VERSION + my_sanitize := endif -ifeq ($(my_sanitize),never) +# Never always wins. +ifeq ($(LOCAL_SANITIZE),never) my_sanitize := endif -- 2.11.0