Skip to content

Commit f386fd6

Browse files
committed
First stage of Mingw build support (#171). What remains is to replace
signal_guard in quickcpplib, as it'll never be mingw compatible.
1 parent b3c9308 commit f386fd6

File tree

15 files changed

+975
-544
lines changed

15 files changed

+975
-544
lines changed

.github/workflows/unittests_windows.yml

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,43 +26,77 @@ jobs:
2626
id: vars
2727
shell: bash
2828
run: |
29-
if [ "${{ matrix.image }}" = "windows-2025" ]; then
30-
NAME=VS2025;
31-
GENERATOR="Visual Studio 18 2025";
32-
else
33-
NAME=VS2022;
34-
GENERATOR="Visual Studio 17 2022";
35-
fi
36-
echo ::set-output name=NAME::${NAME}
37-
echo ::set-output name=GENERATOR::${GENERATOR}
29+
if [ "${{ matrix.image }}" = "windows-2025" ]; then
30+
NAME=VS2025;
31+
GENERATOR="Visual Studio 18 2025";
32+
else
33+
NAME=VS2022;
34+
GENERATOR="Visual Studio 17 2022";
35+
fi
36+
echo ::set-output name=NAME::${NAME}
37+
echo ::set-output name=GENERATOR::${GENERATOR}
3838
39-
39+
4040
- name: CMake tests Windows
4141
shell: bash
4242
env:
4343
NAME: ${{ steps.vars.outputs.NAME }}-${{ matrix.configuration }}
4444
run: |
45-
if [ "${{ matrix.configuration }}" = "status_code" ]; then
46-
export CMAKE_CONFIGURE_OPTIONS="-DLLFIO_USE_EXPERIMENTAL_SG14_STATUS_CODE=ON"
47-
fi
48-
ctest -S .ci.cmake -VV --timeout 900 "-DCTEST_CONFIGURE_OPTIONS=$CMAKE_CONFIGURE_OPTIONS" -DCTEST_SITE=$NAME -DCTEST_CMAKE_GENERATOR="${{ steps.vars.outputs.GENERATOR }}"
49-
45+
if [ "${{ matrix.configuration }}" = "status_code" ]; then
46+
export CMAKE_CONFIGURE_OPTIONS="-DLLFIO_USE_EXPERIMENTAL_SG14_STATUS_CODE=ON"
47+
fi
48+
ctest -S .ci.cmake -VV --timeout 900 "-DCTEST_CONFIGURE_OPTIONS=$CMAKE_CONFIGURE_OPTIONS" -DCTEST_SITE=$NAME -DCTEST_CMAKE_GENERATOR="${{ steps.vars.outputs.GENERATOR }}"
49+
5050
- name: Upload Prebuilt Binaries
5151
uses: actions/upload-artifact@v4
5252
with:
5353
name: Windows ${{ steps.vars.outputs.NAME }} ${{ matrix.configuration }} prebuilt binaries
5454
path: llfio-v2.0-binaries-win64.zip
55-
55+
5656
- name: Upload Test Results
5757
if: always()
5858
uses: actions/upload-artifact@v4
5959
with:
6060
name: Windows ${{ steps.vars.outputs.NAME }} ${{ matrix.configuration }} test results
6161
path: prebuilt/merged_junit_results.xml
6262

63+
WinMinGW:
64+
name: MinGW-MSYS2
65+
strategy:
66+
fail-fast: false
67+
matrix:
68+
configuration: [error_code, status_code]
69+
runs-on: windows-latest
70+
71+
steps:
72+
- uses: msys2/setup-msys2@v2
73+
with:
74+
msystem: MINGW64
75+
update: true
76+
install: mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja
77+
78+
- uses: actions/checkout@v4
79+
80+
- name: CMake tests Windows
81+
shell: msys2 {0}
82+
env:
83+
NAME: MinGW-${{ matrix.configuration }}
84+
run: |
85+
if [ "${{ matrix.configuration }}" = "status_code" ]; then
86+
export CMAKE_CONFIGURE_OPTIONS="-DLLFIO_USE_EXPERIMENTAL_SG14_STATUS_CODE=ON"
87+
fi
88+
ctest -S .ci.cmake -VV --timeout 900 "-DCTEST_CONFIGURE_OPTIONS=$CMAKE_CONFIGURE_OPTIONS" -DCTEST_SITE=$NAME -DCTEST_CMAKE_GENERATOR=Ninja
89+
90+
- name: Upload Test Results
91+
if: always()
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: Windows MinGW ${{ matrix.configuration }} test results
95+
path: prebuilt/merged_junit_results.xml
96+
6397
publish-test-results:
6498
name: "Publish Unit Tests Results"
65-
needs: [WinVS2022]
99+
needs: [WinVS2022, WinMinGW]
66100
runs-on: ubuntu-latest
67101
if: success() || failure()
68102

AGENTS.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Agentic coding guidelines
2+
3+
The main git repository for this project is at https://github.com/ned14/llfio.
4+
5+
1. All source, header and test files MUST be kept compatible with the 2017
6+
ISO C++ standard. Where using a latest ISO C++ standard feature would make
7+
sense, try to use the existing preprocessor macro infrastructure where
8+
possible. Otherwise ask for direction on what to do.
9+
2. Run `clang-format` on every changed header and source file. Do NOT run
10+
`clang-format` on cmake files.
11+
3. When building and testing, extract what to do for the current platform
12+
from `.github/workflows/unittests_*.yml`.

Build.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ These compilers and OSs are regularly tested by CI:
66
- [Clang](https://clang.llvm.org/) on Linux
77
- Xcode on Mac OS
88
- Visual Studio on Windows
9+
- MinGW on Windows (note that you'll get lots of warnings)
910

1011
Other compilers, architectures and OSs may work, but are not tested regularly.
1112
You will need a working Filesystem implementation in your STL, and at least C++ 17.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
set(CMAKE_SYSTEM_NAME Windows)
2+
set(CMAKE_SYSTEM_PROCESSOR x86_64)
3+
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
4+
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
5+
set(CMAKE_CXX_FLAGS_INIT "-DLLFIO_DISABLE_SIGNAL_GUARD=1") ## temporary
6+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
7+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
8+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
9+
set(CXX_HAS_CXX17_FILESYSTEM_EXITCODE 0)

include/llfio/revision.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time
2-
#define LLFIO_PREVIOUS_COMMIT_REF aa1077c18f704607a40417ba3b10b424c66fde3d
3-
#define LLFIO_PREVIOUS_COMMIT_DATE "2025-12-17 17:13:08 +00:00"
4-
#define LLFIO_PREVIOUS_COMMIT_UNIQUE aa1077c1
2+
#define LLFIO_PREVIOUS_COMMIT_REF b3c9308f143e27161c40f6d52a8fd18e8f05761b
3+
#define LLFIO_PREVIOUS_COMMIT_DATE "2026-01-18 17:53:09 +00:00"
4+
#define LLFIO_PREVIOUS_COMMIT_UNIQUE b3c9308f

include/llfio/v2.0/detail/impl/windows/byte_io_handle.ipp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* A handle to something
2-
(C) 2015-2021 Niall Douglas <http://www.nedproductions.biz/> (11 commits)
2+
(C) 2015-2026 Niall Douglas <http://www.nedproductions.biz/> (11 commits)
33
File Created: Dec 2015
44
55
@@ -25,9 +25,6 @@ Distributed under the Boost Software License, Version 1.0.
2525
#include "../../../byte_io_handle.hpp"
2626
#include "import.hpp"
2727

28-
#include <WinSock2.h>
29-
#include <ws2ipdef.h>
30-
3128
LLFIO_V2_NAMESPACE_BEGIN
3229

3330
size_t byte_io_handle::_do_max_buffers() const noexcept
@@ -46,7 +43,8 @@ size_t byte_io_handle::_do_max_buffers() const noexcept
4643
}
4744

4845
template <class BuffersType>
49-
inline bool do_cancel(const native_handle_type &nativeh, span<windows_nt_kernel::IO_STATUS_BLOCK> ols, byte_io_handle::io_request<BuffersType> reqs) noexcept
46+
inline bool do_cancel(const native_handle_type &nativeh, span<windows_nt_kernel::IO_STATUS_BLOCK> ols,
47+
byte_io_handle::io_request<BuffersType> reqs) noexcept
5048
{
5149
using namespace windows_nt_kernel;
5250
using EIOSB = windows_nt_kernel::IO_STATUS_BLOCK;
@@ -75,8 +73,9 @@ inline bool do_cancel(const native_handle_type &nativeh, span<windows_nt_kernel:
7573

7674
// Returns true if operation completed immediately
7775
template <bool blocking, class Syscall, class BuffersType>
78-
inline bool do_read_write(byte_io_handle::io_result<BuffersType> &ret, Syscall &&syscall, const native_handle_type &nativeh,
79-
span<windows_nt_kernel::IO_STATUS_BLOCK> ols, byte_io_handle::io_request<BuffersType> reqs, deadline d) noexcept
76+
inline bool do_read_write(byte_io_handle::io_result<BuffersType> &ret, Syscall &&syscall,
77+
const native_handle_type &nativeh, span<windows_nt_kernel::IO_STATUS_BLOCK> ols,
78+
byte_io_handle::io_request<BuffersType> reqs, deadline d) noexcept
8079
{
8180
using namespace windows_nt_kernel;
8281
using EIOSB = windows_nt_kernel::IO_STATUS_BLOCK;
@@ -130,7 +129,8 @@ inline bool do_read_write(byte_io_handle::io_result<BuffersType> &ret, Syscall &
130129
#endif
131130
reqs.offset += req.size();
132131
ol.Status = 0x103 /*STATUS_PENDING*/;
133-
NTSTATUS ntstat = syscall(nativeh.h, nullptr, nullptr, nullptr, &ol, (PVOID) req.data(), static_cast<DWORD>(req.size()), &offset, nullptr);
132+
NTSTATUS ntstat = syscall(nativeh.h, nullptr, nullptr, nullptr, &ol, (PVOID) req.data(),
133+
static_cast<DWORD>(req.size()), &offset, nullptr);
134134
if(ntstat < 0 && ntstat != 0x103 /*STATUS_PENDING*/)
135135
{
136136
InterlockedCompareExchange(&ol.Status, ntstat, 0x103 /*STATUS_PENDING*/);
@@ -191,8 +191,8 @@ inline bool do_read_write(byte_io_handle::io_result<BuffersType> &ret, Syscall &
191191
return true;
192192
}
193193

194-
byte_io_handle::io_result<byte_io_handle::buffers_type> byte_io_handle::_do_read(byte_io_handle::io_request<byte_io_handle::buffers_type> reqs,
195-
deadline d) noexcept
194+
byte_io_handle::io_result<byte_io_handle::buffers_type>
195+
byte_io_handle::_do_read(byte_io_handle::io_request<byte_io_handle::buffers_type> reqs, deadline d) noexcept
196196
{
197197
windows_nt_kernel::init();
198198
using namespace windows_nt_kernel;
@@ -216,8 +216,8 @@ byte_io_handle::io_result<byte_io_handle::buffers_type> byte_io_handle::_do_read
216216
return ret;
217217
}
218218

219-
byte_io_handle::io_result<byte_io_handle::const_buffers_type> byte_io_handle::_do_write(byte_io_handle::io_request<byte_io_handle::const_buffers_type> reqs,
220-
deadline d) noexcept
219+
byte_io_handle::io_result<byte_io_handle::const_buffers_type>
220+
byte_io_handle::_do_write(byte_io_handle::io_request<byte_io_handle::const_buffers_type> reqs, deadline d) noexcept
221221
{
222222
windows_nt_kernel::init();
223223
using namespace windows_nt_kernel;
@@ -241,8 +241,9 @@ byte_io_handle::io_result<byte_io_handle::const_buffers_type> byte_io_handle::_d
241241
return ret;
242242
}
243243

244-
byte_io_handle::io_result<byte_io_handle::const_buffers_type> byte_io_handle::_do_barrier(byte_io_handle::io_request<byte_io_handle::const_buffers_type> reqs,
245-
barrier_kind kind, deadline d) noexcept
244+
byte_io_handle::io_result<byte_io_handle::const_buffers_type>
245+
byte_io_handle::_do_barrier(byte_io_handle::io_request<byte_io_handle::const_buffers_type> reqs, barrier_kind kind,
246+
deadline d) noexcept
246247
{
247248
windows_nt_kernel::init();
248249
using namespace windows_nt_kernel;

0 commit comments

Comments
 (0)