Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR For Blog #1

Merged
merged 27 commits into from Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c7d3bd8
test_streams: Fix UBSAN error in random generator
erikd Nov 10, 2019
b3f55c4
libFLAC/bitreader.c: Fix shift invoking undefined behaviour
erikd Nov 10, 2019
2907d49
flac/main.c: replace an snprintf() call with flac_snprintf()
sezero Nov 10, 2019
cdcf0d5
cmake_minimum_required() cleanup:
sezero Nov 13, 2019
888ea86
libFLAC++: Add libFLAC++-static.la target for oss-fuzzers
erikd Nov 17, 2019
b19f3a6
oss-fuzz: Add fuzzing headers
erikd Nov 17, 2019
e0f7e0e
oss-fuzz: Add fuzzing targets
erikd Nov 17, 2019
ed1b67b
cmake: use proper pkg-config install path variable
DeadSix27 Nov 12, 2019
1f059e8
libFLAC/bitreader.c: Fix shift invoking undefined behaviour
erikd Nov 18, 2019
3a151a2
doc: Update to Doxygen 1.7.6.1
NotTsunami Nov 18, 2019
3bb5d8c
include: Escape number signs to suppress warnings
NotTsunami Nov 18, 2019
1640e10
lib.mk: Remove incorrect u flag from ar
NotTsunami Nov 19, 2019
f706f28
cmake/configure.ac: Enable -fstack-protector-strong by default
NotTsunami Nov 19, 2019
d518e13
libFLAC/bitreader.c: Fix shift invoking undefined behaviour
erikd Nov 21, 2019
b02e159
libFLAC/bitreader.c: Fix shift invoking undefined behaviour
erikd Nov 24, 2019
6455e47
Both files are checked for EOF
elnull Nov 29, 2019
1f578f1
libFLAC++: Delete decoder and encoder before return if they're not valid
elnull Nov 30, 2019
53953b6
libFLAC++: Fix mistyped identifier name
elnull Nov 30, 2019
ec35d55
libFLAC: Removed useless comparison
elnull Nov 30, 2019
020042c
flac: Remove variable from expression because it's always equals to f…
elnull Nov 30, 2019
a76bdaa
replaygain: Fixed usage of gainfilter variable after free
elnull Nov 30, 2019
a9d9f4d
flac: Input file name size calculated just one time
elnull Nov 30, 2019
a3d8927
Correct printf specifiers to unsigned int where needed
elnull Nov 30, 2019
0dfe235
CMake: Handier way to find Iconv
krokoziabla Dec 21, 2019
cffe389
Fix nullptr dereference in FLAC++
tzahola Dec 26, 2019
f69412e
Add Aarch64 Support
coreyjjames Nov 12, 2019
9242aab
travis: Build on Arm64 as well
erikd Jan 5, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -75,3 +75,5 @@ test/picture.diff
test/picture.log
.dirstamp
microbench/benchmark_residual
oss-fuzz/fuzz-decoder
oss-fuzz/fuzz-encoder
6 changes: 5 additions & 1 deletion .travis.yml
@@ -1,5 +1,9 @@
language: c

arch:
- amd64
- arm64

os:
- linux
- osx
Expand All @@ -17,7 +21,7 @@ env:
- BUILD_SYSTEM="cmake" CONFIGURE_OPTS=
- BUILD_SYSTEM="cmake" CONFIGURE_OPTS=-DENABLE_64_BIT_WORDS=ON
install:
- if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get -y install libtool-bin libogg-dev doxygen libxml2-utils w3c-sgml-lib; fi
- if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get -y install gettext libtool-bin libogg-dev doxygen libxml2-utils w3c-sgml-lib; fi
- if [ $TRAVIS_OS_NAME = osx ]; then brew update ; brew install libogg; fi

script:
Expand Down
31 changes: 23 additions & 8 deletions CMakeLists.txt
@@ -1,4 +1,8 @@
cmake_minimum_required(VERSION 3.9)
# 3.1 is OK for most parts. However:
# 3.3 is needed in src/libFLAC
# 3.5 is needed in src/libFLAC/ia32
# 3.9 is needed in 'doc' because of doxygen_add_docs()
cmake_minimum_required(VERSION 3.5)

if(NOT (CMAKE_BUILD_TYPE OR CMAKE_CONFIGURATION_TYPES OR DEFINED ENV{CFLAGS} OR DEFINED ENV{CXXFLAGS}))
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo")
Expand All @@ -10,17 +14,20 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

option(BUILD_CXXLIBS "Build libFLAC++" ON)
option(BUILD_EXAMPLES "Build and install examples" ON)
option(BUILD_DOCS "Build and install doxygen documents" ON)
option(WITH_STACK_PROTECTOR "Enable GNU GCC stack smash protection" ON)
option(WITH_OGG "ogg support (default: test for libogg)" ON)

if(WITH_OGG)
find_package(OGG REQUIRED)
endif()

find_package(Iconv)
set(HAVE_ICONV ${Iconv_FOUND})

if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return -Wcast-align -Wnested-externs -Wshadow -Wundef -Wmissing-declarations -Winline")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -funroll-loops")

option(ENABLE_SSP "Enable GNU GCC stack smash protection" OFF)
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wcast-align -Wshadow -Wwrite-strings -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder -Wsign-promo -Wundef")
Expand Down Expand Up @@ -57,10 +64,15 @@ test_big_endian(CPU_IS_BIG_ENDIAN)

check_c_compiler_flag(-Werror HAVE_WERROR_FLAG)
check_c_compiler_flag(-Wdeclaration-after-statement HAVE_DECL_AFTER_STMT_FLAG)
check_c_compiler_flag("-fstack-protector --param ssp-buffer-size=4" HAVE_SSP_FLAG)
check_c_compiler_flag(-mstackrealign HAVE_STACKREALIGN_FLAG)
check_cxx_compiler_flag(-Weffc++ HAVE_WEFFCXX_FLAG)

if(WITH_STACK_PROTECTOR)
if(NOT MSVC)
check_c_compiler_flag("-fstack-protector-strong" HAVE_STACK_PROTECTOR_FLAG)
endif()
endif()

if(HAVE_WERROR_FLAG)
option(ENABLE_WERROR "Enable -Werror in all Makefiles" OFF)
endif()
Expand All @@ -69,12 +81,13 @@ add_compile_options(
$<$<BOOL:${MSVC}>:/wd4267>
$<$<BOOL:${MSVC}>:/wd4996>
$<$<BOOL:${ENABLE_WERROR}>:-Werror>
$<$<AND:$<BOOL:${HAVE_SSP_FLAG}>,$<BOOL:${ENABLE_SSP}>>:-fstack-protector>
$<$<AND:$<BOOL:${HAVE_SSP_FLAG}>,$<BOOL:${ENABLE_SSP}>>:--param>
$<$<AND:$<BOOL:${HAVE_SSP_FLAG}>,$<BOOL:${ENABLE_SSP}>>:ssp-buffer-size=4>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<BOOL:${HAVE_WEFFCXX_FLAG}>>:-Weffc++>
$<$<AND:$<COMPILE_LANGUAGE:C>,$<BOOL:${HAVE_DECL_AFTER_STMT_FLAG}>>:-Wdeclaration-after-statement>)

if(HAVE_STACK_PROTECTOR_FLAG)
add_compile_options(-fstack-protector-strong)
endif()

if(CMAKE_SYSTEM_PROCESSOR STREQUAL "i686" AND HAVE_STACKREALIGN_FLAG)
add_compile_options(-mstackrealign)
endif()
Expand All @@ -93,9 +106,11 @@ if(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
add_definitions(-DFLAC__OVERFLOW_DETECT)
endif()

add_subdirectory("doc")
add_subdirectory("src")
add_subdirectory("microbench")
if(BUILD_DOCS)
add_subdirectory("doc")
endif()
if(BUILD_EXAMPLES)
add_subdirectory("examples")
endif()
Expand Down
2 changes: 1 addition & 1 deletion Makefile.am
Expand Up @@ -31,7 +31,7 @@

ACLOCAL_AMFLAGS = -I m4

SUBDIRS = doc include m4 man src test build microbench
SUBDIRS = doc include m4 man src test build microbench oss-fuzz

if EXAMPLES
SUBDIRS += examples
Expand Down
2 changes: 1 addition & 1 deletion build/lib.mk
Expand Up @@ -38,7 +38,7 @@ ifeq ($(CC),gcc)
GCC_INLINE = -finline-functions
endif
NASM = nasm
LINK = ar cru
LINK = ar cr
OBJPATH = $(topdir)/objs
LIBPATH = $(OBJPATH)/$(BUILD)/lib
DEBUG_LIBPATH = $(OBJPATH)/debug/lib
Expand Down
71 changes: 57 additions & 14 deletions configure.ac
Expand Up @@ -69,7 +69,7 @@ AC_C_INLINE
AC_C_VARARRAYS
AC_C_TYPEOF

AC_CHECK_HEADERS([stdint.h inttypes.h byteswap.h sys/param.h sys/ioctl.h termios.h x86intrin.h cpuid.h])
AC_CHECK_HEADERS([stdint.h inttypes.h byteswap.h sys/param.h sys/ioctl.h termios.h x86intrin.h cpuid.h arm_neon.h])

XIPH_C_BSWAP32
XIPH_C_BSWAP16
Expand Down Expand Up @@ -156,6 +156,11 @@ case "$host_cpu" in
AH_TEMPLATE(FLAC__CPU_PPC, [define if building for PowerPC])
asm_optimisation=$asm_opt
;;
aarch64*)
cpu_aarch64=true
AC_DEFINE(FLAC__CPU_AARCH64)
AH_TEMPLATE(FLAC__CPU_AARCH64, [define if building for AARCH64])
;;
sparc)
cpu_sparc=true
AC_DEFINE(FLAC__CPU_SPARC)
Expand All @@ -167,6 +172,7 @@ AM_CONDITIONAL(FLAC__CPU_X86_64, test "x$cpu_x86_64" = xtrue)
AM_CONDITIONAL(FLaC__CPU_IA32, test "x$cpu_ia32" = xtrue)
AM_CONDITIONAL(FLaC__CPU_PPC, test "x$cpu_ppc" = xtrue)
AM_CONDITIONAL(FLaC__CPU_PPC64, test "x$cpu_ppc64" = xtrue)
AM_CONDITIONAL(FLAC__CPU_AARCH64, test "x$cpu_aarch64" = xtrue)
AM_CONDITIONAL(FLaC__CPU_SPARC, test "x$cpu_sparc" = xtrue)

if test "x$ac_cv_header_x86intrin_h" = xyes; then
Expand All @@ -175,6 +181,12 @@ else
AC_DEFINE([FLAC__HAS_X86INTRIN], 0)
fi

if test "x$ac_cv_header_arm_neon_h" = xyes; then
AC_DEFINE([FLAC__HAS_NEONINTRIN], 1, [Set to 1 if <arm_neon.h> is available.])
else
AC_DEFINE([FLAC__HAS_NEONINTRIN], 0)
fi

if test x"$cpu_ppc64" = xtrue ; then

AC_C_ATTRIBUTE([target("cpu=power8")],
Expand Down Expand Up @@ -310,8 +322,10 @@ AC_SUBST(FLAC__TEST_LEVEL)
AC_ARG_ENABLE(werror,
AC_HELP_STRING([--enable-werror], [Enable -Werror in all Makefiles]))

AC_ARG_ENABLE(stack-smash-protection,
AC_HELP_STRING([--enable-stack-smash-protection], [Enable GNU GCC stack smash protection]))
AC_ARG_ENABLE([stack-smash-protection],
[AS_HELP_STRING([--disable-stack-smash-protection],[Disable GNU GCC stack smash protection])],,
[AS_IF([test "$ac_cv_c_compiler_gnu" = "yes" && test "$os_is_windows" = "no"],
[enable_stack_smash_protection=yes],[enable_stack_smash_protection=no])])

AC_ARG_ENABLE(64-bit-words,
AC_HELP_STRING([--enable-64-bit-words], [Set FLAC__BYTES_PER_WORD to 8 (4 is the default)]))
Expand Down Expand Up @@ -374,6 +388,32 @@ AC_HELP_STRING([--disable-cpplibs], [Do not build libFLAC++]),
esac], [disable_cpplibs=false])
AM_CONDITIONAL(FLaC__WITH_CPPLIBS, [test "x$disable_cpplibs" != xtrue])

AC_ARG_ENABLE([oss-fuzzers],
[AS_HELP_STRING([--enable-oss-fuzzers],
[Whether to generate the fuzzers for OSS-Fuzz (Clang only)])],
[have_oss_fuzzers=yes], [have_oss_fuzzers=no])

if test "x$have_oss_fuzzers" = "xyes"; then
if test "x$xiph_cv_c_compiler_clang" = "xyes" ; then
AM_CONDITIONAL([USE_OSSFUZZERS], [test "x$have_oss_fuzzers" = "xyes"])
if test "x$LIB_FUZZING_ENGINE" = "x" ; then
# Only set this if it is empty.
LIB_FUZZING_ENGINE=-fsanitize=fuzzer
fi
else
AM_CONDITIONAL([USE_OSSFUZZERS], [test "false" = "true"])
# Disable fuzzer if the compiler is not Clang.
AC_MSG_WARN([*** Ozz-Fuzz is disabled because that requres the Clang compiler.])
have_oss_fuzzers="no (compiler is GCC)"
fi
else
AM_CONDITIONAL([USE_OSSFUZZERS], [test "false" = "true"])
fi

AM_CONDITIONAL([USE_OSSFUZZ_FLAG], [test "x$LIB_FUZZING_ENGINE" = "x-fsanitize=fuzzer"])
AM_CONDITIONAL([USE_OSSFUZZ_STATIC], [test -f "$LIB_FUZZING_ENGINE"])
AC_SUBST([LIB_FUZZING_ENGINE])

dnl check for ogg library
AC_ARG_ENABLE([ogg],
AC_HELP_STRING([--disable-ogg], [Disable ogg support (default: test for libogg)]),
Expand Down Expand Up @@ -576,7 +616,8 @@ AC_CONFIG_FILES([ \
test/metaflac-test-files/Makefile \
test/pictures/Makefile \
build/Makefile \
microbench/Makefile
microbench/Makefile \
oss-fuzz/Makefile
])
AC_OUTPUT

Expand All @@ -585,19 +626,21 @@ AC_MSG_RESULT([

Configuration summary :

FLAC version : ........................ ${VERSION}
FLAC version : ............................ ${VERSION}

Host CPU : ............................ ${host_cpu}
Host Vendor : ......................... ${host_vendor}
Host OS : ............................. ${host_os}
Host CPU : ................................ ${host_cpu}
Host Vendor : ............................. ${host_vendor}
Host OS : ................................. ${host_os}
])

echo " Compiler is GCC : ..................... ${ac_cv_c_compiler_gnu}"
echo " Compiler is GCC : ......................... ${ac_cv_c_compiler_gnu}"
if test x$ac_cv_c_compiler_gnu = xyes ; then
echo " GCC version : ......................... ${GCC_VERSION}"
echo " GCC version : ............................. ${GCC_VERSION}"
fi
echo " Compiler is Clang : ................... ${xiph_cv_c_compiler_clang}"
echo " SSE optimizations : ................... ${sse_os}"
echo " Asm optimizations : ................... ${asm_optimisation}"
echo " Ogg/FLAC support : .................... ${have_ogg}"
echo " Compiler is Clang : ....................... ${xiph_cv_c_compiler_clang}"
echo " SSE optimizations : ....................... ${sse_os}"
echo " Asm optimizations : ....................... ${asm_optimisation}"
echo " Ogg/FLAC support : ........................ ${have_ogg}"
echo " Stack protector : ........................ ${enable_stack_smash_protection}"
echo " Fuzzing support (Clang only) : ............ ${have_oss_fuzzers}"
echo
3 changes: 2 additions & 1 deletion doc/CMakeLists.txt
@@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.9)

find_package(Doxygen)

if (NOT DOXYGEN_FOUND)
Expand Down