From: Zebediah Figura zfigura@codeweavers.com
62173699c38453777c7d5638ed2e779790506b75 exposed multiple gcc bugs related to stack alignment. While there seems to be motion to fix these bugs in gcc, it seems prudent to work around them for now in Wine.
Instead of restoring __force_align_arg_pointer__ for all entry points, however, this patch takes a simpler approach, and one that is effectively the same as how this bug will eventually be solved upstream. We do not need to align every entry point, only those functions which will actually use aligned types.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55007 --- configure | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++- configure.ac | 5 +++- 2 files changed, 67 insertions(+), 2 deletions(-)
diff --git a/configure b/configure index aad417e0547..788647f18db 100755 --- a/configure +++ b/configure @@ -11322,6 +11322,39 @@ printf "%s\n" "$ac_res" >&6; } if eval test "x$"$as_ac_var"" = x"yes" then : as_fn_append ${wine_arch}_EXTRACFLAGS " -fno-omit-frame-pointer" +fi } + { as_ac_var=`printf "%s\n" "ac_cv_${wine_arch}_cflags_-mpreferred-stack-boundary=2" | $as_tr_sh` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -mpreferred-stack-boundary=2" >&5 +printf %s "checking whether $CC supports -mpreferred-stack-boundary=2... " >&6; } +if eval test ${$as_ac_var+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_wine_try_cflags_saved=$CFLAGS +ac_wine_try_cflags_saved_exeext=$ac_exeext +CFLAGS="$CFLAGS -nostdlib -nodefaultlibs -mpreferred-stack-boundary=2" +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 : + eval "$as_ac_var=yes" +else $as_nop + eval "$as_ac_var=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +CFLAGS=$ac_wine_try_cflags_saved +ac_exeext=$ac_wine_try_cflags_saved_exeext +fi +eval ac_res=$$as_ac_var + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } +if eval test "x$"$as_ac_var"" = x"yes" +then : + as_fn_append ${wine_arch}_EXTRACFLAGS " -mpreferred-stack-boundary=2" fi } { as_ac_var=`printf "%s\n" "ac_cv_${wine_arch}_cflags_-Wl,--disable-stdcall-fixup" | $as_tr_sh` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wl,--disable-stdcall-fixup" >&5 @@ -19247,7 +19280,8 @@ fi ;; esac
case $host_cpu in - *i[3456789]86*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -fno-omit-frame-pointer" >&5 + *i[3456789]86*) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -fno-omit-frame-pointer" >&5 printf %s "checking whether the compiler supports -fno-omit-frame-pointer... " >&6; } if test ${ac_cv_cflags__fno_omit_frame_pointer+y} then : @@ -19274,6 +19308,34 @@ printf "%s\n" "$ac_cv_cflags__fno_omit_frame_pointer" >&6; } if test "x$ac_cv_cflags__fno_omit_frame_pointer" = xyes then : MSVCRTFLAGS="$MSVCRTFLAGS -fno-omit-frame-pointer" +fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -mpreferred-stack-boundary=2" >&5 +printf %s "checking whether the compiler supports -mpreferred-stack-boundary=2... " >&6; } +if test ${ac_cv_cflags__mpreferred_stack_boundary_2+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_wine_try_cflags_saved=$CFLAGS +CFLAGS="$CFLAGS -mpreferred-stack-boundary=2" +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__mpreferred_stack_boundary_2=yes +else $as_nop + ac_cv_cflags__mpreferred_stack_boundary_2=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +CFLAGS=$ac_wine_try_cflags_saved +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cflags__mpreferred_stack_boundary_2" >&5 +printf "%s\n" "$ac_cv_cflags__mpreferred_stack_boundary_2" >&6; } +if test "x$ac_cv_cflags__mpreferred_stack_boundary_2" = xyes +then : + MSVCRTFLAGS="$MSVCRTFLAGS -mpreferred-stack-boundary=2" fi ;; *x86_64*) case $host_os in diff --git a/configure.ac b/configure.ac index 5676e35f2b9..a1fc739dd9c 100644 --- a/configure.ac +++ b/configure.ac @@ -971,6 +971,7 @@ This is an error since --enable-archs=$wine_arch was requested.])])
case $wine_arch in i386) WINE_TRY_PE_CFLAGS([-fno-omit-frame-pointer]) + WINE_TRY_PE_CFLAGS([-mpreferred-stack-boundary=2]) WINE_TRY_PE_CFLAGS([-Wl,--disable-stdcall-fixup], [AS_VAR_APPEND([${wine_arch}_LDFLAGS],[" -Wl,--disable-stdcall-fixup"])]) ;; x86_64) WINE_TRY_PE_CFLAGS([-Wformat-overflow]) @@ -1916,7 +1917,9 @@ char*f(const char *h,char n) {return strchr(h,n);}]])],[ac_cv_c_logicalop_noisy=
case $host_cpu in dnl gcc-4.6+ omits frame pointers by default, breaking some copy protections - *i[[3456789]]86*) WINE_TRY_CFLAGS([-fno-omit-frame-pointer],[MSVCRTFLAGS="$MSVCRTFLAGS -fno-omit-frame-pointer"]) ;; + *i[[3456789]]86*) + WINE_TRY_CFLAGS([-fno-omit-frame-pointer],[MSVCRTFLAGS="$MSVCRTFLAGS -fno-omit-frame-pointer"]) + WINE_TRY_CFLAGS([-mpreferred-stack-boundary=2],[MSVCRTFLAGS="$MSVCRTFLAGS -mpreferred-stack-boundary=2"]) ;; *x86_64*) case $host_os in dnl Mingw uses Windows 64-bit types, not Unix ones