-
Notifications
You must be signed in to change notification settings - Fork 76
Add github actions build file for MinGW-W64 #102
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
Add github actions build file for MinGW-W64 #102
Conversation
Thanks for the PR! Compatibility with MinGW is a good thing and once I've figured out how to mark CI targets as optional (i.e., only run them when explicitly requested) I'll add it. As it is, it shouldn't be needed. Even though liblsl is a C++ library, the entire API/ABI has only plain C types / functions and the C++ include header calls the C functions behind the scenes so liblsl compiled with MSVC should be loadable from a program compiled with MinGW and vice versa.
Fixed in 7fcc1bf.
For entire steps, you can add conditions, e.g. liblsl/.github/workflows/cppcmake.yml Lines 63 to 67 in 7fcc1bf
|
I tried integrating your changes into the main CI config, but the compiler / shell has an issue with a string definition passed via the CLI:
Neither MSVC on Windows nor g++ on Linux have a problem with |
Interesting! Can you point me to the build file and an github actions log, I would be interested in finding the cause. |
Sure, the log is here and the commit here. Just in case you can't access the build log, I've also uploaded it: buildlog.txt.gz I think the main issue is that the build steps are running in the bash shell, not the msys shell, but I'd rather avoid changing the shell for every step. |
Thanks for the pointers. I still do not understand how this double-decimal-point error occurs. But I saw that your build was using an older compiler installed by chocolatey and the bash shell from the git installation instead of from msys2. I agree that it is undesirable to extend every step with a shell setting. Alternative suggestion here: https://github.com/tobiasherzke/liblsl/commit/13dac557fc4dcc77b75ebbbfc670714b84a3ec47 the shell is again specified only once in the file, but in a different place to allow a different shell for MinGW. This change builds the liblsl DLL. The unit test stage still fails, but it is one step further. |
Without the quotes, the compiler tries to make sense of
Nice, I didn't know you could put the
A segfault shouldn't happen, especially when testing the exported methods. The segfault seems to happen in the |
Reproducing on a local windows installation: In order to reproduce the steps from the build file, I need
When executing the steps from the Makefile locally, I can reproduce the segmentation fault. When reproducing the segmentation fault in the debugger, it does not give me any information in the backtrace. In order to recompile with debug info, I have changed "Release" to "Debug" in the two cmake invocations that had "Release". After doing this, there is no directory "install", but I can find the two test executables in build/testing. The internal tests succeed as before. The exported tests fail, but without producing the segmentation fault. The output is:
but the diagnostic output is not stable: in the next run, it is
and in the next
Hope this helps and you can make sense of it. My first guess when seeing this would be usage of uninitialized memory. (In that case, running the same test on Linux with valgrind would reliably diagnose it as such. It could also explain a segfault.) |
Valgrind does not report uninitialized memory on Linux (see https://github.com/tobiasherzke/liblsl/commit/af99b67582149c430ca696fe452e9194be80aabf#diff-71cc08be7d433f3916799b252b7ae38be718a330946ec1399e8361276cd6bb40) which makes this explanation unlikely. Something else indeterministic must be going on. |
As always I appreciate your thoroughness, and while typing out why this shouldn't happen and MinGW is to blame, I found the error but it still doesn't fix the issue. The That being said, it's time to quote Phil Karlton:
The last element of After fixing it, it still segfaults. Maybe MinGW really is to blame? |
…tobiasherzke for debugging the issue
Use github actions to also build for MinGW-W64. Uses msys2 environment. For the current gcc-10.3 compiler on msys, * link-time optimization needs to be disabled to avoid linker errors, * -O3 needs to be disabled to avoid errors with thread- local storage across DLL borders.
Initially, I found this hard to believe, because it's usually not the compiler's fault. But now, after extensive recompilations, printfs and retryings, I think you are right. The current MinGW-W64 compiler 10.3 (as packaged by msys2) somehow messes up the thread-local storage when that TLS is defined in a DLL, and optimization is I'll try to update this pull request with a working modification of cppcmake.yml. Because I do not know cmake very well, I'll simply use --target=Debug for MinGW to disable What my proposed change does not fix is the thread-local-storage in the loguru library that you use by source inclusion. I believe you will be able to fix that by replacing |
c60ae9e
to
05fcd77
Compare
0bd89ad demonstrates this problem by adding a test which exposes it. |
e0fce48 suggests a fix. |
Normally I'd agree, but when the compiler has an internal error for code MSVC, GCC and Clang accept without any warnings it's reason to get suspicious.
Building against all optimization levels
Looks good to me. We (and for authorship credits, I mean you 😄) should submit a PR to the upstream repository (https://github.com/emilk/loguru). |
And it's fixed: tstenner@a1f8679 |
I have pushed the changes that allow MinGW to build liblsl even with optimizations. There's one issue: as liblsl is compiler-agnostic, the packages are named after the platform and architecture and the windows package names are already taken by the MSVC packages. I can think of two options:
|
Thank you!
You need to decide this, obviously this is not my decision. I would prefer 1) because then github actions will inform you if any changes that you make to liblsl causes problems with MinGW. This can be a liability because, as we have seen here, the MinGW compiler has some peculiarities. But it is also a chance for you to detect more possible problems in the code because one more compiler will mean more/different code analysis during compilation. The number of places in the code that were causing problems were very few, after all. And if in future the liability aspect causes too much work, you can always disable the MinGW build then. Especially if you do not publish it with your releases, then you will also not grow any significant user base that would depend on it. |
FYI, this is how we build liblsl on windows for the MinGW compiler. As liblsl is a C++ library, users who write applications that use liblsl need to have their liblsl compiled with the same compiler as their application.
The build file is derived from your cross-platform build file. Compare against that file to find the differences. I was not sure how to integrate the different default shell settings required for this build (msys2) and all other platforms (bash) in github actions.
I have disabled examples and unit-tests because I get a linker error in one of them. I do not remember which, I remember that it is possible to fix the linker command manually quite easily, but I do not know enough cmake to fix it in the build system.
This pull request is mainly FYI. I for one would very much like if you accept it or merge into your cross-platform build file, but your priorities may lie elsewhere.