[Android] build: add asan support
Thomas Guillem
git at videolan.org
Mon Aug 29 13:36:51 CEST 2016
vlc-android | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Aug 29 13:32:53 2016 +0200| [a55cb3254d465757e77afbc72c366db893a4c71e] | committer: Thomas Guillem
build: add asan support
> https://code.videolan.org/videolan/vlc-android/commit/a55cb3254d465757e77afbc72c366db893a4c71e
---
compile-libvlc.sh | 21 +++++++++++++++++++++
compile.sh | 6 ++++++
2 files changed, 27 insertions(+)
diff --git a/compile-libvlc.sh b/compile-libvlc.sh
index c9666fd..f0d7c97 100755
--- a/compile-libvlc.sh
+++ b/compile-libvlc.sh
@@ -17,6 +17,7 @@ checkfail()
#############
RELEASE=0
+ASAN=0
while [ $# -gt 0 ]; do
case $1 in
help|--help)
@@ -31,6 +32,9 @@ while [ $# -gt 0 ]; do
-c)
CHROME_OS=1
;;
+ --asan)
+ ASAN=1
+ ;;
release|--release)
RELEASE=1
;;
@@ -347,6 +351,7 @@ fi
##########
# CFLAGS #
##########
+
VLC_CFLAGS="-std=gnu11"
VLC_CXXFLAGS="-std=gnu++11"
if [ "$NO_OPTIM" = "1" ];
@@ -418,6 +423,19 @@ else
NDK_DEBUG=1
fi
+if [ "${ASAN}" = 1 ];then
+ VLC_CFLAGS="${VLC_CFLAGS} -O0 -fno-omit-frame-pointer -fsanitize=address"
+ VLC_CXXFLAGS="${VLC_CXXLAGS} -O0 -fno-omit-frame-pointer -fsanitize=address"
+ VLC_LDFLAGS="${VLC_LDFLAGS} -ldl -fsanitize=address"
+ # ugly, sorry
+ if [ "${ANDROID_API}" = "9" ];then
+ cp ${ANDROID_NDK}/platforms/android-9/arch-${PLATFORM_SHORT_ARCH}/usr/include/stdlib.h \
+ ${NDK_TOOLCHAIN_DIR}/sysroot/usr/include
+ echo "extern int posix_memalign(void **memptr, size_t alignment, size_t size);" \
+ >> ${NDK_TOOLCHAIN_DIR}/sysroot/usr/include/stdlib.h
+ fi
+fi
+
echo "EXTRA_CFLAGS: ${EXTRA_CFLAGS}"
echo "VLC_CFLAGS: ${VLC_CFLAGS}"
@@ -505,6 +523,9 @@ if [ "${CHROME_OS}" = "1" ];then
else
VLC_BUILD_DIR=build-android-${TARGET_TUPLE}
fi
+if [ "${ASAN}" = 1 ];then
+ VLC_BUILD_DIR=${VLC_BUILD_DIR}-asan
+fi
mkdir -p $VLC_BUILD_DIR && cd $VLC_BUILD_DIR
#############
diff --git a/compile.sh b/compile.sh
index 560c46c..d05f631 100755
--- a/compile.sh
+++ b/compile.sh
@@ -60,6 +60,9 @@ while [ $# -gt 0 ]; do
run)
RUN=1
;;
+ --asan)
+ ASAN=1
+ ;;
*)
diagnostic "$0: Invalid option '$1'."
diagnostic "$0: Try --help for more information."
@@ -218,6 +221,9 @@ fi
if [ "$CHROME_OS" = 1 ]; then
OPTS="$OPTS -c"
fi
+if [ "$ASAN" = 1 ]; then
+ OPTS="$OPTS --asan"
+fi
./compile-libvlc.sh $OPTS
More information about the Android
mailing list