Skip to content

Some changes for basic support of MinGW #76

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mmuetzel
Copy link
Contributor

@mmuetzel mmuetzel commented Mar 17, 2025

These changes are still a hot mess. They compile on MINGW64 with the compilers from MSYS2.
But all tests are failing with errors like the following:

Start testing: Mar 17 21:14 Mitteleuropäische Zeit
----------------------------------------------------------
1/119 Testing: BLAS-xblat1s
1/119 Test: BLAS-xblat1s
Command: "C:/msys64/mingw64/bin/cmake.exe" "-DTEST=D:/repo/flexiblas/build/bin/xblat1s.exe" "-DINTDIR=." "-P" "D:/repo/flexiblas/test/blas/runtest.cmake"
Directory: D:/repo/flexiblas/build/test/blas
"BLAS-xblat1s" start time: Mar 17 21:14 Mitteleuropäische Zeit
Output:
----------------------------------------------------------
-- "D:/repo/flexiblas/build/lib" -- PATH
Running: D:/repo/flexiblas/build/bin/xblat1s.exe
ARGS= 
�[0;2;36m<flexiblas> Config D:\repo\flexiblas\etc/flexiblasrc does not exist.
�[0m�[0;2;36m<flexiblas> Configuration directory D:\repo\flexiblas\etc/flexiblasrc.d does not exists.
�[0m�[0;2;36m<flexiblas> User config C:\Users\Markus\AppData\Roaming\flexiblasrc does not exist.
�[0m�[0;2;36m<flexiblas> Host config (null) does not exist.
�[0m<flexiblas> Load enviroment config D:/repo/flexiblas/build/flexiblasrc
�[1;2;31mflexiblas Unable to load library: D:/repo/flexiblas/build/lib\libflexiblas_hook_dummy.dll.a
�[0m�[1;2;31mflexiblas Unable to load library: D:/repo/flexiblas/build/lib\libflexiblas_hook_profile.dll.a
�[0m�[1;2;31mflexiblas  Failed to load the BLAS fallback library 'flexiblas_netlib.dll'.  Abort!
�[0mCMake Error at D:/repo/flexiblas/test/blas/runtest.cmake:53 (message):
  Test D:/repo/flexiblas/build/bin/xblat1s.exe returned 3


<end of output>
Test time =   0.10 sec
----------------------------------------------------------
Test Failed.
"BLAS-xblat1s" end time: Mar 17 21:14 Mitteleuropäische Zeit
"BLAS-xblat1s" time elapsed: 00:00:00
----------------------------------------------------------

If I understand the error messages correctly, it is trying to load import libraries (with file extension .dll.a) which fails (unsurprisingly). Instead, it should be trying to load the dynamic load libraries (with file extension .dll which are installed in the bin folder on Windows).
I haven't looked yet into why that is happening. Any feedback would be very welcome.

Instead of adding a dependency on a dlopen wrapper library, I thought it might be better to use native Windows functions to load symbols from the libraries on runtime. (Might have a performance advantage. But since it doesn't run yet, I can't tell whether that is the case.)

There are also still a couple of FIXME comments where the implementation isn't complete yet. I figured that it might still make sense to share what I have so far.

@grisuthedragon
Copy link
Member

Since there are many constructions like

#ifdef __WIN32__
        ptr  = GetProcAddress(backend->library_handle, fn_name);
#else
        ptr  = dlsym(backend->library_handle, fn_name);
#endif

to get rid of the dlfcn-win32 functionality, we should consider to write a file containing wrappers for dlsym and so on, such that we only have to adjust stuff at one place and keep the remaining code (and its logic) better readable.

Loading symbols from shared libraries requires different mechanisms on
Windows (compared to Linux or macOS). Add helper functions that
encapsulate these differences for some tasks that are done repeatedly.
That concentrated of platform-specific code in less places and makes
maintenance easier.
@mmuetzel
Copy link
Contributor Author

Thanks for the feedback.
I tried to introduce a couple of helper functions that can be called independent on the host OS and encapsulate the target-specific code. There should be a lot less places now with pre-processor conditions like #ifdef __WIN32__.

I also rebased on the branch that triggers the CI on pull requests. (And already found a regression that should be fixed now.)

I'm still at a loss as to where the flexiblas Unable to load library: D:/repo/flexiblas/build/lib\libflexiblas_hook_dummy.dll.a message is coming from.
That looks very suspicious. But is that the actual error? Or is it failing for some other reason?

@grisuthedragon
Copy link
Member

grisuthedragon commented Mar 18, 2025 via email

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

Successfully merging this pull request may close these issues.

2 participants