#11622 - PCH is actually NOT enabled for energyplus_tests + fixup PCH usage on Windows CI#11623
Conversation
…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 ```
…mpile_headers at the call site
…H, so stop doing it
… the weirdness. No PCH is tested in test_develop_commits.yml
Functionally revert b032784
…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
There was a problem hiding this comment.
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
| # 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 |
There was a problem hiding this comment.
Switched this, made a note to keep both workflows in line
| # 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 |
| 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 }}- |
There was a problem hiding this comment.
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 }} |
| add_executable(${BASE_NAME}_tests ${SRC}) | ||
| target_link_libraries(${BASE_NAME}_tests PRIVATE project_options project_warnings) | ||
|
|
||
| if(USE_PCH) |
There was a problem hiding this comment.
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
|
|
||
| # Create test targets | ||
| macro(CREATE_TEST_TARGETS BASE_NAME SRC DEPENDENCIES USE_PCH) | ||
| macro(CREATE_TEST_TARGETS BASE_NAME SRC DEPENDENCIES) |
There was a problem hiding this comment.
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!
| create_test_targets(energyplus "${test_src}" "${test_dependencies}") | ||
| if(ENABLE_PCH) | ||
| target_precompile_headers(energyplus_tests PRIVATE ${EP_TEST_CXX_PCH_HEADERS}) | ||
| endif() |
| 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>") |
There was a problem hiding this comment.
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 }}" |
There was a problem hiding this comment.
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
|
I tested a PR on my fork with two commits: jmarrec#19
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. |
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:
after
The expensive headers are gone
CI PCH
I started doing very complicated things, but in the end I went with simple:
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
Reviewer