Skip to content

#11622 - PCH is actually NOT enabled for energyplus_tests + fixup PCH usage on Windows CI#11623

Merged
mitchute merged 11 commits into
developfrom
11622_PCH_and_CI
Jun 8, 2026
Merged

#11622 - PCH is actually NOT enabled for energyplus_tests + fixup PCH usage on Windows CI#11623
mitchute merged 11 commits into
developfrom
11622_PCH_and_CI

Conversation

@jmarrec

@jmarrec jmarrec commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Pull request overview

Description of the purpose of this PR

3dfcc1b shows that PCH wasn't added to the energyplus_tests target.

I change the CMake code so that is does, and I added EnergyPlusFixture.hh and gtest/gtest.h to the PCH for energyplus_tests.

before:

time ninja

  real    7m0.262s
  user    54m1.999s
  sys     2m46.176s

Analyzing build trace from 'capture.bin'...
**** Time summary:
Compilation (870 times):
  Parsing (frontend):         2009.9 s
  Codegen & opts (backend):   1639.4 s

after

time ninja

  real    6m34.713s
  user    49m26.037s
  sys     2m27.567s

Analyzing build trace from 'capture_pch.bin'...
**** Time summary:
Compilation (872 times):
  Parsing (frontend):         1659.4 s
  Codegen & opts (backend):   1696.5 s

The expensive headers are gone

**** Expensive headers:
216254 ms: /Users/julien/Software/Others/EnergyPlus/third_party/gtest/googletest/include/gtest/gtest.h (included 282 times, avg 766 ms), included via:
  242x: <direct include>
  22x: AutosizingFixture.hh EnergyPlusFixture.hh
  8x: gtest.h gtest_pred_impl.h
  7x: EnergyPlusFixture.hh
  2x: gmock.h gmock-actions.h gmock-internal-utils.h
  1x: EnergyPlusFixture.hh gtest.h gtest_pred_impl.h

138664 ms: /Users/julien/Software/Others/EnergyPlus/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.hh (included 265 times, avg 523 ms), included via:
  233x: <direct include>
  22x: AutosizingFixture.hh
  4x: SQLiteFixture.hh
  3x: CoilCoolingDXFixture.hh SQLiteFixture.hh
  2x: InputProcessorFixture.hh
  1x: ResultsFrameworkFixture.hh
  ...

CI PCH

I started doing very complicated things, but in the end I went with simple:

  • I don’t think there’s any point restoring a CCACHE cache with a different ENABLE_PCH value, so it’’s part of the base restore key now
  • run_and_cache_regressions_develop.yml should just do ENABLE_PCH = ON. The OFF case is tested via alternate builds in test_develop_commits.yml. This will reduce the number of shenanigans and confusion.

I originally also added a windows-only hash of the PCH files into the cache keys, but I don't think that's necessary at all, so I reverted it in a9a9da3 but kept a note.

Pull Request Author

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • Label the PR with at least one of: Defect, Refactoring, NewFeature, Performance, and/or DoNoPublish
  • Pull requests that impact EnergyPlus code must also include unit tests to cover enhancement or defect repair
  • Author should provide a "walkthrough" of relevant code changes using a GitHub code review comment process
  • If any diffs are expected, author must demonstrate they are justified using plots and descriptions
  • If changes fix a defect, the fix should be demonstrated in plots and descriptions
  • If any defect files are updated to a more recent version, upload new versions here or on DevSupport
  • If IDD requires transition, transition source, rules, ExpandObjects, and IDFs must be updated, and add IDDChange label
  • If structural output changes, add to output rules file and add OutputChange label
  • If adding/removing any LaTeX docs or figures, update that document's CMakeLists file dependencies
  • If adding/removing any output files (e.g., eplustbl.*)
    • Update ..\scripts\Epl-run.bat
    • Update ..\scripts\RunEPlus.bat
    • Update ..\src\EPLaunch\ MainModule.bas, epl-ui.frm, and epl.vbp (VersionComments)
    • Update ...github\workflows\energyplus.py

Reviewer

  • Perform a Code Review on GitHub
  • If branch is behind develop, merge develop and build locally to check for side effects of the merge
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified
  • Check that performance is not impacted (CI Linux results include performance check)
  • Run Unit Test(s) locally
  • Check any new function arguments for performance impacts
  • Verify IDF naming conventions and styles, memos and notes and defaults
  • If new idf included, locally check the err file and other outputs

jmarrec added 10 commits June 5, 2026 09:24
…ture and gtest to it

```
**** Expensive headers:
216254 ms: /Users/julien/Software/Others/EnergyPlus/third_party/gtest/googletest/include/gtest/gtest.h (included 282 times, avg 766 ms), included via:
  242x: <direct include>
  22x: AutosizingFixture.hh EnergyPlusFixture.hh
  8x: gtest.h gtest_pred_impl.h
  7x: EnergyPlusFixture.hh
  2x: gmock.h gmock-actions.h gmock-internal-utils.h
  1x: EnergyPlusFixture.hh gtest.h gtest_pred_impl.h

138664 ms: /Users/julien/Software/Others/EnergyPlus/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.hh (included 265 times, avg 523 ms), included via:
  233x: <direct include>
  22x: AutosizingFixture.hh
  4x: SQLiteFixture.hh
  3x: CoilCoolingDXFixture.hh SQLiteFixture.hh
  2x: InputProcessorFixture.hh
  1x: ResultsFrameworkFixture.hh
```
…rove_pch_on_msvc"

This reverts commit 3be933c, reversing
changes made to 690283b.
… the weirdness. No PCH is tested in test_develop_commits.yml
@jmarrec jmarrec added Defect Includes code to repair a defect in EnergyPlus Developer Issue Related to cmake, packaging, installers, or developer tooling (CI, etc) labels Jun 5, 2026
…ame directory (and same as develop run_and_cache workflow)

it might breaks MSVC PCH (/FI vs /Yu path mismatch → C1010)

Locall on a windows 11 arm64 VM I can build 100% fine with PCH and ccache, using the same versions

- ccache: 4.13.6
- ninja: 1.13.2
 - MSVC: v17.14.33 (Entreprise on CI, Community on VM)
- cmake: 4.3.3

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since this is touching a workflow that runs only on develop, I pushed a run on my fork https://github.com/jmarrec/EnergyPlus/actions/runs/27041535807

Comment on lines +10 to +11
# IMPORTANT: If you change this: modify test_pull_requests.yml in accordance for the ENABLE_PCH value when we found regression tests
ENABLE_PCH: ON

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Switched this, made a note to keep both workflows in line

Comment on lines +82 to +84
# We adjust the ENABLE_PCH to match what is on develop
# IMPORTANT: keep this in sync with the ENABLE_PCH from run_and_cache_regressions_develop.yml
echo "ENABLE_PCH=ON" >> $GITHUB_ENV

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Companion note

Comment on lines +81 to +83
key: ccache-${{ matrix.os }}-${{ steps.setup-runner.outputs.compiler-id }}-pch=${{ env.ENABLE_PCH }}-${{ env.CURRENT_SHA }}
restore-keys: |
ccache-${{ matrix.os }}-${{ steps.setup-runner.outputs.compiler-id }}-
ccache-${{ matrix.os }}-
ccache-${{ matrix.os }}-${{ steps.setup-runner.outputs.compiler-id }}-pch=${{ env.ENABLE_PCH }}-

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

On develop, the pch is now path of the key. compiler-id too, it won't change nearly as often as we have cache evictions anyways.

key: ccache-ubuntu-24.04-gcc-13-enable-pch=ON-ee1a1b3c25
restore_keys: |
   ccache-ubuntu-24.04-gcc-13-enable-pch=ON-
key: ccache-windows-2022-msvc-enable-pch=ON-ee1a1b3c25
restore_keys: |
   ccache-windows-2022-msvc-enable-pch=ON-

uses: ./.github/actions/configure-and-build
with:
enable-pch: OFF
enable-pch: ${{ env.ENABLE_PCH }}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

env var passed here

Comment thread cmake/ProjectMacros.cmake
add_executable(${BASE_NAME}_tests ${SRC})
target_link_libraries(${BASE_NAME}_tests PRIVATE project_options project_warnings)

if(USE_PCH)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The issue for #11622 is caused by this.

This is a macro!! In a function, arguments are true variables in the usual CMake sense. In a macro, they are not, they are string replacements much like the C preprocessor would do with a macro

if(USE_PCH)can't work, we MUST use if(${USE_PCH})

https://cmake.org/cmake/help/latest/command/macro.html#argument-caveats

Comment thread cmake/ProjectMacros.cmake

# Create test targets
macro(CREATE_TEST_TARGETS BASE_NAME SRC DEPENDENCIES USE_PCH)
macro(CREATE_TEST_TARGETS BASE_NAME SRC DEPENDENCIES)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

USE_PCH was passed as True/False: it's used by third_party/ObjexxFCL/CMakeLists.txt too, with False on purpose

It's much cleaner to not take that argument, and handle the target_precompile_headers at the call site!

Comment on lines +311 to +314
create_test_targets(energyplus "${test_src}" "${test_dependencies}")
if(ENABLE_PCH)
target_precompile_headers(energyplus_tests PRIVATE ${EP_TEST_CXX_PCH_HEADERS})
endif()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Clear AND foolproof

Comment thread CMakeLists.txt
Comment on lines +49 to +52
set(EP_TEST_CXX_PCH_HEADERS
${EP_CXX_PCH_HEADERS}
"$<$<COMPILE_LANGUAGE:CXX>:<gtest/gtest.h>>"
"$<$<COMPILE_LANGUAGE:CXX>:${PROJECT_SOURCE_DIR}/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.hh>")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

test pch include EnergyPlusFixture.hh and gtest/gtest.h

ccache --set-config=max_size=500M
ccache --set-config=compression=true
ccache --set-config=sloppiness=pch_defines,time_macros
ccache --set-config=base_dir="${{ github.workspace }}"

@jmarrec jmarrec Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

My guess is that that's the thing that might breaks MSVC PCH (/Yc vs /Yu path mismatch → C1010)

Locally on a windows 11 arm64 VM I can build 100% fine with PCH and ccache, using the same versions

  • ccache: 4.13.6
  • ninja: 1.13.2
  • MSVC: v17.14.33 (Entreprise on CI, Community on VM)
  • cmake: 4.3.3

@jmarrec jmarrec requested a review from mitchute June 5, 2026 23:03
@jmarrec jmarrec self-assigned this Jun 5, 2026
@jmarrec

jmarrec commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

I tested a PR on my fork with two commits: jmarrec#19

  • First one uses a warm cache from develop, and does a quick non PCH header change
  • Second one grabs the branch ccache from the previous commit but has a PCH header change

Seems all good. I think base_dir was the culprit indeed.

If this drop we'll see in practice if this still hits PCH issues on windows or not.

@mitchute mitchute merged commit ac87bf0 into develop Jun 8, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Defect Includes code to repair a defect in EnergyPlus Developer Issue Related to cmake, packaging, installers, or developer tooling (CI, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PCH is actually NOT enabled for energyplus_tests

3 participants