configure: Use -Winit-self if possible.

This protects against variable initialization like "int x = x". gcc apparently
treats this as an intentional way to suppress uninitialized or unused variable
warnings, but in my case it has caused at least one confusing bug.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-03-11 10:08:06 -06:00 committed by Alexandre Julliard
parent 5a3b5c9689
commit 131d2d2ef3
2 changed files with 58 additions and 0 deletions

56
configure vendored
View File

@ -9981,6 +9981,37 @@ fi
$as_echo "$ac_cv_crosscflags__Wignored_qualifiers" >&6; }
if test "x$ac_cv_crosscflags__Wignored_qualifiers" = xyes; then :
EXTRACROSSCFLAGS="$EXTRACROSSCFLAGS -Wignored-qualifiers"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the cross-compiler supports -Winit-self" >&5
$as_echo_n "checking whether the cross-compiler supports -Winit-self... " >&6; }
if ${ac_cv_crosscflags__Winit_self+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_wine_try_cflags_saved=$CFLAGS
ac_wine_try_cflags_saved_cc=$CC
ac_wine_try_cflags_saved_exeext=$ac_exeext
CFLAGS="$CFLAGS $EXTRACROSSCFLAGS -nostartfiles -nodefaultlibs -Winit-self"
CC="$CROSSCC"
ac_exeext=".exe"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int __cdecl mainCRTStartup(void) { return 0; }
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_crosscflags__Winit_self=yes
else
ac_cv_crosscflags__Winit_self=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
CFLAGS=$ac_wine_try_cflags_saved
CC=$ac_wine_try_cflags_saved_cc
ac_exeext=$ac_wine_try_cflags_saved_exeext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_crosscflags__Winit_self" >&5
$as_echo "$ac_cv_crosscflags__Winit_self" >&6; }
if test "x$ac_cv_crosscflags__Winit_self" = xyes; then :
EXTRACROSSCFLAGS="$EXTRACROSSCFLAGS -Winit-self"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the cross-compiler supports -Wpacked-not-aligned" >&5
$as_echo_n "checking whether the cross-compiler supports -Wpacked-not-aligned... " >&6; }
@ -17193,6 +17224,31 @@ fi
$as_echo "$ac_cv_cflags__Wignored_qualifiers" >&6; }
if test "x$ac_cv_cflags__Wignored_qualifiers" = xyes; then :
EXTRACFLAGS="$EXTRACFLAGS -Wignored-qualifiers"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -Winit-self" >&5
$as_echo_n "checking whether the compiler supports -Winit-self... " >&6; }
if ${ac_cv_cflags__Winit_self+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_wine_try_cflags_saved=$CFLAGS
CFLAGS="$CFLAGS -Winit-self"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int main(int argc, char **argv) { return 0; }
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_cflags__Winit_self=yes
else
ac_cv_cflags__Winit_self=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
CFLAGS=$ac_wine_try_cflags_saved
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cflags__Winit_self" >&5
$as_echo "$ac_cv_cflags__Winit_self" >&6; }
if test "x$ac_cv_cflags__Winit_self" = xyes; then :
EXTRACFLAGS="$EXTRACFLAGS -Winit-self"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -Wpacked-not-aligned" >&5
$as_echo_n "checking whether the compiler supports -Wpacked-not-aligned... " >&6; }

View File

@ -1044,6 +1044,7 @@ then
WINE_TRY_CROSSCFLAGS([-Wdeclaration-after-statement])
WINE_TRY_CROSSCFLAGS([-Wempty-body])
WINE_TRY_CROSSCFLAGS([-Wignored-qualifiers])
WINE_TRY_CROSSCFLAGS([-Winit-self])
WINE_TRY_CROSSCFLAGS([-Wpacked-not-aligned],[EXTRACROSSCFLAGS="$EXTRACROSSCFLAGS -Wno-packed-not-aligned"])
WINE_TRY_CROSSCFLAGS([-Wpragma-pack],[EXTRACROSSCFLAGS="$EXTRACROSSCFLAGS -Wno-pragma-pack"])
WINE_TRY_CROSSCFLAGS([-Wshift-overflow=2])
@ -2024,6 +2025,7 @@ then
WINE_TRY_CFLAGS([-Wdeclaration-after-statement])
WINE_TRY_CFLAGS([-Wempty-body])
WINE_TRY_CFLAGS([-Wignored-qualifiers])
WINE_TRY_CFLAGS([-Winit-self])
WINE_TRY_CFLAGS([-Wpacked-not-aligned],[EXTRACFLAGS="$EXTRACFLAGS -Wno-packed-not-aligned"])
WINE_TRY_CFLAGS([-Wpragma-pack],[EXTRACFLAGS="$EXTRACFLAGS -Wno-pragma-pack"])
WINE_TRY_CFLAGS([-Wshift-overflow=2])