Tristan Matthews
2015-Mar-09 22:41 UTC
[flac-dev] [PATCH 1/1] ensure that stack is aligned for SSE functions if using mingw32
Unable to test on win32 at the moment, please give this a try. Feedback welcome. Avoids crashes due to unaligned ops when built with mingw. --- src/libFLAC/include/private/cpu.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/libFLAC/include/private/cpu.h b/src/libFLAC/include/private/cpu.h index 8927897..bd40012 100644 --- a/src/libFLAC/include/private/cpu.h +++ b/src/libFLAC/include/private/cpu.h @@ -72,8 +72,13 @@ #define FLAC__FMA_SUPPORTED 1 #endif #elif defined __GNUC__ + #ifdef __MINGW32__ + #define FLAC__STACK_ALIGN __attribute__((force_align_arg_pointer)) + #else + #define FLAC__STACK_ALIGN + #endif /* SSE stack alignment fixups */ #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) /* since GCC 4.9 -msse.. compiler options aren't necessary */ - #define FLAC__SSE_TARGET(x) __attribute__ ((__target__ (x))) + #define FLAC__SSE_TARGET(x) __attribute__ ((__target__ (x))) FLAC__STACK_ALIGN #define FLAC__SSE_SUPPORTED 1 #define FLAC__SSE2_SUPPORTED 1 #define FLAC__SSSE3_SUPPORTED 1 @@ -82,7 +87,7 @@ #define FLAC__AVX2_SUPPORTED 1 #define FLAC__FMA_SUPPORTED 1 #else /* for GCC older than 4.9 */ - #define FLAC__SSE_TARGET(x) + #define FLAC__SSE_TARGET(x) FLAC__STACK_ALIGN #ifdef __SSE__ #define FLAC__SSE_SUPPORTED 1 #endif -- 2.1.0
lvqcl
2015-Mar-09 22:59 UTC
[flac-dev] ensure that stack is aligned for SSE functions if using mingw32
Tristan Matthews wrote:> Unable to test on win32 at the moment, please give this a try. Feedback welcome.I wonder why misaligned stack is a problem only for the FLAC library. There are many other libraries inside VLC... BTW: FLAC 1.3.1 uses -msse2 option by default. Do you remove it? Otherwise libFLAC may crash anywhere else (if its stack is not aligned).
Dave Yeo
2015-Mar-09 23:57 UTC
[flac-dev] ensure that stack is aligned for SSE functions if using mingw32
On 03/09/15 03:59 PM, lvqcl wrote:> Tristan Matthews wrote: > >> >Unable to test on win32 at the moment, please give this a try. Feedback welcome. > > I wonder why misaligned stack is a problem only for the FLAC library. > There are many other libraries inside VLC... > > BTW: FLAC 1.3.1 uses -msse2 option by default. Do you remove it? > Otherwise libFLAC may crash anywhere else (if its stack is not aligned).One workaround is to use -mstackrealign where ever -msse2 is used Dave
Reasonably Related Threads
- ensure that stack is aligned for SSE functions if using mingw32
- [PATCH 1/1] ensure that stack is aligned for SSE functions if using mingw32
- [PATCH] configure: only use -mstackrealign for mingw32
- [PATCH] configure: only use -mstackrealign for mingw32
- [PATCH] configure: only use -mstackrealign for mingw32