-
Notifications
You must be signed in to change notification settings - Fork 133
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
Allow build dft on MinGW #540
Conversation
It actually works fine.
I don't know about gcc, but at least llvm-mingw works fine, I used sleefdft for rubberband's fft library and got better performance than fftw. |
Hello! We are a bit concerned about the absence of testing for this one. But I suppose DFT can still be disabled manually. |
Btw thanks for testing and reporting this, very useful! I'll try to test locally. |
These tests don't support MinGW
Some platforms such as MSYS2 provide a broken libcrypto.pc, this is needed to fix statically link build.
To fix cross-compilation compatibility
I'll try to add a MSYS2 CI that can test gcc and clang. but expect some things to not work. MSYS2 also support clang arm64 and I've done a preliminary evaluation of arm64 build with my cross build toolchain, but that's hard to do in the CI since GHA doesn't support Windows Arm64 runner. |
Unfortunately, the mingw-w64 gcc does not work at all. But clang passes the test, will add msys2 native build & test and llvm-mingw aarch64 & x86_64 cross build later. |
Yes, it is most likely why we were holding it for now. But we would be ok to start with only a subset of the tests.
Yes, we have also done some work to enable Windows on Arm (for sleef/libm) that is not yet upstream, happy to try and merge that soon if that can help. However as you said it is not available on GH-hosted runners, so we will have to keep testing internally for now. |
Thanks for the contribution, impressive GHA skills! I like the idea of the build/test-msys2 jobs, we were definitely missing testing for Windows (x86). On the other hand, we did not desperately need a precommit workflow for llvm-mingw, but it is quite handy to be able to (cross-)compile for windows on both x86 and arm64, so happy try and merge that too. Before getting into the details, would you mind moving both jobs to separate yaml files (even if it means duplicating code for build-native)? We might want to schedule and parametrise the 3 workflows differently. Btw if you are aware of simple/nice ways to re-use bits of workflows (say build-native) in other workflows, please let us know. |
Most MinGW users are cross-compile on Linux because the build are an order of magnitude faster, so I'd prefer cross-compile to be a first-class citizen.
Done. Native build are usually very fast, and since there is no longer need to pass native build files via artifacts, this is actually faster.
One possible way to do this is to save native builds to action cache, which is quite a bit faster than artifacts and can across workflows. But I suspect this would still be slower than build native and cross within same instance. |
Thanks for the insight, action cache might be useful for other jobs. I like the present solution though, hopefully in the future a native build isn't even needed to cross-compile. |
Regarding the libm and quad tests on msys2, would you be able to link us to the build or test failures? Do you have suggestions on ways to port a code that relies on wait.h (wait, fork, ...) to mingw/msys2? @shibatch Have you ever considered ways to make the libm tester compatible with mingw? |
Since tester1 does not need to be compiled with mingw, the test should be possible by combining tester1 for Cygwin or linux, although it may be a bit troublesome to write the script for the test. Another idea could be to add a new tester using tlfloat, which I am currently developing. With tlfloat, testing is possible even if libmpfr is not available. |
Fair, it's true that they can be compiled independently, but I'm afraid this will confuse things more than they already are on Windows.
That could be interesting! Looks like you already have support for several OS-es there too. Mpfr is not the worst dependency to have, but always good to remove dependencies I suppose. Would tlfloat resolve the dependency on wait.h and POSIX in general? Is it able to handle multithreading too? Alternatively, we could look at straight windows port for wait.h https://github.com/win32ports/sys_wait_h ? |
The new tester can be made pipe-free and multi-threading capable. |
I suggest we create an issue specifically for this? |
Writing an Issue is fine, but there are other things to consider regarding this. If we implement the fp16 support mentioned here, it could be related to that as well. |
_install-* | ||
if: always() | ||
|
||
test-msys2: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we display information on the cpu in this job at least? Equivalent to what we have in the linux workflow:
https://github.com/shibatch/sleef/actions/runs/8845094575/workflow#L102
Ideally in all jobs but that might be a bit much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
-DCMAKE_INSTALL_PREFIX="$(pwd)/_install-${{ matrix.arch }}" \ | ||
-DCMAKE_SYSROOT="$(pwd)/llvm-mingw/${{ matrix.arch }}-w64-mingw32" \ | ||
-DNATIVE_BUILD_DIR="$(pwd)/_build-native" \ | ||
${COMMON_CMAKE_FLAGS} \ | ||
-DCMAKE_C_COMPILER=${{ matrix.arch }}-w64-mingw32-clang \ | ||
-DCMAKE_ASM_COMPILER=${{ matrix.arch }}-w64-mingw32-clang \ | ||
-DCMAKE_SYSTEM_NAME=Windows \ | ||
-DCMAKE_SYSTEM_PROCESSOR=${{ matrix.arch }} \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we can rely on a toolchain file for most of these options? Our toolchain files are located in https://github.com/shibatch/sleef/tree/master/toolchains.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this makes sense, ideally llvm-mingw is multi-target, in order to support multiple targets, toolchain.cmake only include platform specific not architecture specific, which actually means that toolchain.cmake only include CMAKE_SYSTEM_NAME=Windows.
#- mingw64 | ||
#- ucrt64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we have a quick comment saying why these are commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mingw64 and ucrt64 are gcc envs, and gcc is completely broken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have any more details on that, maybe a link? Is the compiler broken or is it SLEEF when compiled in a gcc envs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-DNATIVE_BUILD_DIR="$(pwd)/_build-native" \ | ||
${COMMON_CMAKE_FLAGS} \ | ||
-DCMAKE_C_COMPILER=${{ matrix.arch }}-w64-mingw32-clang \ | ||
-DCMAKE_ASM_COMPILER=${{ matrix.arch }}-w64-mingw32-clang \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CMAKE_ASM_COMPILER
one does not seem to be used, could just rm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
904a57d
to
d663a23
Compare
Made some fixes and cleanups, and enabled LTO for clang. |
</tr> | ||
<tr align="center"><th>x86_64</th><th>SSE2, SSE4,<br>AVX, AVX2, AVX512F</th> | ||
<td>:green_circle:</td><td>:green_circle:</td><td>:white_circle:</td> | ||
<td>:white_circle:</td><td>:white_circle:</td> | ||
<td>:white_circle:</td><td>:white_circle:</td><td>:white_circle:</td> | ||
<td>:white_circle:</td><td>:green_circle:</td><td>:white_circle:</td><td>:white_circle:</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking the time to document that.
In this case only DFT is tested though. What we do at the moment is at least add a comment in the following subsections, here Component support
section should indicate that on Windows only DFT is tested but everything is built.
Let's not bother in this patch but we should probably use a different colour scheme when only part of the library is tested, or when component is compiled only and not tested. Ultimately, this could probably be mapped to the workflow/job status.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
msys2 clang and llvm-mingw cross
Subdivided Windows LLVM into llvm-gnu and llvm-msvc to distinguish between *-w64-mingw32 (aka *-pc-windows-gnu) and *-pc-windows-msvc targets. Updated Windows AArch64 from N/A to Not tested in CI.
run: | | ||
EXTRA_CMAKE_FLAGS="" | ||
if [[ ${{ matrix.sys }} = "clang64" ]]; then | ||
EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DSLEEF_ENABLE_LTO=ON" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please test without LTO for now? I would like to test SLEEF's basic features primarily, and test LTO separately if that's ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added lto matrix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, works for me. But please refrain from adding too many variants/parameters as we have limited resources to address failures. Also special casing for combinations of parameters is a bit gross in GHA workflow files.
EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DSLEEF_ENABLE_LTO=ON" | ||
EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DSLEEF_ENFORCE_SSE2=ON -DSLEEF_ENFORCE_SSE4=ON -DSLEEF_ENFORCE_AVX=ON -DSLEEF_ENFORCE_AVX2=ON -DSLEEF_ENFORCE_AVX512F=ON -DSLEEF_ENFORCE_FMA4=ON" | ||
elif [[ ${{ matrix.sys }} = "clangarm64" ]]; then | ||
EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DSLEEF_ENABLE_LTO=ON" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, can we remove LTO for now.
-DSLEEF_BUILD_SCALAR_LIB=ON | ||
-DSLEEF_BUILD_STATIC_TEST_BINS=ON | ||
-DSLEEF_BUILD_TESTS=OFF | ||
-DSLEEF_ENABLE_LTO=ON |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
Rename yml to msys2 and llvm-mingw to avoid conflicts with future msvc/llvm-msvc{msvc-style, gnu-style}/llvm-msvc-cross{msvc-style, gnu-style}. |
Are you happy for me to merge? |
Yes, LGTM. |
It actually works fine.