Qt, GCC, SSE and stack alignment

前端 未结 2 895
一整个雨季
一整个雨季 2020-12-17 23:12

I\'m trying to make a program compiled with GCC and using Qt and SSE intrinsics. It seems that when one of my functions is called by Qt, the stack alignment is not preserved

相关标签:
2条回答
  • 2020-12-17 23:52
    __attribute__((force_align_arg_pointer)) void paintEvent(QPaintEvent *);
    

    made it work! Does anybody have a better solution?

    0 讨论(0)
  • 2020-12-17 23:59

    You can use the option -mstackrealign to do that without adding attributes to your source code:

    -mstackrealign Realign the stack at entry. On the Intel x86, the -mstackrealign option will generate an alternate prologue and epilogue that realigns the runtime stack if necessary. This supports mixing legacy codes that keep a 4-byte aligned stack with modern codes that keep a 16-byte stack for SSE compatibility. See also the attribute force_align_arg_pointer, applicable to individual functions.

    (from the GCC docs)

    0 讨论(0)
提交回复
热议问题