Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6874440 authored by Dan Albert's avatar Dan Albert Committed by Gerrit Code Review
Browse files

Merge "Add support for a partial ubsan build."

parents e3aa1c1f b5b2ffe3
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -98,6 +98,32 @@ CLANG_CONFIG_TARGET_EXTRA_CFLAGS := -nostdlibinc
CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS := -nostdlibinc
CLANG_CONFIG_TARGET_EXTRA_LDFLAGS :=

CLANG_DEFAULT_UB_CHECKS := \
  bool \
  integer-divide-by-zero \
  return \
  returns-nonnull-attribute \
  shift-exponent \
  unreachable \
  vla-bound \

# TODO(danalbert): The following checks currently have compiler performance
# issues.
# CLANG_DEFAULT_UB_CHECKS += alignment
# CLANG_DEFAULT_UB_CHECKS += bounds
# CLANG_DEFAULT_UB_CHECKS += enum
# CLANG_DEFAULT_UB_CHECKS += float-cast-overflow
# CLANG_DEFAULT_UB_CHECKS += float-divide-by-zero
# CLANG_DEFAULT_UB_CHECKS += nonnull-attribute
# CLANG_DEFAULT_UB_CHECKS += null
# CLANG_DEFAULT_UB_CHECKS += shift-base
# CLANG_DEFAULT_UB_CHECKS += signed-integer-overflow

# TODO(danalbert): Fix UB in libc++'s __tree so we can turn this on.
# https://llvm.org/PR19302
# http://reviews.llvm.org/D6974
# CLANG_DEFAULT_UB_CHECKS += object-size

# HOST config
clang_2nd_arch_prefix :=
include $(BUILD_SYSTEM)/clang/HOST_$(HOST_ARCH).mk
+8 −4
Original line number Diff line number Diff line
@@ -50,11 +50,15 @@ ifneq ($(my_clang),true)
  endif
endif

unknown_sanitizers := $(filter-out address, \
                      $(filter-out undefined,$(my_sanitize)))
ifneq ($(filter default-ub,$(my_sanitize)),)
  my_sanitize := $(CLANG_DEFAULT_UB_CHECKS)
  my_ldlibs += -ldl

ifneq ($(unknown_sanitizers),)
  $(error Unknown sanitizers: $(unknown_sanitizers))
  ifdef LOCAL_IS_HOST_MODULE
    my_cflags += -fno-sanitize-recover=all
  else
    my_cflags += -fsanitize-undefined-trap-on-error
  endif
endif

ifneq ($(my_sanitize),)