blob: 35d077ca65bfa7081fc3178f022709d22ebdeb1c [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
Vishwath Mohan23b2d2e2017-10-31 02:25:16 -070037# Disable global CFI in excluded paths
38ifneq ($(filter cfi, $(my_global_sanitize)),)
39 combined_exclude_paths := $(CFI_EXCLUDE_PATHS) \
40 $(PRODUCT_CFI_EXCLUDE_PATHS)
41
42 ifneq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_exclude_paths)),\
43 $(filter $(dir)%,$(LOCAL_PATH)))),)
44 my_global_sanitize := $(filter-out cfi,$(my_global_sanitize))
45 my_global_sanitize_diag := $(filter-out cfi,$(my_global_sanitize_diag))
46 endif
47endif
48
Dan Albert4c401412015-08-19 20:13:33 -070049ifneq ($(my_global_sanitize),)
Evgenii Stepanov71faa192016-05-19 17:45:21 -070050 my_sanitize := $(my_global_sanitize) $(my_sanitize)
Dan Albert4c401412015-08-19 20:13:33 -070051endif
Ivan Lozano4a363732017-06-28 09:11:26 -070052ifneq ($(my_global_sanitize_diag),)
53 my_sanitize_diag := $(my_global_sanitize_diag) $(my_sanitize_diag)
54endif
Dan Albert4c401412015-08-19 20:13:33 -070055
Andreas Gampe6b30d772016-06-27 15:15:31 -070056# The sanitizer specified in the product configuration wins over the previous.
57ifneq ($(SANITIZER.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG),)
58 my_sanitize := $(SANITIZER.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG)
59 ifeq ($(my_sanitize),never)
60 my_sanitize :=
Ivan Lozano4a363732017-06-28 09:11:26 -070061 my_sanitize_diag :=
Andreas Gampe6b30d772016-06-27 15:15:31 -070062 endif
63endif
64
Colin Cross23618422016-11-02 15:05:21 -070065ifndef LOCAL_IS_HOST_MODULE
66 # Add a filter point for 32-bit vs 64-bit sanitization (to lighten the burden)
67 SANITIZE_TARGET_ARCH ?= $(TARGET_ARCH) $(TARGET_2ND_ARCH)
68 ifeq ($(filter $(SANITIZE_TARGET_ARCH),$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)),)
69 my_sanitize :=
Ivan Lozano4a363732017-06-28 09:11:26 -070070 my_sanitize_diag :=
Colin Cross23618422016-11-02 15:05:21 -070071 endif
Andreas Gampecd257402016-06-20 17:36:49 -070072endif
73
Andreas Gampe3d3b0c92016-06-20 17:46:29 -070074# Add a filter point based on module owner (to lighten the burden). The format is a space- or
75# colon-separated list of owner names.
76ifneq (,$(SANITIZE_NEVER_BY_OWNER))
77 ifneq (,$(LOCAL_MODULE_OWNER))
78 ifneq (,$(filter $(LOCAL_MODULE_OWNER),$(subst :, ,$(SANITIZE_NEVER_BY_OWNER))))
79 $(warning Not sanitizing $(LOCAL_MODULE) based on module owner.)
80 my_sanitize :=
Ivan Lozano4a363732017-06-28 09:11:26 -070081 my_sanitize_diag :=
Andreas Gampe3d3b0c92016-06-20 17:46:29 -070082 endif
83 endif
84endif
85
Dan Albert08cca282014-12-11 18:56:26 -080086# Don't apply sanitizers to NDK code.
87ifdef LOCAL_SDK_VERSION
Dan Albert4c401412015-08-19 20:13:33 -070088 my_sanitize :=
Dan Willemsenf761c0f2016-06-28 16:47:43 -070089 my_global_sanitize :=
Ivan Lozano4a363732017-06-28 09:11:26 -070090 my_sanitize_diag :=
Dan Albert27ccb752015-04-16 16:21:02 -070091endif
92
Dan Albert4c401412015-08-19 20:13:33 -070093# Never always wins.
94ifeq ($(LOCAL_SANITIZE),never)
Dan Albert08cca282014-12-11 18:56:26 -080095 my_sanitize :=
Ivan Lozano4a363732017-06-28 09:11:26 -070096 my_sanitize_diag :=
Dan Albert08cca282014-12-11 18:56:26 -080097endif
98
Vishwath Mohan23b2d2e2017-10-31 02:25:16 -070099# Enable CFI in included paths.
100ifeq ($(filter cfi, $(my_sanitize)),)
101 combined_include_paths := $(CFI_INCLUDE_PATHS) \
102 $(PRODUCT_CFI_INCLUDE_PATHS)
103
104 ifneq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_include_paths)),\
105 $(filter $(dir)%,$(LOCAL_PATH)))),)
106 my_sanitize := cfi $(my_sanitize)
107 my_sanitize_diag := cfi $(my_sanitize_diag)
108 endif
109endif
110
Vishwath Mohan8dcfdce2017-01-18 17:50:29 -0800111# If CFI is disabled globally, remove it from my_sanitize.
Vishwath Mohan45665b42017-01-24 13:20:28 -0800112ifeq ($(strip $(ENABLE_CFI)),false)
Vishwath Mohan8dcfdce2017-01-18 17:50:29 -0800113 my_sanitize := $(filter-out cfi,$(my_sanitize))
114 my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
115endif
116
Vishwath Mohana2046062017-02-07 20:28:07 -0800117# Disable CFI for arm32 (b/35157333).
118ifneq ($(filter arm,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)),)
119 my_sanitize := $(filter-out cfi,$(my_sanitize))
120 my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
121endif
122
Vishwath Mohanc026f6d2017-04-20 07:39:13 -0700123# Also disable CFI if ASAN is enabled.
124ifneq ($(filter address,$(my_sanitize)),)
125 my_sanitize := $(filter-out cfi,$(my_sanitize))
126 my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
127endif
128
Evgenii Stepanov8c50e3c2017-01-31 17:08:33 -0800129# CFI needs gold linker, and mips toolchain does not have one.
130ifneq ($(filter mips mips64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)),)
131 my_sanitize := $(filter-out cfi,$(my_sanitize))
132 my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
133endif
134
Vishwath Mohan96a130b2017-11-17 11:19:36 -0800135# Disable CFI for host targets
136ifdef LOCAL_IS_HOST_MODULE
137 my_sanitize := $(filter-out cfi,$(my_sanitize))
138 my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
139endif
140
Ivan Lozano4a363732017-06-28 09:11:26 -0700141# Support for local sanitize blacklist paths.
142ifneq ($(my_sanitize)$(my_global_sanitize),)
143 ifneq ($(LOCAL_SANITIZE_BLACKLIST),)
144 my_cflags += -fsanitize-blacklist=$(LOCAL_PATH)/$(LOCAL_SANITIZE_BLACKLIST)
145 endif
146endif
147
Ivan Lozanob4749cb2017-07-21 10:33:32 -0700148# Disable integer_overflow if LOCAL_NOSANITIZE=integer.
Ivan Lozano4a363732017-06-28 09:11:26 -0700149ifneq ($(filter integer_overflow, $(my_global_sanitize) $(my_sanitize)),)
150 ifneq ($(filter integer, $(strip $(LOCAL_NOSANITIZE))),)
151 my_sanitize := $(filter-out integer_overflow,$(my_sanitize))
152 my_sanitize_diag := $(filter-out integer_overflow,$(my_sanitize_diag))
153 endif
154endif
155
Evgenii Stepanov42823662016-05-12 13:07:17 -0700156my_nosanitize = $(strip $(LOCAL_NOSANITIZE))
157ifneq ($(my_nosanitize),)
158 my_sanitize := $(filter-out $(my_nosanitize),$(my_sanitize))
159endif
160
Dan Alberta6311b72015-07-30 10:17:33 -0700161# TSAN is not supported on 32-bit architectures. For non-multilib cases, make
162# its use an error. For multilib cases, don't use it for the 32-bit case.
163ifneq ($(filter thread,$(my_sanitize)),)
164 ifeq ($(my_32_64_bit_suffix),32)
165 ifeq ($(my_module_multilib),both)
166 my_sanitize := $(filter-out thread,$(my_sanitize))
167 else
168 $(error $(LOCAL_PATH): $(LOCAL_MODULE): TSAN cannot be used for 32-bit modules.)
169 endif
Yabin Cuie77c32e2017-10-19 14:33:58 -0700170 else
171 my_shared_libraries += $(TSAN_RUNTIME_LIBRARY)
Dan Alberta6311b72015-07-30 10:17:33 -0700172 endif
173endif
174
Evgenii Stepanov7dcb8b82016-05-06 18:15:57 -0700175ifneq ($(filter safe-stack,$(my_sanitize)),)
176 ifeq ($(my_32_64_bit_suffix),32)
177 my_sanitize := $(filter-out safe-stack,$(my_sanitize))
178 endif
179endif
180
Evgenii Stepanov5adfcb12015-06-25 16:38:25 -0700181# Undefined symbols can occur if a non-sanitized library links
182# sanitized static libraries. That's OK, because the executable
183# always depends on the ASan runtime library, which defines these
184# symbols.
Evgenii Stepanov912b51f2016-05-19 17:49:51 -0700185ifneq ($(filter address thread,$(strip $(SANITIZE_TARGET))),)
Evgenii Stepanov5adfcb12015-06-25 16:38:25 -0700186 ifndef LOCAL_IS_HOST_MODULE
187 ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
188 ifeq ($(my_sanitize),)
189 my_allow_undefined_symbols := true
190 endif
191 endif
192 endif
193endif
194
Dan Albert94b57912015-04-17 09:48:33 -0700195# Sanitizers can only be used with clang.
196ifneq ($(my_clang),true)
197 ifneq ($(my_sanitize),)
198 $(error $(LOCAL_PATH): $(LOCAL_MODULE): Use of sanitizers requires LOCAL_CLANG := true)
199 endif
200endif
201
Dan Albertb5b2ffe2015-04-16 18:07:07 -0700202ifneq ($(filter default-ub,$(my_sanitize)),)
203 my_sanitize := $(CLANG_DEFAULT_UB_CHECKS)
Dan Albert08cca282014-12-11 18:56:26 -0800204endif
205
Ivan Krasin74b32b82015-09-18 11:54:43 -0700206ifneq ($(filter coverage,$(my_sanitize)),)
207 ifeq ($(filter address,$(my_sanitize)),)
208 $(error $(LOCAL_PATH): $(LOCAL_MODULE): Use of 'coverage' also requires 'address')
209 endif
Zach Rigglebe0811f2017-08-21 17:07:42 -0400210 my_cflags += -fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp
Ivan Krasin74b32b82015-09-18 11:54:43 -0700211 my_sanitize := $(filter-out coverage,$(my_sanitize))
212endif
213
Ivan Lozano4a363732017-06-28 09:11:26 -0700214ifneq ($(filter integer_overflow,$(my_sanitize)),)
215 ifneq ($(filter SHARED_LIBRARIES EXECUTABLES,$(LOCAL_MODULE_CLASS)),)
216 ifneq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
217
218 # Respect LOCAL_NOSANITIZE for integer-overflow flags.
219 ifeq ($(filter signed-integer-overflow, $(strip $(LOCAL_NOSANITIZE))),)
Ivan Lozano911cb992018-02-21 13:41:05 -0800220 my_sanitize += signed-integer-overflow
Ivan Lozano4a363732017-06-28 09:11:26 -0700221 endif
222 ifeq ($(filter unsigned-integer-overflow, $(strip $(LOCAL_NOSANITIZE))),)
Ivan Lozano911cb992018-02-21 13:41:05 -0800223 my_sanitize += unsigned-integer-overflow
Ivan Lozano4a363732017-06-28 09:11:26 -0700224 endif
Ivan Lozano4a363732017-06-28 09:11:26 -0700225 my_cflags += $(INTEGER_OVERFLOW_EXTRA_CFLAGS)
226
Ivan Lozanoc5ef21f2018-01-20 01:44:11 +0000227 # Check for diagnostics mode (on by default).
Ivan Lozano4a363732017-06-28 09:11:26 -0700228 ifneq ($(filter integer_overflow,$(my_sanitize_diag)),)
Ivan Lozano911cb992018-02-21 13:41:05 -0800229 my_sanitize_diag += signed-integer-overflow
230 my_sanitize_diag += unsigned-integer-overflow
Ivan Lozano4a363732017-06-28 09:11:26 -0700231 endif
232 endif
233 endif
234 my_sanitize := $(filter-out integer_overflow,$(my_sanitize))
235endif
236
237# Makes sure integer_overflow diagnostics is removed from the diagnostics list
238# even if integer_overflow is not set for some reason.
239ifneq ($(filter integer_overflow,$(my_sanitize_diag)),)
240 my_sanitize_diag := $(filter-out integer_overflow,$(my_sanitize_diag))
241endif
242
Dan Albert08cca282014-12-11 18:56:26 -0800243ifneq ($(my_sanitize),)
Stephen Hinese8119e92015-11-09 16:32:11 -0800244 fsanitize_arg := $(subst $(space),$(comma),$(my_sanitize))
Dan Albert08cca282014-12-11 18:56:26 -0800245 my_cflags += -fsanitize=$(fsanitize_arg)
246
247 ifdef LOCAL_IS_HOST_MODULE
Dan Albertabf4bc92015-06-16 23:27:34 -0700248 my_cflags += -fno-sanitize-recover=all
Dan Albert08cca282014-12-11 18:56:26 -0800249 my_ldflags += -fsanitize=$(fsanitize_arg)
Dan Albertabf4bc92015-06-16 23:27:34 -0700250 else
Evgenii Stepanov71faa192016-05-19 17:45:21 -0700251 my_cflags += -fsanitize-trap=all
252 my_cflags += -ftrap-function=abort
Evgenii Stepanov55f73e62016-05-12 13:07:36 -0700253 ifneq ($(filter address thread,$(my_sanitize)),)
Evgenii Stepanov71faa192016-05-19 17:45:21 -0700254 my_cflags += -fno-sanitize-trap=address,thread
Evgenii Stepanov55f73e62016-05-12 13:07:36 -0700255 my_shared_libraries += libdl
256 endif
Dan Albert08cca282014-12-11 18:56:26 -0800257 endif
258endif
259
Evgenii Stepanov202c7a72016-07-07 10:56:39 -0700260ifneq ($(filter cfi,$(my_sanitize)),)
Evgenii Stepanov81bea1b2017-01-20 14:12:08 -0800261 # __cfi_check needs to be built as Thumb (see the code in linker_cfi.cpp).
262 # LLVM is not set up to do this on a function basis, so force Thumb on the
263 # entire module.
264 LOCAL_ARM_MODE := thumb
Vishwath Mohan5b69c062017-02-14 07:55:37 -0800265 my_cflags += $(CFI_EXTRA_CFLAGS)
Vishwath Mohan85f72442017-11-01 09:21:20 +0000266 # Only append the default visibility flag if -fvisibility has not already been
267 # set to hidden.
268 ifeq ($(filter -fvisibility=hidden,$(LOCAL_CFLAGS)),)
269 my_cflags += -fvisibility=default
270 endif
Vishwath Mohan5b69c062017-02-14 07:55:37 -0800271 my_ldflags += $(CFI_EXTRA_LDFLAGS)
Evgenii Stepanove1b96f32017-01-23 16:57:38 -0800272 my_arflags += --plugin $(LLVM_PREBUILTS_PATH)/../lib64/LLVMgold.so
Vishwath Mohan85f72442017-11-01 09:21:20 +0000273
274 ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
275 my_ldflags := $(filter-out -fsanitize-cfi-cross-dso,$(my_ldflags))
276 my_cflags := $(filter-out -fsanitize-cfi-cross-dso,$(my_cflags))
277 else
278 # Apply the version script to non-static executables
279 my_ldflags += -Wl,--version-script,build/soong/cc/config/cfi_exports.map
280 LOCAL_ADDITIONAL_DEPENDENCIES += build/soong/cc/config/cfi_exports.map
281 endif
Evgenii Stepanov202c7a72016-07-07 10:56:39 -0700282endif
283
Chih-Hung Hsiehad741e62016-03-09 14:54:55 -0800284# If local or global modules need ASAN, add linker flags.
285ifneq ($(filter address,$(my_global_sanitize) $(my_sanitize)),)
Dan Albert4ae5d4b2014-10-31 16:23:08 -0700286 my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS)
287 ifdef LOCAL_IS_HOST_MODULE
Dan Albert08cca282014-12-11 18:56:26 -0800288 # -nodefaultlibs (provided with libc++) prevents the driver from linking
289 # libraries needed with -fsanitize=address. http://b/18650275 (WAI)
Dan Albert1f0d5302015-04-28 14:55:50 -0700290 my_ldflags += -Wl,--no-as-needed
Dan Albert4ae5d4b2014-10-31 16:23:08 -0700291 else
Chih-Hung Hsiehad741e62016-03-09 14:54:55 -0800292 # Add asan libraries unless LOCAL_MODULE is the asan library.
Evgenii Stepanovf0b15e12015-04-24 16:34:47 -0700293 # ASan runtime library must be the first in the link order.
Chih-Hung Hsiehad741e62016-03-09 14:54:55 -0800294 ifeq (,$(filter $(LOCAL_MODULE),$($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_RUNTIME_LIBRARY)))
295 my_shared_libraries := $($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_RUNTIME_LIBRARY) \
296 $(my_shared_libraries)
297 endif
298 ifeq (,$(filter $(LOCAL_MODULE),$(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)))
299 my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)
300 endif
301
302 # Do not add unnecessary dependency in shared libraries.
303 ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
304 my_ldflags += -Wl,--as-needed
305 endif
Ying Wanga05e2222015-08-17 16:13:24 -0700306
Colin Crossd08699e2016-07-17 15:28:07 -0700307 ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
308 ifneq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
309 my_linker := $($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_LINKER)
310 # Make sure linker_asan get installed.
311 $(LOCAL_INSTALLED_MODULE) : | $(PRODUCT_OUT)$($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_LINKER)
312 endif
313 endif
Dan Albert08cca282014-12-11 18:56:26 -0800314 endif
315endif
316
Chih-Hung Hsiehad741e62016-03-09 14:54:55 -0800317# If local module needs ASAN, add compiler flags.
318ifneq ($(filter address,$(my_sanitize)),)
319 # Frame pointer based unwinder in ASan requires ARM frame setup.
320 LOCAL_ARM_MODE := arm
321 my_cflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS)
322 ifndef LOCAL_IS_HOST_MODULE
323 my_cflags += -mllvm -asan-globals=0
324 endif
325endif
326
Ivan Lozano911cb992018-02-21 13:41:05 -0800327# Use minimal diagnostics when integer overflow is enabled
328ifndef LOCAL_IS_HOST_MODULE
329 # Pre-emptively add UBSAN minimal runtime incase a static library dependency requires it
330 ifeq ($(filter STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
331 ifndef LOCAL_SDK_VERSION
332 my_static_libraries += $($(LOCAL_2ND_ARCH_VAR_PREFIX)UBSAN_MINIMAL_RUNTIME_LIBRARY)
333 endif
334 endif
335 ifneq ($(filter unsigned-integer-overflow signed-integer-overflow integer,$(my_sanitize)),)
336 ifeq ($(filter unsigned-integer-overflow signed-integer overflow integer,$(my_sanitize_diag)),)
337 ifeq ($(filter cfi,$(my_sanitize_diag)),)
338 ifeq ($(filter address,$(my_sanitize)),)
339 my_cflags += -fsanitize-minimal-runtime
340 my_cflags += -fno-sanitize-trap=integer
341 my_cflags += -fno-sanitize-recover=integer
342 endif
343 endif
344 endif
345 endif
346endif
347
Dan Albert9f176552015-04-28 11:26:45 -0700348ifneq ($(strip $(LOCAL_SANITIZE_RECOVER)),)
349 recover_arg := $(subst $(space),$(comma),$(LOCAL_SANITIZE_RECOVER)),
Dan Albert4111d482015-04-16 18:08:44 -0700350 my_cflags += -fsanitize-recover=$(recover_arg)
351endif
Evgenii Stepanov202c7a72016-07-07 10:56:39 -0700352
Vishwath Mohan8dcfdce2017-01-18 17:50:29 -0800353ifneq ($(my_sanitize_diag),)
Vishwath Mohan85f72442017-11-01 09:21:20 +0000354 # TODO(vishwath): Add diagnostic support for static executables once
355 # we switch to clang-4393122 (which adds the static ubsan runtime
356 # that this depends on)
357 ifneq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
358 notrap_arg := $(subst $(space),$(comma),$(my_sanitize_diag)),
359 my_cflags += -fno-sanitize-trap=$(notrap_arg)
360 # Diagnostic requires a runtime library, unless ASan or TSan are also enabled.
361 ifeq ($(filter address thread,$(my_sanitize)),)
362 # Does not have to be the first DT_NEEDED unlike ASan.
363 my_shared_libraries += $($(LOCAL_2ND_ARCH_VAR_PREFIX)UBSAN_RUNTIME_LIBRARY)
364 endif
Evgenii Stepanov202c7a72016-07-07 10:56:39 -0700365 endif
366endif