tests: link KernelFileSystemTests on Windows #712

Closed
github-bot wants to merge 1 commit from gh-pr/712/head into gh-pr/712/base
Owner

@⁠diegoalejandrogomez on GitHub · 2026-09-19 03:19 UTC · original
diegoalejandrogomez:fix/kernelFileSystemTest_buildWin → main · +3 −0 · 1 files · 1 commits · closed without merging

Summary

kernel_file_system_tests does not link on Windows:

lld-link: error: undefined symbol: main
>>> referenced by D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
>>>               msvcrtd.lib(exe_main.obj):(int __cdecl invoke_main(void))

The test includes SDL.h, which pulls in SDL_main.h. On Windows that header defines SDL_MAIN_AVAILABLE and renames main to SDL_main, expecting the SDL2main library to provide the real entry point. The test target only links the static SDL2 library, so no main exists. The emulator itself never hits this because src/main.cpp does not include SDL.h.

This defines SDL_MAIN_HANDLED before the include on Windows, which is the opt-out documented in SDL_main.h for programs that own their main. SDL_SetMainReady is not needed: with SDL_MAIN_AVAILABLE (as opposed to SDL_MAIN_NEEDED) the ready flag in SDL.c defaults to true.

Test plan

  • Windows, clang-cl + Ninja (Debug): kernel_file_system_tests builds and links.
  • Running the binary reaches the socket cases (it previously could not be built at all).

Notes

  • kernel_file_system is not in the ctest filter for any platform in build.yml, which is why this went unnoticed. Adding it to the Windows job would keep this from regressing; left out of this PR as a CI policy call.
  • On Windows the binary currently aborts at guest PEEK and WAITALL preserve the wake bytes. That is a separate pre-existing Winsock issue (recv rejects MSG_PEEK | MSG_WAITALL with WSAEOPNOTSUPP); fix to follow in its own PR.
**@⁠diegoalejandrogomez** on GitHub · 2026-09-19 03:19 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/712) `diegoalejandrogomez:fix/kernelFileSystemTest_buildWin` → `main` · +3 −0 · 1 files · 1 commits · closed without merging ## Summary `kernel_file_system_tests` does not link on Windows: ``` lld-link: error: undefined symbol: main >>> referenced by D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78 >>> msvcrtd.lib(exe_main.obj):(int __cdecl invoke_main(void)) ``` The test includes `SDL.h`, which pulls in `SDL_main.h`. On Windows that header defines `SDL_MAIN_AVAILABLE` and renames `main` to `SDL_main`, expecting the `SDL2main` library to provide the real entry point. The test target only links the static SDL2 library, so no `main` exists. The emulator itself never hits this because `src/main.cpp` does not include `SDL.h`. This defines `SDL_MAIN_HANDLED` before the include on Windows, which is the opt-out documented in `SDL_main.h` for programs that own their `main`. `SDL_SetMainReady` is not needed: with `SDL_MAIN_AVAILABLE` (as opposed to `SDL_MAIN_NEEDED`) the ready flag in `SDL.c` defaults to true. ## Test plan - [x] Windows, clang-cl + Ninja (Debug): `kernel_file_system_tests` builds and links. - [x] Running the binary reaches the socket cases (it previously could not be built at all). ## Notes - `kernel_file_system` is not in the ctest filter for any platform in `build.yml`, which is why this went unnoticed. Adding it to the Windows job would keep this from regressing; left out of this PR as a CI policy call. - On Windows the binary currently aborts at `guest PEEK and WAITALL preserve the wake bytes`. That is a separate pre-existing Winsock issue (`recv` rejects `MSG_PEEK | MSG_WAITALL` with `WSAEOPNOTSUPP`); fix to follow in its own PR.
lld-link: error: undefined symbol: main
>>> referenced by D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
>>>               msvcrtd.lib(exe_main.obj):(int __cdecl invoke_main(void))
ninja: build stopped: subcommand failed.

3rdparty\SDL2\include\SDL_main.h includes the following note:

/* On Windows SDL provides WinMain(), which parses the command line and passes
   the arguments to your main function.

   If you provide your own WinMain(), you may define SDL_MAIN_HANDLED
 */

so defining SDL_MAIN_HANDLED before including SDL in Windows solved the
problem
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:30:25 +00:00
github-bot closed this pull request 2026-11-26 09:30:25 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-19 03:21 UTC · original

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 0fba9304-d9ad-4cb4-9390-84c098859367

📥 Commits

Reviewing files that changed from the base of the PR and between f100f785da and c8f1593359.

📒 Files selected for processing (1)
  • tests/KernelFileSystemTests.cpp

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The test source defines SDL_MAIN_HANDLED on Windows before including SDL headers. This prevents SDL from replacing the test program’s main entry point.

Suggested reviewers: nmzik

Priority: ⬇️ Low

Change: Bug fix

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the Windows linking fix for KernelFileSystemTests and matches the main change.
Description check ✅ Passed The description explains the Windows linker error, the SDL_MAIN_HANDLED fix, validation results, and the separate pre-existing Winsock issue.

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

**@⁠coderabbitai[bot]** on GitHub · 2026-09-19 03:21 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/712#issuecomment-5738957982) <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/712#gh-light-mode-only"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg" alt="Review Change Stack" width="202" height="32"></a><a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/712#gh-dark-mode-only"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg" alt="Review Change Stack" width="202" height="32"></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml **Review profile**: CHILL **Plan**: Advanced **Run ID**: `0fba9304-d9ad-4cb4-9390-84c098859367` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between f100f785dafa108bbf5b40ea8e425e08236f981a and c8f1593359b4fa74b6fa92bce12944b73726de41. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `tests/KernelFileSystemTests.cpp` </details> **Included review availability:** Your plan provides up to 10 included reviews per hour; 9 remain after this review. </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The test source defines `SDL_MAIN_HANDLED` on Windows before including SDL headers. This prevents SDL from replacing the test program’s `main` entry point. **Suggested reviewers:** `nmzik` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬇️ Low <!-- change_assessment_commit:"c8f1593359b4fa74b6fa92bce12944b73726de41" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 5</summary> <details> <summary>✅ Passed checks (5 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1… | | Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Title check | ✅ Passed | The title clearly identifies the Windows linking fix for KernelFileSystemTests and matches the main change. | | Description check | ✅ Passed | The description explains the Windows linker error, the SDL_MAIN_HANDLED fix, validation results, and the separate pre-existing Winsock issue. | </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> --- <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠diegoalejandrogomez on GitHub · 2026-09-19 19:30 UTC · original

This was already solved by this #565
Closing this pr since is duplicated

**@⁠diegoalejandrogomez** on GitHub · 2026-09-19 19:30 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/712#issuecomment-5744717260) This was already solved by this #565 Closing this pr since is duplicated

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.