[fpc-devel] mstackrealign

Den Jean Den.Jean at telenet.be
Tue Nov 23 19:40:11 CET 2010


>> Does this also effect calling in general of C-functions from Free Pascal.

> Afaik, the Linux/i386 abi only mandates 4 byte stack alignment. That  
> means that any function requiring a higher stack alignment has to  
> realign the stack. That's what the new -mstackrealign gcc option does.

I am puzzled why some many projects seem to suffer from this (google),
Is it not just a matter of adding  __attribute__ ((force_align_arg_pointer))
to the functions with sse calls? Instead of compiling the whole code with -mstackrealign ?

The following extract from qglobal.h shows me it is only considered a problem on windows ?!

//defines the type for the WNDPROC on windows
//the alignment needs to be forced for sse2 to not crash with mingw
#if defined(Q_WS_WIN)
#  if defined(Q_CC_MINGW)
#    define QT_ENSURE_STACK_ALIGNED_FOR_SSE __attribute__ ((force_align_arg_pointer))
#  else
#    define QT_ENSURE_STACK_ALIGNED_FOR_SSE
#  endif
#  define QT_WIN_CALLBACK CALLBACK QT_ENSURE_STACK_ALIGNED_FOR_SSE 
#endif


When grepping the Qt source, I do see this attribute popping up in windows only files
like qdnd_win.cpp, so I am still puzzled why then with these precautions by Nokia Qt, 
it still does not work.


regards,

Den Jean



More information about the fpc-devel mailing list