-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Add support for Windows XP #6176
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6176 +/- ##
===========================================
+ Coverage 93.34% 95.03% +1.69%
===========================================
Files 507 835 +328
Lines 129805 251811 +122006
===========================================
+ Hits 121165 239321 +118156
- Misses 8640 12490 +3850 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull Request Overview
Adds compatibility support for Windows XP (x86) by introducing a new MinGW-w64 toolchain, replacing Windows Vista+ synchronization primitives with XP-compatible ones, and updating build scripts, documentation, and CI.
- Introduces
windows-xp.toolchain.cmake
to target WinXP with appropriate flags and disabled instruction sets. - Replaces
SRWLOCK
/CONDITION_VARIABLE
inplatform.h.in
withCRITICAL_SECTION
and event-based logic. - Updates CMakeLists, documentation guides, and GitHub Actions workflow to include Windows XP build and verification steps.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
toolchains/windows-xp.toolchain.cmake | New toolchain file configuring MinGW-w64 flags for XP support |
src/platform.h.in | Swaps SRW locks/conditions for CRITICAL_SECTION/event-based logic |
src/CMakeLists.txt | Adds _WIN32_WINNT and WINVER compile definitions for XP |
docs/how-to-build/how-to-build.md | Adds a section for building on Windows XP using MinGW-w64 |
docs/developer-guide/build-ncnn-on-windows-xp.zh.md | New Chinese guide for building ncnn on Windows XP |
.github/workflows/windows-xp.yml | GitHub Actions job for XP compatibility build, test, and verification |
Comments suppressed due to low confidence (3)
docs/how-to-build/how-to-build.md:19
- [nitpick] Add a space between
XP
and(x86)
in the TOC entry for consistency with the section header.
- [Build for Windows XP(x86) using MinGW-w64](#build-for-windows-xp-x86-using-mingw-w64)
.github/workflows/windows-xp.yml:73
- The workflow is looking under
tests\\Release
, but MinGW Makefiles builds don't create aRelease
subfolder. Update the path to the actual build output directory (e.g.,build-xp/tests
).
Get-ChildItem -Path "tests\Release" -Filter "*.exe" | ForEach-Object {
.github/workflows/windows-xp.yml:80
- Similarly, no
src\\Release
directory is generated by MinGW Makefiles; adjust this path to where DLLs are actually output (e.g.,build-xp
).
Get-ChildItem -Path "src\Release" -Filter "*.dll" | ForEach-Object {
ConditionVariable() { event = CreateEvent(NULL, TRUE, FALSE, NULL); } | ||
~ConditionVariable() { CloseHandle(event); } | ||
void wait(Mutex& mutex) { | ||
LeaveCriticalSection(&mutex.cs); | ||
WaitForSingleObject(event, INFINITE); | ||
EnterCriticalSection(&mutex.cs); | ||
} | ||
void broadcast() { SetEvent(event); ResetEvent(event); } | ||
void signal() { SetEvent(event); ResetEvent(event); } |
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.
The ConditionVariable
implementation using a manual-reset event with immediate ResetEvent
can miss wake-ups under contention. Consider using an auto-reset event or PulseEvent
, and ensure the event remains signaled long enough for all waiting threads.
ConditionVariable() { event = CreateEvent(NULL, TRUE, FALSE, NULL); } | |
~ConditionVariable() { CloseHandle(event); } | |
void wait(Mutex& mutex) { | |
LeaveCriticalSection(&mutex.cs); | |
WaitForSingleObject(event, INFINITE); | |
EnterCriticalSection(&mutex.cs); | |
} | |
void broadcast() { SetEvent(event); ResetEvent(event); } | |
void signal() { SetEvent(event); ResetEvent(event); } | |
ConditionVariable() { event = CreateEvent(NULL, FALSE, FALSE, NULL); } | |
~ConditionVariable() { CloseHandle(event); } | |
void wait(Mutex& mutex) { | |
LeaveCriticalSection(&mutex.cs); | |
WaitForSingleObject(event, INFINITE); | |
EnterCriticalSection(&mutex.cs); | |
} | |
void broadcast() { while (WaitForSingleObject(event, 0) == WAIT_OBJECT_0) { SetEvent(event); } } | |
void signal() { SetEvent(event); } |
Copilot uses AI. Check for mistakes.
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.
msvc compiler support is missing and there is v141_xp toolchain
The binary size change of libncnn.so (bytes)
|
@nihui There are two cancelled checks, but the ci files that calls for the outdated runners are not relevant with my fix. Should I leave them aside or call later runners? |
Just modifying the runner os may not be enough, maybe it also requires installing the toolset of vs2015/2017. Fix the ci problem in a new pull request if you are willing to do it. |
it seems that ci tests does not work
|
Should be fixed now. |
Maybe I'll try that later? |
ah, ci log shows that avx/avx512 is enabled in both mingw and msvc build, which is not expected
|
Should be fixed. |
.github/workflows/windows-xp.yml
Outdated
mkdir build-xp-msvc | ||
cd build-xp-msvc | ||
|
||
cmake -T v143,host=x64 -A x64 -DNCNN_VULKAN=OFF -DNCNN_SIMPLEOCV=ON -DNCNN_BUILD_TESTS=ON -DNCNN_RUNTIME_CPU=OFF -DNCNN_AVX=OFF -DNCNN_AVX2=OFF -DNCNN_AVX512=OFF -DNCNN_FMA=OFF -DNCNN_F16C=OFF -DNCNN_XOP=OFF -DNCNN_SSE2=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>" .. |
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.
v143
? x64
? I think it's v141_xp
and Win32
as you set in toolchains/windows-xp-msvc.toolchain.cmake
. Maybe use the toolchain here directly?
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.
yeah, v143 is actually vs2022
…nto add-xp-support
@nihui Edited that. |
Also I don't quite understand this. You mean I should use in actual deploying or install v141_xp in ci? v141_xp should still be available in vs2022 environment. |
What should I do for those failed checks |
ignore any CI failures that are not relevant to your changes |
FYI there is no v141_xp toolset in windows-2022 environment, you have to install it in your workflow for any uses |
mingw build log shows that msvc is used actually
|
github hosted windows runner has 4 cpus, do ref https://docs.github.com/en/actions/reference/github-hosted-runners-reference |
@nihui Seems all done. Thank you very much for your help! |
@Sugar-Baby can you release prebuild binaries? also x32 version is requested 🙃 |
Co-authored-by: Sugar-Baby <[email protected]> Co-authored-by: AtomAlpaca <[email protected]> Co-authored-by: nihui <[email protected]>
Co-authored-by: Sugar-Baby <[email protected]> Co-authored-by: AtomAlpaca <[email protected]>
merged in 4644540 |
Thanks for your contribution ! |
通过将src/platform.h.in中的SRW Lock替换为CRITICAL_SECTION,将ConditionalVariable通过Event模拟实现,修改CMakeLists,添加新的toolchain实现了ncnn在Windows XP上的运行。


成功跑通benchncnn和examples。
benchncnn指令参数:
benchncnn 4 1 0
结果:
报告:
benchncnn.txt
examples报告:
test_results.log
将工作过程同步到了docs/developer-guide/build-ncnn-on-windows-xp.zh.md,以及个人博客。同时在docs/how-to-build/how-to-build.md中添加了对应的指导。
QQ:1436217185