Allow native Windows build using MinGW#30
Conversation
|
cc @dimpase |
|
@tobiasdiez Just FYI. It's a little early because the PR has not been merged yet, but it gives a working build that passes all tests (make check). |
|
@dimpase I added CI for Windows and updated the README. I tested the CI workflows and also fixed a few things that caused errors:
|
tests/Makefile.am
Outdated
| DEFINES = | ||
| # include TOPBUILDIR for m4ri_config.h | ||
| AM_CFLAGS = -I$(TOPSRCDIR) -I$(TOPBUILDDIR) -D_XOPEN_SOURCE=600 $(DEFINES) @OPENMP_CFLAGS@ @PAPI_CFLAGS@ @LIBPNG_CFLAGS@ | ||
| AM_CFLAGS = -I$(TOPSRCDIR) -I$(TOPBUILDDIR) -I$(TOPBUILDDIR)/m4ri -D_XOPEN_SOURCE=600 $(DEFINES) @OPENMP_CFLAGS@ @PAPI_CFLAGS@ @LIBPNG_CFLAGS@ |
There was a problem hiding this comment.
Before this PR, configure automatically added -I to every subdirectories, which was causing the standard library io.h (only on MinGW Windows) got hidden by m4ri\io.h.
Then, with the addition of nostdinc in configure.ac, we stop this automatic -I additions, manually added them in Makefile.am and tests/Makefile.am strategically.
Specifically, without this, for example test_elimination will break during make distcheck because it indirectly includes misc.h (through testing.h) that has:
#include "config.h", which won't resolve (because it is under m4ri subdirectory).
In retrospect, this probably should also be -iquote similar to the other Makfile.am change to prevent potential future problem. Currently -I works here I think just because there is no indirect call to "#include <io.h>" from within the standard library during tests, so I am changing this to iquote in my new amended commit.
|
Thank you for your review. I have replied to each and made the two changes I mentioned: one for the -iquote and the other for README, as you suggested. |
|
Thanks for doing this, btw |
The unsigned long size in gcc on 64-bit Linux is 64-bit while on MinGW on 64-bit Windows is 32-bit (compiled with MinGW). This not only cause compilation error but also failing tests on MinGW.
The use of > unintentionally creates a file (interpreted as bash) instead of comparison. When they are hits, they created files like x80000004, etc. Instead, \> gives an actual comparison.
MinGW does not support random and srandom, so a fallback to rand and srand is implemented for those cases.
Without this change, #include<io.h> will include m4ri's io.h, which hides the io.h from MinGW's standard library. After this change, there are three ways to include a header (let's name it `x.h`) from m4ri directory: `#include "x.h"`, `#include <m4ri/x.h>`, or `#include "m4ri/x.h"`. This means, `#include<io.h>` will correctly resolve to the standard library io.h instead of `m4ri/io.h`
This change allow the linker to figure out the dll created for Windows.
This will suppress the warning because MinGW does not support -no-install.
|
Thank you for the comments! I have updated the code accordingly. |
|
Thank you for the reviews! |
This PR contains commits that allow both make and make check to work on MinGW. The commits were tested on both MinGW (through MSYS UCRT64) and Linux gcc (through WSL). However, this does not allow us to build bench on MinGW, which seems to be significantly more difficult.
As a context, this native Windows build will help us to create a native Windows build for Sagemath: sagemath/sage#38872