This attribute is available since GCC 4.2.

The previous trick of using inline assembly for overriding the stack
pointer behind the compiler's back isn't guaranteed to work.

This fixes stack alignment on llvm/clang.

Signed-off-by: Martin Storsjö <mar...@martin.st>
---
 mingw-w64-crt/crt/crtexe.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/mingw-w64-crt/crt/crtexe.c b/mingw-w64-crt/crt/crtexe.c
index 4542bfe..e390074 100644
--- a/mingw-w64-crt/crt/crtexe.c
+++ b/mingw-w64-crt/crt/crtexe.c
@@ -221,6 +221,11 @@ int mainCRTStartup (void)
 }
 
 static
+#if defined(__i386__) || defined(_X86_)
+/* We need to make sure that we align the stack to 16 bytes for the sake of SSE
+   opts in main or in functions called main.  */
+__attribute__((force_align_arg_pointer))
+#endif
 __declspec(noinline) int
 __tmainCRTStartup (void)
 {
@@ -229,17 +234,6 @@ __tmainCRTStartup (void)
   WINBOOL inDoubleQuote = FALSE;
   memset (&StartupInfo, 0, sizeof (STARTUPINFO));
 
-#if defined(__i386__) || defined(_X86_)
-  /* We need to make sure that this function is build with frame-pointer
-     and that we align the stack to 16 bytes for the sake of SSE ops in main
-     or in functions inlined into main.  */
-  lpszCommandLine = (_TCHAR *) alloca (32);
-  memset (lpszCommandLine, 0xcc, 32);
-#ifdef __GNUC__
-  asm  __volatile__  ("andl $-16, %%esp" : : : "%esp");
-#endif
-#endif /* defined(__i386__) || defined(_X86_) */
-
   if (mingw_app_type)
     GetStartupInfo (&StartupInfo);
   {
-- 
2.7.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to