openframeworks/openFrameworks — pull request #1265 by gameoverhack (2012-05-17 19:15:50+00:00)
Title: Better fix for issue #1253. openCV 2.3.1 mingw32 compiled with SSE/SSE2, -O3 and -mstackrealign

Turns out the problem with the openCV libs on mingw32 is a very old bug to do with the implementation of SSE/SSE2 in GNU GCC or in the way that individual functions/libraries align bits on the stack.

Boiling it all down: what (I think) happens is that non-aligned code calls an aligned stack and you get a segmentation fault.

There seem to be 2 workarounds: compiling with -mpreferred-stack-boundary=2 or -mstackrealign ... it's all a bit over my head but it seems that - the latter is the better way to go, see:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40838#c80

and the feedback from openCV bug report:

http://code.opencv.org/issues/1932#note-3

Both workarounds bring efficiency back to same or better than VS openCV 2.3.1 lib performance.