diff --git a/compile-libvlc.sh b/compile-libvlc.sh index c9666fdb14d7b9582cb27158481362a6681f6725..f0d7c97fd83a9d83ba97a79224fb850d024c2ada 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 560c46cb6f9be336e496fd82d21633749ab25cd1..d05f631a7ed5da57537c377c9ef6505568ed1f65 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