mirror of
https://github.com/libretro/RetroArch
synced 2025-03-18 13:20:57 +00:00
(phoenix) Add optional clang sanitizer support
Set the SANITIZER=address environment variable. Debug mode isn't required but helps.
This commit is contained in:
parent
9ed030cda0
commit
d62839516e
@ -54,11 +54,8 @@ LOCAL_CFLAGS += -Wall -pthread -Wno-unused-function -fno-stack-protector -funrol
|
||||
LOCAL_CFLAGS += -DHAVE_7ZIP
|
||||
LOCAL_CFLAGS += -DHAVE_CHEEVOS
|
||||
|
||||
ifeq ($(NDK_DEBUG),1)
|
||||
LOCAL_CFLAGS += -O0 -g
|
||||
else
|
||||
LOCAL_CFLAGS += -O2 -DNDEBUG
|
||||
endif
|
||||
# Let ndk-build set the optimization flags but remove -O3 like in cf3c3
|
||||
LOCAL_CFLAGS := $(subst -O3,-O2,$(LOCAL_CFLAGS))
|
||||
|
||||
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -landroid -lEGL $(GLES_LIB) $(LOGGER_LDLIBS) -ldl
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(RARCH_DIR)/libretro-common/include/
|
||||
@ -66,5 +63,11 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(RARCH_DIR)/libretro-common/include/
|
||||
LOCAL_CFLAGS += -DHAVE_SL
|
||||
LOCAL_LDLIBS += -lOpenSLES -lz
|
||||
|
||||
ifneq ($(SANITIZER),)
|
||||
LOCAL_CFLAGS += -g -fsanitize=$(SANITIZER) -fno-omit-frame-pointer
|
||||
LOCAL_CPPFLAGS += -g -fsanitize=$(SANITIZER) -fno-omit-frame-pointer
|
||||
LOCAL_LDFLAGS += -fsanitize=$(SANITIZER)
|
||||
endif
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
|
@ -17,3 +17,24 @@ ifndef TARGET_ABIS
|
||||
else
|
||||
APP_ABI := $(TARGET_ABIS)
|
||||
endif
|
||||
|
||||
# Run $NDK/toolchains/llvm-3.6/prebuilt/linux-x86_64/bin/asan_device_setup once
|
||||
# for each AVD you use, replacing llvm-3.6 with the latest you have and
|
||||
# linux-x86_64 with your host ABI.
|
||||
ifneq ($(SANITIZER),)
|
||||
# AddressSanitizer doesn't run on mips
|
||||
ifndef TARGET_ABIS
|
||||
APP_ABI := armeabi-v7a x86
|
||||
else
|
||||
ifneq ($(findstring mips,$(TARGET_ABIS)),)
|
||||
$(error "AddressSanitizer does not support mips.")
|
||||
endif
|
||||
endif
|
||||
USE_CLANG := 1
|
||||
endif
|
||||
|
||||
ifeq ($(USE_CLANG),1)
|
||||
NDK_TOOLCHAIN_VERSION := clang
|
||||
APP_CFLAGS := -Wno-invalid-source-encoding
|
||||
APP_CPPFLAGS := -Wno-invalid-source-encoding
|
||||
endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user