Skip to content

fix pthreads under windows msys2 mingw#413

Merged
blueloveTH merged 1 commit intopocketpy:mainfrom
hibays:fix-threads-under-windows-msys2-mingw
Dec 10, 2025
Merged

fix pthreads under windows msys2 mingw#413
blueloveTH merged 1 commit intopocketpy:mainfrom
hibays:fix-threads-under-windows-msys2-mingw

Conversation

@hibays
Copy link
Contributor

@hibays hibays commented Dec 10, 2025

fix cmake build because of <threads.h> not found

Before:

FAILED: [code=1] thirdlib/pocketpy-2.1.3/CMakeFiles/pocketpy.dir/Unity/unity_pocketpy_c.c.obj 
D:/Dev/MSYS64/ucrt64/bin/ccache.exe D:\Dev\MSYS64\ucrt64\bin\gcc.exe -DPK_ENABLE_CUSTOM_SNAME=0 -DPK_ENABLE_DETERMINISM=0 -DPK_ENABLE_MIMALLOC=0 -DPK_ENABLE_OS=0 -DPK_ENABLE_THREADS=1 -DPK_ENABLE_WATCHDOG=0 -D_CRT_SECURE_NO_WARNINGS -IG:/Projects/papp/thirdlib/pocketpy-2.1.3/include -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -g -std=gnu11 -fdiagnostics-color=always -MD -MT thirdlib/pocketpy-2.1.3/CMakeFiles/pocketpy.dir/Unity/unity_pocketpy_c.c.obj -MF thirdlib\pocketpy-2.1.3\CMakeFiles\pocketpy.dir\Unity\unity_pocketpy_c.c.obj.d -o thirdlib/pocketpy-2.1.3/CMakeFiles/pocketpy.dir/Unity/unity_pocketpy_c.c.obj -c G:/Projects/papp/build/thirdlib/pocketpy-2.1.3/CMakeFiles/pocketpy.dir/Unity/unity_pocketpy_c.c
In file included from G:/Projects/papp/thirdlib/pocketpy-2.1.3/src/common/name.c:6,
                 from G:/Projects/papp/build/thirdlib/pocketpy-2.1.3/CMakeFiles/pocketpy.dir/Unity/unity_pocketpy_c.c:40:
G:/Projects/papp/thirdlib/pocketpy-2.1.3/include/pocketpy/common/threads.h:16:10: fatal error: threads.h: No such file or directory
   16 | #include <threads.h>
      |          ^~~~~~~~~~~
compilation terminated.

Summary by CodeRabbit

  • Chores
    • Improved Windows (MinGW) platform compatibility for thread handling.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 10, 2025

Walkthrough

The change adds __MINGW32__ to an existing platform preprocessor check in the threads header file, enabling MinGW32 Windows builds to use the pthreads-based thread definitions rather than an alternative code path.

Changes

Cohort / File(s) Summary
Platform conditionals
include/pocketpy/common/threads.h
Added __MINGW32__ to the platform check to route MinGW Windows builds through the pthreads code path

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

This is a straightforward single-line preprocessor directive addition with no complex logic or behavioral changes beyond conditional compilation path selection.

Poem

🐰 A whisker-twitch for MinGW's delight,
Platform checks now held just right,
Pthreads flow through Windows' door,
Threads harmonize forevermore! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding MINGW32 to the platform check to fix pthreads support on Windows MinGW builds, which directly addresses the file's purpose and the PR's objective to resolve the missing threads.h issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e3bd4cf and fa8a53d.

📒 Files selected for processing (1)
  • include/pocketpy/common/threads.h (1 hunks)
🔇 Additional comments (1)
include/pocketpy/common/threads.h (1)

10-10: LGTM! Correct fix for MinGW build failure.

Adding __MINGW32__ correctly routes MinGW builds to use pthreads instead of the unavailable <threads.h>. MinGW-w64 (and MSYS2) include the winpthreads library, making pthread.h available. The __MINGW32__ macro is appropriate as it covers both MinGW32 and MinGW-w64 in both 32-bit and 64-bit modes. C11 <threads.h> is not provided by default in MinGW-w64's standard runtime.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@blueloveTH blueloveTH merged commit 0eabbda into pocketpy:main Dec 10, 2025
16 checks passed
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