forked from openkylin/platform_build
Let clang decide ASan linker flags for the host.
Pass -fsanitize=address instead of manually specifying asan libraries and other linker flags. Note that we enable LOCAL_ALLOW_UNDEFINED_SYMBOLS by default for host builds because ASAN only links symbols in the final executable, so there will _always_ be undefined symbols in intermediate libraries. Bug: 18208352 Change-Id: Ief55ab296e94974560eeb10507ec8d90f0025d5c
This commit is contained in:
parent
37979c5749
commit
b58fb4aac6
|
@ -50,6 +50,12 @@ my_generated_sources := $(LOCAL_GENERATED_SOURCES)
|
|||
my_native_coverage := $(LOCAL_NATIVE_COVERAGE)
|
||||
my_additional_dependencies := $(LOCAL_MODULE_MAKEFILE) $(LOCAL_ADDITIONAL_DEPENDENCIES)
|
||||
|
||||
ifdef LOCAL_IS_HOST_MODULE
|
||||
my_allow_undefined_symbols := true
|
||||
else
|
||||
my_allow_undefined_symbols := $(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS))
|
||||
endif
|
||||
|
||||
my_ndk_sysroot :=
|
||||
my_ndk_sysroot_include :=
|
||||
my_ndk_sysroot_lib :=
|
||||
|
@ -192,19 +198,10 @@ ifeq ($(strip $(LOCAL_ADDRESS_SANITIZER)),true)
|
|||
my_cflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS)
|
||||
my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS)
|
||||
ifdef LOCAL_IS_HOST_MODULE
|
||||
my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS_HOST)
|
||||
my_ldlibs += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDLIBS_HOST)
|
||||
my_shared_libraries += \
|
||||
$(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES_HOST)
|
||||
my_static_libraries += \
|
||||
$(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES_HOST)
|
||||
my_ldflags += -fsanitize=address
|
||||
else
|
||||
my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS_TARGET)
|
||||
my_ldlibs += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDLIBS_TARGET)
|
||||
my_shared_libraries += \
|
||||
$(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES_TARGET)
|
||||
my_static_libraries += \
|
||||
$(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES_TARGET)
|
||||
my_shared_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES)
|
||||
my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)
|
||||
endif
|
||||
endif
|
||||
|
||||
|
@ -403,7 +400,7 @@ $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPP_EXTENSION := $(LOCAL_CPP_EXTENSION)
|
|||
# Certain modules like libdl have to have symbols resolved at runtime and blow
|
||||
# up if --no-undefined is passed to the linker.
|
||||
ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),)
|
||||
ifeq ($(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)),)
|
||||
ifeq ($(my_allow_undefined_symbols),)
|
||||
my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)NO_UNDEFINED_LDFLAGS)
|
||||
endif
|
||||
endif
|
||||
|
|
|
@ -107,15 +107,8 @@ ADDRESS_SANITIZER_RUNTIME_LIBRARY := libclang_rt.asan_$(TARGET_ARCH)_android
|
|||
ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fsanitize=address -fno-omit-frame-pointer
|
||||
ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit
|
||||
|
||||
ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS_HOST := -rdynamic
|
||||
ADDRESS_SANITIZER_CONFIG_EXTRA_LDLIBS_HOST := -lpthread -ldl
|
||||
ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES_HOST :=
|
||||
ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES_HOST := libasan
|
||||
|
||||
ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS_TARGET :=
|
||||
ADDRESS_SANITIZER_CONFIG_EXTRA_LDLIBS_TARGET :=
|
||||
ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES_TARGET := libdl $(ADDRESS_SANITIZER_RUNTIME_LIBRARY)
|
||||
ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES_TARGET := libasan
|
||||
ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := libdl $(ADDRESS_SANITIZER_RUNTIME_LIBRARY)
|
||||
ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan
|
||||
|
||||
# This allows us to use the superset of functionality that compiler-rt
|
||||
# provides to Clang (for supporting features like -ftrapv).
|
||||
|
|
Loading…
Reference in New Issue