FFTW/fftw3

Use Windows' `_aligned_malloc` paired with `_aligned_free` for MinGW

albinahlback opened this issue · 4 comments

Currently cross-compiling with MinGW (in my case from Linux to Windows) generates an error due to line 131 in kernel/kalloc.c. I am no expert in MinGW, but I suppose one would actually utilize the same case as for MSVC at line 106.

This works for my setup at least. Perhaps there are cases where this won't work?

On MinGW you should configure with the flag --with-our-malloc (which is effectively equivalent to _aligned_malloc), similar to https://github.com/FFTW/fftw3/blob/master/support/BUILD-MINGW64.sh

But I guess we could try to automatically use _aligned_malloc on MinGW now that they provide this function. (They didn't used to IIRC.)

But I guess we could try to automatically use _aligned_malloc on MinGW now that they provide this function. (They didn't used to IIRC.)

Looking at an answer on StackOverflow, it seems like MinGW has provided _aligned_malloc since at least 2016. Perhaps the best way is to check whether _aligned_alloc is available during the configuration for Windows-type machines?

Or we could check for _mm_malloc and _mm_free, since it sounds like those are supported even more widely.