Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Windows' _aligned_malloc paired with _aligned_free for MinGW #310

Open
albinahlback opened this issue Jan 19, 2023 · 4 comments
Open

Comments

@albinahlback
Copy link

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?

@stevengj
Copy link
Contributor

stevengj commented Jan 20, 2023

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

@stevengj
Copy link
Contributor

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.)

@stevengj stevengj reopened this Jan 20, 2023
@albinahlback
Copy link
Author

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?

@stevengj
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants