Skip to content

build: fix race condition for pdb generation#1642

Merged
alandtse merged 2 commits into
community-shaders:devfrom
alandtse:pdb_race
Dec 15, 2025
Merged

build: fix race condition for pdb generation#1642
alandtse merged 2 commits into
community-shaders:devfrom
alandtse:pdb_race

Conversation

@alandtse
Copy link
Copy Markdown
Collaborator

@alandtse alandtse commented Dec 14, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Improved build reliability by changing plugin deployment to occur after linking, preventing race conditions when copying build artifacts.
  • Documentation
    • Added explanatory comments clarifying the post-build deployment approach and rationale.

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

Copilot AI review requested due to automatic review settings December 14, 2025 00:10
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 14, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

CMakeLists.txt was changed to move plugin DLL/PDB copy steps out of an inline PREPARE_AIO phase into a POST_BUILD custom command so files are copied only after the linker finishes and releases them.

Changes

Cohort / File(s) Summary
Build System Race Condition Fix
CMakeLists.txt
Removed inline copy commands from PREPARE_AIO; added a POST_BUILD custom command to copy the built DLL and PDB into AIO/Plugins; added comments explaining race-condition avoidance and rationale.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify POST_BUILD paths and variables target the correct built DLL/PDB and destination (AIO/Plugins)
  • Confirm custom command runs after linking and does not interfere with incremental builds
  • Check Windows file-locking behavior and that PDB is copied alongside the DLL
  • Run a clean build and an incremental build to validate no file-access errors

Poem

🐰 I watched the linker finish its run,

then hopped to copy — now races are none.
POST_BUILD waits, then files take flight,
no locks, no errors, all tidy and right.
A tiny hop for code, a calmer night. ✨

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 'build: fix race condition for pdb generation' is specific and clearly summarizes the main change: addressing a race condition in the build process related to PDB file generation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@github-actions
Copy link
Copy Markdown

Using provided base ref: b3cb42e
Using base ref: b3cb42e
Base commit date: 2025-12-13T14:48:11-08:00 (Saturday, December 13, 2025 02:48 PM)
No actionable suggestions for changed features.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
CMakeLists.txt (1)

335-336: Comment is accurate, but POST_BUILD should be self-sufficient
Right now ${AIO_DIR}/SKSE/Plugins is created by PREPARE_AIO; consider also creating it in the POST_BUILD block so the copy step remains correct if target ordering/ALL-ness changes later.

 add_custom_command(
     TARGET ${PROJECT_NAME}
     POST_BUILD
+    COMMAND
+        ${CMAKE_COMMAND} -E make_directory
+        "${AIO_DIR}/SKSE/Plugins"
     COMMAND
         ${CMAKE_COMMAND} -E copy_if_different
         "$<TARGET_FILE:${PROJECT_NAME}>"
         "${AIO_DIR}/SKSE/Plugins/$<TARGET_FILE_NAME:${PROJECT_NAME}>"
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b3cb42e and 5f6808e.

📒 Files selected for processing (1)
  • CMakeLists.txt (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*

⚙️ CodeRabbit configuration file

**/*: When reviewing PRs, please provide suggestions for:

  1. Conventional Commit Titles (if not following https://www.conventionalcommits.org/ or
    if the existing title does not describe the code changes):
    Format: type(scope): description
    Length: 50 characters limit for title, 72 for body
    Style: lowercase description, no ending period
    Examples:

    • feat(vr): add cross-eye sampling
    • fix(water): resolve flowmap bug
    • docs: update shader documentation
  2. Issue References (if PR fixes bugs or implements features):
    Suggest adding appropriate GitHub keywords:

    • "Fixes #123" or "Closes #123" for bug fixes
    • "Implements #123" or "Addresses #123" for features
    • "Related to #123" for partial implementations

Otherwise, use your standard review approach focusing on code quality.

Files:

  • CMakeLists.txt
🧠 Learnings (1)
📓 Common learnings
Learnt from: alandtse
Repo: doodlum/skyrim-community-shaders PR: 0
File: :0-0
Timestamp: 2025-07-05T05:20:45.823Z
Learning: In the skyrim-community-shaders repository, file deletion error handling improvements that replace existence checks and try-catch blocks with std::filesystem::remove error-code-based approaches are considered bug fixes rather than refactoring, as they address inadequate error handling and misleading log messages.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Validate shader compilation (Flatrim, .github/configs/shader-validation.yaml)
  • GitHub Check: Validate shader compilation (VR, .github/configs/shader-validation-vr.yaml)
  • GitHub Check: Build plugin and addons
  • GitHub Check: Agent

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR attempts to fix a race condition during the build process by moving DLL and PDB file copying from a custom command (that runs as part of prepare_aio.stamp) to a POST_BUILD command attached to the main project target. The goal is to ensure the linker has fully released these files before attempting to copy them.

Key Changes:

  • Removed DLL and PDB copy operations from the _prepare_aio_cmds list (lines 346-366 removed)
  • Added a new POST_BUILD command to copy DLL and PDB files after the target is built (lines 438-453)
  • Updated comments to clarify the new approach

Comment thread CMakeLists.txt
Comment thread CMakeLists.txt
@alandtse alandtse changed the title build: fix race condition for pdf generation build: fix race condition for pdb generation Dec 14, 2025
@alandtse alandtse marked this pull request as draft December 14, 2025 00:21
@alandtse alandtse marked this pull request as ready for review December 14, 2025 00:30
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
CMakeLists.txt (2)

438-454: Update PR title to follow conventional commits and add issue reference.

Per the repository's coding guidelines, the PR title should follow the conventional commits format type(scope): description (lowercase, no period). Consider revising the title to fix(build): avoid dll/pdb copy race condition or similar, and add a reference like Fixes #<issue-number> in the PR description if this addresses a tracked issue.

As per coding guidelines, recommended title:

  • Current: build: fix race condition for pdb generation
  • Suggested: fix(build): avoid dll/pdb copy race condition

449-451: Guard $<TARGET_PDB_FILE:...> to avoid empty-path failure.

On generators/configurations where no PDB is produced (MinGW, non-MSVC toolchains, certain Debug builds), $<TARGET_PDB_FILE:${PROJECT_NAME}> evaluates to an empty string, and cmake -E copy_if_different "" <dst> may hard-fail the build. Wrap the PDB copy command in a generator-expression guard so it becomes a no-op when there is no PDB.

Apply this diff to conditionally guard the PDB copy:

         COMMAND
             ${CMAKE_COMMAND} -E copy_if_different
             "$<TARGET_FILE:${PROJECT_NAME}>"
             "${AIO_DIR}/SKSE/Plugins/$<TARGET_FILE_NAME:${PROJECT_NAME}>"
         COMMAND
-            ${CMAKE_COMMAND} -E copy_if_different
-            "$<TARGET_PDB_FILE:${PROJECT_NAME}>"
-            "${AIO_DIR}/SKSE/Plugins/$<TARGET_PDB_FILE_NAME:${PROJECT_NAME}>"
+            ${CMAKE_COMMAND} -E $<IF:$<BOOL:$<TARGET_PDB_FILE:${PROJECT_NAME}>>,copy_if_different,true>
+            "$<TARGET_PDB_FILE:${PROJECT_NAME}>"
+            "${AIO_DIR}/SKSE/Plugins/$<TARGET_PDB_FILE_NAME:${PROJECT_NAME}>"
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5f6808e and 09b9f95.

📒 Files selected for processing (1)
  • CMakeLists.txt (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*

⚙️ CodeRabbit configuration file

**/*: When reviewing PRs, please provide suggestions for:

  1. Conventional Commit Titles (if not following https://www.conventionalcommits.org/ or
    if the existing title does not describe the code changes):
    Format: type(scope): description
    Length: 50 characters limit for title, 72 for body
    Style: lowercase description, no ending period
    Examples:

    • feat(vr): add cross-eye sampling
    • fix(water): resolve flowmap bug
    • docs: update shader documentation
  2. Issue References (if PR fixes bugs or implements features):
    Suggest adding appropriate GitHub keywords:

    • "Fixes #123" or "Closes #123" for bug fixes
    • "Implements #123" or "Addresses #123" for features
    • "Related to #123" for partial implementations

Otherwise, use your standard review approach focusing on code quality.

Files:

  • CMakeLists.txt
🧠 Learnings (2)
📓 Common learnings
Learnt from: alandtse
Repo: doodlum/skyrim-community-shaders PR: 0
File: :0-0
Timestamp: 2025-07-05T05:20:45.823Z
Learning: In the skyrim-community-shaders repository, file deletion error handling improvements that replace existence checks and try-catch blocks with std::filesystem::remove error-code-based approaches are considered bug fixes rather than refactoring, as they address inadequate error handling and misleading log messages.
📚 Learning: 2025-08-17T18:37:35.839Z
Learnt from: CR
Repo: doodlum/skyrim-community-shaders PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-17T18:37:35.839Z
Learning: Applies to src/**/*.{cpp,cxx,cc,h,hpp,hxx} : Ensure SE/AE/VR runtime compatibility; use runtime detection patterns (e.g., REL::RelocateMember())

Applied to files:

  • CMakeLists.txt
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Validate shader compilation (VR, .github/configs/shader-validation-vr.yaml)
  • GitHub Check: Build plugin and addons
  • GitHub Check: Validate shader compilation (Flatrim, .github/configs/shader-validation.yaml)

Comment thread CMakeLists.txt
@github-actions
Copy link
Copy Markdown

✅ A pre-release build is available for this PR:
Download

@alandtse alandtse merged commit c067b35 into community-shaders:dev Dec 15, 2025
23 checks passed
ParticleTroned pushed a commit to ParticleTroned/skyrim-community-shaders that referenced this pull request Dec 18, 2025
ParticleTroned pushed a commit to ParticleTroned/skyrim-community-shaders that referenced this pull request Dec 19, 2025
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.

3 participants