[vlc-commits] [Git][videolan/vlc][master] 13 commits: configure: test CXXFLAGS with the C++ compiler
Steve Lhomme (@robUx4)
gitlab at videolan.org
Fri Nov 10 05:38:41 UTC 2023
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
f4fa0473 by Steve Lhomme at 2023-11-10T04:51:50+00:00
configure: test CXXFLAGS with the C++ compiler
- - - - -
fded16c5 by Steve Lhomme at 2023-11-10T04:51:50+00:00
configure: add --enable-extra-checks do add more compilation errors
These are the same options we already use in build scripts.
- - - - -
8f3d9849 by Steve Lhomme at 2023-11-10T04:51:50+00:00
meson: add extra_checks do add more compilation errors
These are the same options we already use in build scripts.
- - - - -
0f75cbf6 by Steve Lhomme at 2023-11-10T04:51:50+00:00
extras/package: use --enable-extra-checks instead of local errors
We have a common set of errors between all builds.
- - - - -
fb4dd919 by Steve Lhomme at 2023-11-10T04:51:50+00:00
CI: use common error checks in Debian build
- - - - -
2324eff4 by Steve Lhomme at 2023-11-10T04:51:50+00:00
CI: use common error checks in Debian Meson build
- - - - -
3b6e2700 by Steve Lhomme at 2023-11-10T04:51:50+00:00
package/apple: add --enable-extra-checks to add extra compilation errors
- - - - -
922e338e by Steve Lhomme at 2023-11-10T04:51:50+00:00
CI: build iOS targets with extra compilation checks
- - - - -
921c88a2 by Steve Lhomme at 2023-11-10T04:51:50+00:00
package/snap: build with --enable-extra-checks to add extra compilation errors
- - - - -
52be67e5 by Steve Lhomme at 2023-11-10T04:51:50+00:00
package/wasm: add --enable-extra-checks to add extra compilation errors
- - - - -
aea00fb4 by Steve Lhomme at 2023-11-10T04:51:50+00:00
CI: build WASM target with extra compilation checks
- - - - -
203a9520 by Steve Lhomme at 2023-11-10T04:51:50+00:00
CI: build Android targets with extra compilation checks
- - - - -
6aadea39 by Steve Lhomme at 2023-11-10T04:51:50+00:00
build: add -Werror=format error
GCC and Clang can check that the % format strings are used with the proper
types. If they are not that can lead to security issues.
This cannot be added to global CFLAGS as it will issue an error when testing
for asprintf/vasprintf in AC_REPLACE_FUNCS().
- - - - -
10 changed files:
- configure.ac
- extras/ci/gitlab-ci.yml
- extras/package/apple/build.sh
- extras/package/macosx/build.sh
- extras/package/raspberry/build.sh
- extras/package/snap/snapcraft.yaml
- extras/package/wasm-emscripten/build.sh
- extras/package/win32/build.sh
- meson.build
- meson_options.txt
Changes:
=====================================
configure.ac
=====================================
@@ -1148,12 +1148,25 @@ dnl Compiler warnings
dnl
AX_APPEND_COMPILE_FLAGS([-Wall -Wextra -Wsign-compare -Wundef -Wpointer-arith -Wvolatile-register-var -Wformat -Wformat-security -Wduplicated-branches -Wduplicated-cond], [CFLAGS])
+AC_LANG_PUSH(C++)
AX_APPEND_COMPILE_FLAGS([-Wall -Wextra -Wsign-compare -Wundef -Wpointer-arith -Wvolatile-register-var -Wformat -Wformat-security -Wduplicated-branches -Wduplicated-cond], [CXXFLAGS])
+AC_LANG_POP(C++)
dnl -Werror-implicit-function-declaration is used for the if_nametoindex detection with winstore
AX_APPEND_COMPILE_FLAGS([-Wbad-function-cast -Wwrite-strings -Wmissing-prototypes -Werror-implicit-function-declaration -Winit-self -Wlogical-op -Wshadow=local -Wmultistatement-macros], [CFLAGS])
AX_APPEND_COMPILE_FLAGS([-pipe], [CFLAGS])
+AC_ARG_ENABLE([extra_checks],
+ AS_HELP_STRING([--enable-extra-checks],
+ [Turn some warnings into compilation error (default disabled)]),,
+ [enable_extra_checks="no"])
+AS_IF([test "${enable_extra_checks}" = "yes"], [
+ AX_APPEND_COMPILE_FLAGS([-Werror=missing-field-initializers -Werror=format -Werror=incompatible-pointer-types -Werror=restrict], [CFLAGS])
+ AC_LANG_PUSH(C++)
+ AX_APPEND_COMPILE_FLAGS([-Werror=missing-field-initializers -Werror=format], [CXXFLAGS])
+ AC_LANG_POP(C++)
+])
+
dnl UWP forbidden checks
AS_IF([test "${SYS}" = "mingw32"], [
AC_MSG_CHECKING(for if_nametoindex availability)
=====================================
extras/ci/gitlab-ci.yml
=====================================
@@ -307,17 +307,16 @@ debian:
# Configure VLC
./bootstrap
- ./configure CFLAGS="$LIBVLC_EXTRA_CFLAGS"
+ ./configure
# Allow core dumps for tracing test failures
ulimit -c unlimited
# Build, check and distcheck VLC
export XZ_OPT="-T 0"
- DISTCHECK_CONFIGURE_FLAGS="CFLAGS='$LIBVLC_EXTRA_CFLAGS'" make -j$NCPU distcheck AM_DISTCHECK_CONFIGURE_FLAGS="--enable-fast-install" || ./test/dump_stacktraces.sh
+ make -j$NCPU distcheck AM_DISTCHECK_CONFIGURE_FLAGS="--enable-fast-install --enable-extra-checks" || ./test/dump_stacktraces.sh
variables:
<<: *variables-debian
- LIBVLC_EXTRA_CFLAGS: -Werror=restrict -Werror=incompatible-pointer-types
nightly-debian:
extends: debian
@@ -348,7 +347,7 @@ debian-meson:
- |
echo -e "\e[0Ksection_start:$(date +%s):setup_meson_section\r\e[0KMeson setup"
# Setup meson build dir
- meson setup -Db_coverage=true build-meson || (echo "ERROR: Meson setup failed!" >&2 ; cat build-meson/meson-logs/meson-log.txt >&2 ; exit 1)
+ meson setup -Db_coverage=true -Dextra_checks=true build-meson || (echo "ERROR: Meson setup failed!" >&2 ; cat build-meson/meson-logs/meson-log.txt >&2 ; exit 1)
echo -e "\e[0Ksection_end:$(date +%s):setup_meson_section\r\e[0K"
- |
@@ -536,9 +535,10 @@ nightly-macos-arm64:
mkdir build && cd build
if [ -n "$VLC_PREBUILT_CONTRIBS_URL" ]; then
../extras/package/apple/build.sh --sdk=$SDKNAME --arch=$HOST_ARCH --package-contribs \
- --with-prebuilt-contribs
+ --enable-extra-checks --with-prebuilt-contribs
else
- ../extras/package/apple/build.sh --sdk=$SDKNAME --arch=$HOST_ARCH --package-contribs
+ ../extras/package/apple/build.sh --sdk=$SDKNAME --arch=$HOST_ARCH --package-contribs \
+ --enable-extra-checks
fi
ios-arm64:
@@ -568,10 +568,11 @@ tvos-arm64:
git clone https://code.videolan.org/videolan/libvlcjni.git
(cd libvlcjni && git checkout aa63288b6bb5c52dfacbdec95104cd4c86c7e9c2)
if [ -n "$VLC_PREBUILT_CONTRIBS_URL" ]; then
- /bin/sh ./libvlcjni/buildsystem/compile-libvlc.sh --no-jni -a $ANDROID_ARCH --with-prebuilt-contribs
+ CONTRIB_FLAGS="--with-prebuilt-contribs"
else
- /bin/sh ./libvlcjni/buildsystem/compile-libvlc.sh --no-jni -a $ANDROID_ARCH --package-contribs
+ CONTRIB_FLAGS="--package-contribs"
fi
+ EXTRA_PARAMS="--enable-extra-checks" /bin/sh ./libvlcjni/buildsystem/compile-libvlc.sh --no-jni -a $ANDROID_ARCH $CONTRIB_FLAGS
android-arm:
extends: .android-common
@@ -601,6 +602,7 @@ wasm32-emscripten-build :
script:
- source $EMSCRIPTEN_SDK/emsdk_env.sh
- |
+ EXTRA_BUILD_FLAGS="${EXTRA_BUILD_FLAGS} --enable-extra-checks"
if [ -n "$VLC_PREBUILT_CONTRIBS_URL" ]; then
echo "Building using prebuilt contribs at $VLC_PREBUILT_CONTRIBS_URL"
EXTRA_BUILD_FLAGS="${EXTRA_BUILD_FLAGS} --with-prebuilt-contribs"
=====================================
extras/package/apple/build.sh
=====================================
@@ -101,6 +101,8 @@ VLC_USE_BITCODE=0
VLC_BITCODE_FLAG="-fembed-bitcode"
# whether to build static or dynamic plugins
VLC_BUILD_DYNAMIC=0
+# Add extra checks when compiling
+VLC_BUILD_EXTRA_CHECKS=0
# Tools to be used
VLC_HOST_CC="$(xcrun --find clang)"
@@ -135,6 +137,7 @@ usage()
echo " --with-prebuilt-contribs Use prebuilt contribs instead of building"
echo " them from source"
echo " --enable-shared Build dynamic libraries and plugins"
+ echo " --enable-extra-checks Add extra checks when compiling"
echo "Environment variables:"
echo " VLC_PREBUILT_CONTRIBS_URL URL to fetch the prebuilt contrib archive"
echo " from when --with-prebuilt-contribs is used"
@@ -475,6 +478,9 @@ do
--enable-shared)
VLC_BUILD_DYNAMIC=1
;;
+ --enable-extra-checks)
+ VLC_BUILD_EXTRA_CHECKS=1
+ ;;
VLC_PREBUILT_CONTRIBS_URL=*)
VLC_PREBUILT_CONTRIBS_URL="${1#VLC_PREBUILT_CONTRIBS_URL=}"
;;
@@ -684,6 +690,10 @@ else
VLC_CONFIG_OPTIONS+=( "--disable-shared" "--enable-static" )
fi
+if [ "$VLC_BUILD_EXTRA_CHECKS" -gt "0" ]; then
+ VLC_CONFIG_OPTIONS+=( "--enable-extra-checks" )
+fi
+
# Bootstrap VLC
cd "$VLC_SRC_DIR" || abort_err "Failed cd to VLC source dir"
if ! [ -e configure ]; then
=====================================
extras/package/macosx/build.sh
=====================================
@@ -252,8 +252,7 @@ if [ "$NODEBUG" = "yes" ]; then
CONFIGFLAGS="$CONFIGFLAGS --disable-debug"
fi
if [ -n "$EXTRA_CHECKS" ]; then
- CFLAGS="$CFLAGS -Werror=incompatible-pointer-types -Werror=missing-field-initializers"
- CXXFLAGS="$CXXFLAGS -Werror=missing-field-initializers"
+ CONFIGFLAGS="$CONFIGFLAGS --enable-extra-checks"
fi
export CFLAGS
=====================================
extras/package/raspberry/build.sh
=====================================
@@ -161,7 +161,7 @@ if [ "$I18N" != "yes" ]; then
CONFIGFLAGS="$CONFIGFLAGS --disable-nls"
fi
if [ ! -z "$EXTRA_CHECKS" ]; then
- CFLAGS="$CFLAGS -Werror=incompatible-pointer-types -Werror=missing-field-initializers"
+ CONFIGFLAGS="$CONFIGFLAGS --enable-extra-checks"
fi
ac_cv_path_MOC="qtchooser -qt=qt5-$TRIPLET -run-tool=moc" \
=====================================
extras/package/snap/snapcraft.yaml
=====================================
@@ -99,7 +99,8 @@ parts:
--prefix=$SNAPCRAFT_PART_INSTALL/usr \
--host=$TRIPLET \
--disable-wayland \
- --enable-merge-ffmpeg
+ --enable-merge-ffmpeg \
+ --enable-extra-checks
make -j $(getconf _NPROCESSORS_ONLN)
echo $(git describe --always HEAD) > $SNAPCRAFT_STAGE/version
make -j $(getconf _NPROCESSORS_ONLN) install
=====================================
extras/package/wasm-emscripten/build.sh
=====================================
@@ -52,6 +52,9 @@ do
--enable-shared)
VLC_COMPILE_SHARED=1
;;
+ --enable-extra-checks)
+ VLC_BUILD_EXTRA_CHECKS=1
+ ;;
--gen-contrib-archive|-c)
GENERATE_ARCHIVE=1
;;
@@ -70,6 +73,7 @@ BUILDDIR_NAME="build-emscripten"
GENERATE_ARCHIVE=${GENERATE_ARCHIVE:=0}
VLC_USE_PREBUILT_CONTRIBS=${VLC_USE_PREBUILT_CONTRIBS:=0}
VLC_COMPILE_SHARED=${VLC_COMPILE_SHARED:=0}
+VLC_BUILD_EXTRA_CHECKS=${VLC_BUILD_EXTRA_CHECKS:=0}
diagnostic "setting MAKEFLAGS"
if [ -z "$MAKEFLAGS" ]; then
@@ -175,6 +179,10 @@ else
SHARED_CONFIGURE_FLAGS="--disable-shared"
fi
+if [ "$VLC_BUILD_EXTRA_CHECKS" -eq "1" ]; then
+ EXTRA_CONFIGURE_FLAGS="--enable-extra-checks"
+fi
+
cd "$BUILD_PATH"
if [ $BUILD_MODE -eq 1 ]; then
diagnostic "libvlc build: bootstrap"
@@ -192,7 +200,7 @@ if [ $BUILD_MODE -eq 1 ]; then
SANITIZER_OPTIONS="--with-sanitizer=${VLC_USE_SANITIZER}"
fi
emconfigure "$VLC_SRCPATH"/configure --host=wasm32-unknown-emscripten --enable-debug \
- $SHARED_CONFIGURE_FLAGS --disable-vlc \
+ $SHARED_CONFIGURE_FLAGS $EXTRA_CONFIGURE_FLAGS --disable-vlc \
--enable-avcodec --enable-avformat --enable-swscale --enable-postproc \
--disable-sout --disable-vlm --disable-a52 --disable-xcb --disable-lua \
--disable-addonmanagermodules --disable-ssp --disable-nls \
=====================================
extras/package/win32/build.sh
=====================================
@@ -415,11 +415,7 @@ if [ ! -z "$WITH_PDB" ]; then
CONFIGFLAGS="$CONFIGFLAGS --enable-pdb"
fi
if [ ! -z "$EXTRA_CHECKS" ]; then
- CFLAGS="$CFLAGS -Werror=incompatible-pointer-types -Werror=missing-field-initializers"
- CXXFLAGS="$CXXFLAGS -Werror=missing-field-initializers"
- if [ ! "$COMPILING_WITH_CLANG" -gt 0 ]; then
- CFLAGS="$CFLAGS -Werror=restrict"
- fi
+ CONFIGFLAGS="$CONFIGFLAGS --enable-extra-checks"
fi
if [ ! -z "$DISABLEGUI" ]; then
CONFIGFLAGS="$CONFIGFLAGS --disable-vlc --disable-qt --disable-skins2"
=====================================
meson.build
=====================================
@@ -476,6 +476,17 @@ add_project_arguments(cc.get_supported_arguments([
'-pipe'
]), language: ['c'])
+if get_option('extra_checks')
+ add_project_arguments(cc.get_supported_arguments([
+ '-Werror=missing-field-initializers',
+ '-Werror=format'
+ ]), language: ['c', 'cpp'])
+ add_project_arguments(cc.get_supported_arguments([
+ '-Werror=incompatible-pointer-types',
+ '-Werror=restrict'
+ ]), language: ['c'])
+endif
+
if get_option('branch_protection') \
.require(host_machine.cpu_family() == 'aarch64', error_message: 'Branch protection is only available for AArch64') \
.require(cc.has_argument('-mbranch-protection=standard'), error_message: 'Compiler does not support `-mbranch-protection`') \
=====================================
meson_options.txt
=====================================
@@ -50,6 +50,11 @@ option('ssp',
value : 'auto',
description : 'Stack smashing protection')
+option('extra_checks',
+ type : 'boolean',
+ value : false,
+ description : 'Turn some warnings into compilation error')
+
option('winstore_app',
type : 'boolean',
value : false,
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/75d83e3501d9e79bb9f080477f8481928da06edd...6aadea3959d1094216d43d867c7b625cda5672f7
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/75d83e3501d9e79bb9f080477f8481928da06edd...6aadea3959d1094216d43d867c7b625cda5672f7
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list