blob: 2064d8dda3e535fbb177f53e63b6e16412f0760a [file] [log] [blame]
Dan Albert4ae5d4b2014-10-31 16:23:08 -07001##############################################
2## Perform configuration steps for sanitizers.
3##############################################
4
Dan Albert27ccb752015-04-16 16:21:02 -07005my_sanitize := $(strip $(LOCAL_SANITIZE))
Vishwath Mohan8dcfdce2017-01-18 17:50:29 -08006my_sanitize_diag := $(strip $(LOCAL_SANITIZE_DIAG))
Dan Albert08cca282014-12-11 18:56:26 -08007
Dan Albert4c401412015-08-19 20:13:33 -07008# SANITIZE_HOST is only in effect if the module is already using clang (host
9# modules that haven't set `LOCAL_CLANG := false` and device modules that
10# have set `LOCAL_CLANG := true`.
11my_global_sanitize :=
Ivan Lozano4a363732017-06-28 09:11:26 -070012my_global_sanitize_diag :=
Dan Albert4c401412015-08-19 20:13:33 -070013ifeq ($(my_clang),true)
14 ifdef LOCAL_IS_HOST_MODULE
15 my_global_sanitize := $(strip $(SANITIZE_HOST))
16
17 # SANITIZE_HOST=true is a deprecated way to say SANITIZE_HOST=address.
18 my_global_sanitize := $(subst true,address,$(my_global_sanitize))
19 else
20 my_global_sanitize := $(strip $(SANITIZE_TARGET))
Ivan Lozano4a363732017-06-28 09:11:26 -070021 my_global_sanitize_diag := $(strip $(SANITIZE_TARGET_DIAG))
Dan Albert4c401412015-08-19 20:13:33 -070022 endif
23endif
24
Ivan Lozanob4749cb2017-07-21 10:33:32 -070025# Disable global integer_overflow in excluded paths.
26ifneq ($(filter integer_overflow, $(my_global_sanitize)),)
27 combined_exclude_paths := $(INTEGER_OVERFLOW_EXCLUDE_PATHS) \
28 $(PRODUCT_INTEGER_OVERFLOW_EXCLUDE_PATHS)
29
30 ifneq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_exclude_paths)),\
31 $(filter $(dir)%,$(LOCAL_PATH)))),)
32 my_global_sanitize := $(filter-out integer_overflow,$(my_global_sanitize))
33 my_global_sanitize_diag := $(filter-out integer_overflow,$(my_global_sanitize_diag))
34 endif
35endif
36
Ivan Lozanoc2d7db12018-01-09 09:56:54 -080037# Enable integer overflow sanitizer in included paths.
38# (includes override excludes)
39ifeq ($(my_clang),true)
40 ifndef LOCAL_IS_HOST_MODULE
41 ifeq ($(filter integer_overflow, $(my_sanitize)),)
42 combined_include_paths := $(DEFAULT_INTEGER_OVERFLOW_PATHS) \
43 $(INTEGER_OVERFLOW_INCLUDE_PATHS) \
44 $(PRODUCT_INTEGER_OVERFLOW_INCLUDE_PATHS)
45 ifneq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_include_paths)),\
46 $(filter $(dir)%,$(LOCAL_PATH)))),)
47 my_global_sanitize := integer_overflow $(my_sanitize)
48 # Ensure default paths do not run in diagnostics unless SANITIZE_TARGET_DIAG
49 ifneq ($(filter integer_overflow, $(SANITIZE_TARGET_DIAG)),)
50 my_global_sanitize_diag := integer_overflow $(my_sanitize_diag)
51 endif
52 endif
53 endif
54 endif
55endif
56
Vishwath Mohan23b2d2e2017-10-31 02:25:16 -070057# Disable global CFI in excluded paths
58ifneq ($(filter cfi, $(my_global_sanitize)),)
59 combined_exclude_paths := $(CFI_EXCLUDE_PATHS) \
60 $(PRODUCT_CFI_EXCLUDE_PATHS)
61
62 ifneq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_exclude_paths)),\
63 $(filter $(dir)%,$(LOCAL_PATH)))),)
64 my_global_sanitize := $(filter-out cfi,$(my_global_sanitize))
65 my_global_sanitize_diag := $(filter-out cfi,$(my_global_sanitize_diag))
66 endif
67endif
68
Dan Albert4c401412015-08-19 20:13:33 -070069ifneq ($(my_global_sanitize),)
Evgenii Stepanov71faa192016-05-19 17:45:21 -070070 my_sanitize := $(my_global_sanitize) $(my_sanitize)
Dan Albert4c401412015-08-19 20:13:33 -070071endif
Ivan Lozano4a363732017-06-28 09:11:26 -070072ifneq ($(my_global_sanitize_diag),)
73 my_sanitize_diag := $(my_global_sanitize_diag) $(my_sanitize_diag)
74endif
Dan Albert4c401412015-08-19 20:13:33 -070075
Andreas Gampe6b30d772016-06-27 15:15:31 -070076# The sanitizer specified in the product configuration wins over the previous.
77ifneq ($(SANITIZER.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG),)
78 my_sanitize := $(SANITIZER.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG)
79 ifeq ($(my_sanitize),never)
80 my_sanitize :=
Ivan Lozano4a363732017-06-28 09:11:26 -070081 my_sanitize_diag :=
Andreas Gampe6b30d772016-06-27 15:15:31 -070082 endif
83endif
84
Colin Cross23618422016-11-02 15:05:21 -070085ifndef LOCAL_IS_HOST_MODULE
86 # Add a filter point for 32-bit vs 64-bit sanitization (to lighten the burden)
87 SANITIZE_TARGET_ARCH ?= $(TARGET_ARCH) $(TARGET_2ND_ARCH)
88 ifeq ($(filter $(SANITIZE_TARGET_ARCH),$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)),)
89 my_sanitize :=
Ivan Lozano4a363732017-06-28 09:11:26 -070090 my_sanitize_diag :=
Colin Cross23618422016-11-02 15:05:21 -070091 endif
Andreas Gampecd257402016-06-20 17:36:49 -070092endif
93
Andreas Gampe3d3b0c92016-06-20 17:46:29 -070094# Add a filter point based on module owner (to lighten the burden). The format is a space- or
95# colon-separated list of owner names.
96ifneq (,$(SANITIZE_NEVER_BY_OWNER))
97 ifneq (,$(LOCAL_MODULE_OWNER))
98 ifneq (,$(filter $(LOCAL_MODULE_OWNER),$(subst :, ,$(SANITIZE_NEVER_BY_OWNER))))
99 $(warning Not sanitizing $(LOCAL_MODULE) based on module owner.)
100 my_sanitize :=
Ivan Lozano4a363732017-06-28 09:11:26 -0700101 my_sanitize_diag :=
Andreas Gampe3d3b0c92016-06-20 17:46:29 -0700102 endif
103 endif
104endif
105
Dan Albert08cca282014-12-11 18:56:26 -0800106# Don't apply sanitizers to NDK code.
107ifdef LOCAL_SDK_VERSION
Dan Albert4c401412015-08-19 20:13:33 -0700108 my_sanitize :=
Dan Willemsenf761c0f2016-06-28 16:47:43 -0700109 my_global_sanitize :=
Ivan Lozano4a363732017-06-28 09:11:26 -0700110 my_sanitize_diag :=
Dan Albert27ccb752015-04-16 16:21:02 -0700111endif
112
Dan Albert4c401412015-08-19 20:13:33 -0700113# Never always wins.
114ifeq ($(LOCAL_SANITIZE),never)
Dan Albert08cca282014-12-11 18:56:26 -0800115 my_sanitize :=
Ivan Lozano4a363732017-06-28 09:11:26 -0700116 my_sanitize_diag :=
Dan Albert08cca282014-12-11 18:56:26 -0800117endif
118
Vishwath Mohan23b2d2e2017-10-31 02:25:16 -0700119# Enable CFI in included paths.
120ifeq ($(filter cfi, $(my_sanitize)),)
121 combined_include_paths := $(CFI_INCLUDE_PATHS) \
122 $(PRODUCT_CFI_INCLUDE_PATHS)
123
124 ifneq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_include_paths)),\
125 $(filter $(dir)%,$(LOCAL_PATH)))),)
126 my_sanitize := cfi $(my_sanitize)
127 my_sanitize_diag := cfi $(my_sanitize_diag)
128 endif
129endif
130
Vishwath Mohan8dcfdce2017-01-18 17:50:29 -0800131# If CFI is disabled globally, remove it from my_sanitize.
Vishwath Mohan45665b42017-01-24 13:20:28 -0800132ifeq ($(strip $(ENABLE_CFI)),false)
Vishwath Mohan8dcfdce2017-01-18 17:50:29 -0800133 my_sanitize := $(filter-out cfi,$(my_sanitize))
134 my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
135endif
136
Vishwath Mohana2046062017-02-07 20:28:07 -0800137# Disable CFI for arm32 (b/35157333).
138ifneq ($(filter arm,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)),)
139 my_sanitize := $(filter-out cfi,$(my_sanitize))
140 my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
141endif
142
Vishwath Mohanc026f6d2017-04-20 07:39:13 -0700143# Also disable CFI if ASAN is enabled.
144ifneq ($(filter address,$(my_sanitize)),)
145 my_sanitize := $(filter-out cfi,$(my_sanitize))
146 my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
147endif
148
Evgenii Stepanov8c50e3c2017-01-31 17:08:33 -0800149# CFI needs gold linker, and mips toolchain does not have one.
150ifneq ($(filter mips mips64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)),)
151 my_sanitize := $(filter-out cfi,$(my_sanitize))
152 my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
153endif
154
Vishwath Mohan96a130b2017-11-17 11:19:36 -0800155# Disable CFI for host targets
156ifdef LOCAL_IS_HOST_MODULE
157 my_sanitize := $(filter-out cfi,$(my_sanitize))
158 my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
159endif
160
Ivan Lozano4a363732017-06-28 09:11:26 -0700161# Support for local sanitize blacklist paths.
162ifneq ($(my_sanitize)$(my_global_sanitize),)
163 ifneq ($(LOCAL_SANITIZE_BLACKLIST),)
164 my_cflags += -fsanitize-blacklist=$(LOCAL_PATH)/$(LOCAL_SANITIZE_BLACKLIST)
165 endif
166endif
167
Ivan Lozanob4749cb2017-07-21 10:33:32 -0700168# Disable integer_overflow if LOCAL_NOSANITIZE=integer.
Ivan Lozano4a363732017-06-28 09:11:26 -0700169ifneq ($(filter integer_overflow, $(my_global_sanitize) $(my_sanitize)),)
170 ifneq ($(filter integer, $(strip $(LOCAL_NOSANITIZE))),)
171 my_sanitize := $(filter-out integer_overflow,$(my_sanitize))
172 my_sanitize_diag := $(filter-out integer_overflow,$(my_sanitize_diag))
173 endif
174endif
175
Evgenii Stepanov42823662016-05-12 13:07:17 -0700176my_nosanitize = $(strip $(LOCAL_NOSANITIZE))
177ifneq ($(my_nosanitize),)
178 my_sanitize := $(filter-out $(my_nosanitize),$(my_sanitize))
179endif
180
Dan Alberta6311b72015-07-30 10:17:33 -0700181# TSAN is not supported on 32-bit architectures. For non-multilib cases, make
182# its use an error. For multilib cases, don't use it for the 32-bit case.
183ifneq ($(filter thread,$(my_sanitize)),)
184 ifeq ($(my_32_64_bit_suffix),32)
185 ifeq ($(my_module_multilib),both)
186 my_sanitize := $(filter-out thread,$(my_sanitize))
187 else
188 $(error $(LOCAL_PATH): $(LOCAL_MODULE): TSAN cannot be used for 32-bit modules.)
189 endif
Yabin Cuie77c32e2017-10-19 14:33:58 -0700190 else
191 my_shared_libraries += $(TSAN_RUNTIME_LIBRARY)
Dan Alberta6311b72015-07-30 10:17:33 -0700192 endif
193endif
194
Evgenii Stepanov7dcb8b82016-05-06 18:15:57 -0700195ifneq ($(filter safe-stack,$(my_sanitize)),)
196 ifeq ($(my_32_64_bit_suffix),32)
197 my_sanitize := $(filter-out safe-stack,$(my_sanitize))
198 endif
199endif
200
Evgenii Stepanov5adfcb12015-06-25 16:38:25 -0700201# Undefined symbols can occur if a non-sanitized library links
202# sanitized static libraries. That's OK, because the executable
203# always depends on the ASan runtime library, which defines these
204# symbols.
Evgenii Stepanov912b51f2016-05-19 17:49:51 -0700205ifneq ($(filter address thread,$(strip $(SANITIZE_TARGET))),)
Evgenii Stepanov5adfcb12015-06-25 16:38:25 -0700206 ifndef LOCAL_IS_HOST_MODULE
207 ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
208 ifeq ($(my_sanitize),)
209 my_allow_undefined_symbols := true
210 endif
211 endif
212 endif
213endif
214
Dan Albert94b57912015-04-17 09:48:33 -0700215# Sanitizers can only be used with clang.
216ifneq ($(my_clang),true)
217 ifneq ($(my_sanitize),)
218 $(error $(LOCAL_PATH): $(LOCAL_MODULE): Use of sanitizers requires LOCAL_CLANG := true)
219 endif
220endif
221
Dan Albertb5b2ffe2015-04-16 18:07:07 -0700222ifneq ($(filter default-ub,$(my_sanitize)),)
223 my_sanitize := $(CLANG_DEFAULT_UB_CHECKS)
Dan Albert08cca282014-12-11 18:56:26 -0800224endif
225
Ivan Krasin74b32b82015-09-18 11:54:43 -0700226ifneq ($(filter coverage,$(my_sanitize)),)
227 ifeq ($(filter address,$(my_sanitize)),)
228 $(error $(LOCAL_PATH): $(LOCAL_MODULE): Use of 'coverage' also requires 'address')
229 endif
Zach Rigglebe0811f2017-08-21 17:07:42 -0400230 my_cflags += -fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp
Ivan Krasin74b32b82015-09-18 11:54:43 -0700231 my_sanitize := $(filter-out coverage,$(my_sanitize))
232endif
233
Ivan Lozanoc2d7db12018-01-09 09:56:54 -0800234# Use minimal diagnostics when integer overflow is enabled on userdebug and eng
235# and full diagnostics not enabled.
236ifneq ($(findstring integer,$(my_sanitize)),)
237 ifeq ($(findstring integer,$(my_sanitize_diag)),)
238 ifeq ($(filter address,$(my_sanitize)),)
239 # TODO(ivanlozano): uncomment after switch to clang-4536805
240 ifneq ($(filter $(TARGET_BUILD_VARIANT),userdebug eng),)
241 # my_cflags += -fsanitize-minimal-runtime
242 endif
243 endif
244 endif
245endif
246
Ivan Lozano4a363732017-06-28 09:11:26 -0700247ifneq ($(filter integer_overflow,$(my_sanitize)),)
248 ifneq ($(filter SHARED_LIBRARIES EXECUTABLES,$(LOCAL_MODULE_CLASS)),)
249 ifneq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
250
251 # Respect LOCAL_NOSANITIZE for integer-overflow flags.
252 ifeq ($(filter signed-integer-overflow, $(strip $(LOCAL_NOSANITIZE))),)
253 my_cflags += -fsanitize=signed-integer-overflow
254 endif
255 ifeq ($(filter unsigned-integer-overflow, $(strip $(LOCAL_NOSANITIZE))),)
256 my_cflags += -fsanitize=unsigned-integer-overflow
257 endif
258 my_cflags += -fsanitize-trap=all
259 my_cflags += -ftrap-function=abort
260 my_cflags += $(INTEGER_OVERFLOW_EXTRA_CFLAGS)
261
Ivan Lozanoc2d7db12018-01-09 09:56:54 -0800262 # Check for diagnostics mode.
Ivan Lozano4a363732017-06-28 09:11:26 -0700263 ifneq ($(filter integer_overflow,$(my_sanitize_diag)),)
264 my_cflags += -fno-sanitize-trap=signed-integer-overflow,unsigned-integer-overflow
265 my_shared_libraries := $($(LOCAL_2ND_ARCH_VAR_PREFIX)UBSAN_RUNTIME_LIBRARY) $(my_shared_libraries)
266 endif
267 endif
268 endif
269 my_sanitize := $(filter-out integer_overflow,$(my_sanitize))
270endif
271
272# Makes sure integer_overflow diagnostics is removed from the diagnostics list
273# even if integer_overflow is not set for some reason.
274ifneq ($(filter integer_overflow,$(my_sanitize_diag)),)
275 my_sanitize_diag := $(filter-out integer_overflow,$(my_sanitize_diag))
276endif
277
Dan Albert08cca282014-12-11 18:56:26 -0800278ifneq ($(my_sanitize),)
Stephen Hinese8119e92015-11-09 16:32:11 -0800279 fsanitize_arg := $(subst $(space),$(comma),$(my_sanitize))
Dan Albert08cca282014-12-11 18:56:26 -0800280 my_cflags += -fsanitize=$(fsanitize_arg)
281
282 ifdef LOCAL_IS_HOST_MODULE
Dan Albertabf4bc92015-06-16 23:27:34 -0700283 my_cflags += -fno-sanitize-recover=all
Dan Albert08cca282014-12-11 18:56:26 -0800284 my_ldflags += -fsanitize=$(fsanitize_arg)
Dan Albertabf4bc92015-06-16 23:27:34 -0700285 else
Evgenii Stepanov71faa192016-05-19 17:45:21 -0700286 my_cflags += -fsanitize-trap=all
287 my_cflags += -ftrap-function=abort
Evgenii Stepanov55f73e62016-05-12 13:07:36 -0700288 ifneq ($(filter address thread,$(my_sanitize)),)
Evgenii Stepanov71faa192016-05-19 17:45:21 -0700289 my_cflags += -fno-sanitize-trap=address,thread
Evgenii Stepanov55f73e62016-05-12 13:07:36 -0700290 my_shared_libraries += libdl
291 endif
Dan Albert08cca282014-12-11 18:56:26 -0800292 endif
293endif
294
Evgenii Stepanov202c7a72016-07-07 10:56:39 -0700295ifneq ($(filter cfi,$(my_sanitize)),)
Evgenii Stepanov81bea1b2017-01-20 14:12:08 -0800296 # __cfi_check needs to be built as Thumb (see the code in linker_cfi.cpp).
297 # LLVM is not set up to do this on a function basis, so force Thumb on the
298 # entire module.
299 LOCAL_ARM_MODE := thumb
Vishwath Mohan5b69c062017-02-14 07:55:37 -0800300 my_cflags += $(CFI_EXTRA_CFLAGS)
Vishwath Mohan85f72442017-11-01 09:21:20 +0000301 # Only append the default visibility flag if -fvisibility has not already been
302 # set to hidden.
303 ifeq ($(filter -fvisibility=hidden,$(LOCAL_CFLAGS)),)
304 my_cflags += -fvisibility=default
305 endif
Vishwath Mohan5b69c062017-02-14 07:55:37 -0800306 my_ldflags += $(CFI_EXTRA_LDFLAGS)
Evgenii Stepanove1b96f32017-01-23 16:57:38 -0800307 my_arflags += --plugin $(LLVM_PREBUILTS_PATH)/../lib64/LLVMgold.so
Vishwath Mohan85f72442017-11-01 09:21:20 +0000308
309 ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
310 my_ldflags := $(filter-out -fsanitize-cfi-cross-dso,$(my_ldflags))
311 my_cflags := $(filter-out -fsanitize-cfi-cross-dso,$(my_cflags))
312 else
313 # Apply the version script to non-static executables
314 my_ldflags += -Wl,--version-script,build/soong/cc/config/cfi_exports.map
315 LOCAL_ADDITIONAL_DEPENDENCIES += build/soong/cc/config/cfi_exports.map
316 endif
Evgenii Stepanov202c7a72016-07-07 10:56:39 -0700317endif
318
Chih-Hung Hsiehad741e62016-03-09 14:54:55 -0800319# If local or global modules need ASAN, add linker flags.
320ifneq ($(filter address,$(my_global_sanitize) $(my_sanitize)),)
Dan Albert4ae5d4b2014-10-31 16:23:08 -0700321 my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS)
322 ifdef LOCAL_IS_HOST_MODULE
Dan Albert08cca282014-12-11 18:56:26 -0800323 # -nodefaultlibs (provided with libc++) prevents the driver from linking
324 # libraries needed with -fsanitize=address. http://b/18650275 (WAI)
Dan Albert1f0d5302015-04-28 14:55:50 -0700325 my_ldflags += -Wl,--no-as-needed
Dan Albert4ae5d4b2014-10-31 16:23:08 -0700326 else
Chih-Hung Hsiehad741e62016-03-09 14:54:55 -0800327 # Add asan libraries unless LOCAL_MODULE is the asan library.
Evgenii Stepanovf0b15e12015-04-24 16:34:47 -0700328 # ASan runtime library must be the first in the link order.
Chih-Hung Hsiehad741e62016-03-09 14:54:55 -0800329 ifeq (,$(filter $(LOCAL_MODULE),$($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_RUNTIME_LIBRARY)))
330 my_shared_libraries := $($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_RUNTIME_LIBRARY) \
331 $(my_shared_libraries)
332 endif
333 ifeq (,$(filter $(LOCAL_MODULE),$(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)))
334 my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)
335 endif
336
337 # Do not add unnecessary dependency in shared libraries.
338 ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
339 my_ldflags += -Wl,--as-needed
340 endif
Ying Wanga05e2222015-08-17 16:13:24 -0700341
Colin Crossd08699e2016-07-17 15:28:07 -0700342 ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
343 ifneq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
344 my_linker := $($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_LINKER)
345 # Make sure linker_asan get installed.
346 $(LOCAL_INSTALLED_MODULE) : | $(PRODUCT_OUT)$($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_LINKER)
347 endif
348 endif
Dan Albert08cca282014-12-11 18:56:26 -0800349 endif
350endif
351
Chih-Hung Hsiehad741e62016-03-09 14:54:55 -0800352# If local module needs ASAN, add compiler flags.
353ifneq ($(filter address,$(my_sanitize)),)
354 # Frame pointer based unwinder in ASan requires ARM frame setup.
355 LOCAL_ARM_MODE := arm
356 my_cflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS)
357 ifndef LOCAL_IS_HOST_MODULE
358 my_cflags += -mllvm -asan-globals=0
359 endif
360endif
361
Dan Albert9f176552015-04-28 11:26:45 -0700362ifneq ($(strip $(LOCAL_SANITIZE_RECOVER)),)
363 recover_arg := $(subst $(space),$(comma),$(LOCAL_SANITIZE_RECOVER)),
Dan Albert4111d482015-04-16 18:08:44 -0700364 my_cflags += -fsanitize-recover=$(recover_arg)
365endif
Evgenii Stepanov202c7a72016-07-07 10:56:39 -0700366
Vishwath Mohan8dcfdce2017-01-18 17:50:29 -0800367ifneq ($(my_sanitize_diag),)
Vishwath Mohan85f72442017-11-01 09:21:20 +0000368 # TODO(vishwath): Add diagnostic support for static executables once
369 # we switch to clang-4393122 (which adds the static ubsan runtime
370 # that this depends on)
371 ifneq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
372 notrap_arg := $(subst $(space),$(comma),$(my_sanitize_diag)),
373 my_cflags += -fno-sanitize-trap=$(notrap_arg)
374 # Diagnostic requires a runtime library, unless ASan or TSan are also enabled.
375 ifeq ($(filter address thread,$(my_sanitize)),)
376 # Does not have to be the first DT_NEEDED unlike ASan.
377 my_shared_libraries += $($(LOCAL_2ND_ARCH_VAR_PREFIX)UBSAN_RUNTIME_LIBRARY)
378 endif
Evgenii Stepanov202c7a72016-07-07 10:56:39 -0700379 endif
380endif