Revision fa7b041eca021cecfd883cc5796150dae5ad4c5f authored by Brad King on 28 May 2020, 21:29:31 UTC, committed by Brad King on 29 May 2020, 09:52:03 UTC
Since commit 729d997f10 (Precompile Headers: Add REUSE_FROM signature, 2019-08-30, v3.16.0-rc1~101^2), `GetPchFileObject` handles the case that it is called first for another target's `REUSE_FROM` by calling `AddSource` to make sure `GetObjectName` can produce the correct object name. However, `AddSource` causes `ClearSourcesCache` to be called, which since commit a9f4f58f0c (cmGeneratorTarget: Clear AllConfigSources in ClearSourcesCache, 2020-05-15, v3.16.7~2^2) now correctly erases the `AllConfigSources` structure. This is okay during `AddPchDependencies`, but there is another code path in which it is problematic. When the Visual Studio generator's `WriteAllSources` method is looping over the sources, the `cmake_pch.cxx` source is encountered first. This causes `OutputSourceSpecificFlags` to call `GetPchCreateCompileOptions`, which calls `GetPchFile`, which under MSVC with `CMAKE_LINK_PCH` calls `GetPchFileObject`. That leads to `ClearSourcesCache` erasing the structure over which `WriteAllSources` is iterating! This bug is caught by our `RunCMake.PrecompileHeaders` test when run with the VS generator as of the commit that exposed it by fixing `ClearSourcesCache`. However, that change was backported to the CMake 3.16 series after testing only with later versions versions that contain commit a55df20499 (Multi-Ninja: Add precompile headers support, 2020-01-10, v3.17.0-rc1~136^2). By adding proper multi-config support for PCH, that commit taught `cmLocalGenerator::AddPchDependencies` to call `GetPchFile` with the real set of configurations instead of just the empty string. This allows the `GetPchFile` cache of PCH sources to be populated up front so that the later calls to it in the `WriteAllSources` loop as described above do not actually call `GetPchFileObject` or `ClearSourcesCache`. That hid the problem. Fix this by re-ordering calls to `AddPchDependencies` to handle `REUSE_FROM` targets only after the targets whose PCH they re-use. Remove the now-unnecessary call to `AddSource` from `GetPchFileObject` so that `ClearSourcesCache` is never called during `WriteAllSources`. Update the PchReuseFrom test case to cover an ordering of targets that causes generators to encounter a `REUSE_FROM` target before the target whose PCH it re-uses. Fixes: #20770
1 parent a9f4f58
File | Mode | Size |
---|---|---|
.github | ||
Auxiliary | ||
Help | ||
Licenses | ||
Modules | ||
Packaging | ||
Source | ||
Templates | ||
Tests | ||
Utilities | ||
.clang-format | -rw-r--r-- | 1.2 KB |
.clang-tidy | -rw-r--r-- | 1010 bytes |
.gitattributes | -rw-r--r-- | 1.1 KB |
.gitignore | -rw-r--r-- | 132 bytes |
.hooks-config | -rw-r--r-- | 418 bytes |
CMakeCPack.cmake | -rw-r--r-- | 9.7 KB |
CMakeCPackOptions.cmake.in | -rw-r--r-- | 11.9 KB |
CMakeGraphVizOptions.cmake | -rw-r--r-- | 153 bytes |
CMakeLists.txt | -rw-r--r-- | 32.3 KB |
CMakeLogo.gif | -rw-r--r-- | 4.4 KB |
CONTRIBUTING.rst | -rw-r--r-- | 3.1 KB |
CTestConfig.cmake | -rw-r--r-- | 440 bytes |
CTestCustom.cmake.in | -rw-r--r-- | 6.6 KB |
CompileFlags.cmake | -rw-r--r-- | 4.2 KB |
Copyright.txt | -rw-r--r-- | 5.2 KB |
DartConfig.cmake | -rw-r--r-- | 374 bytes |
README.rst | -rw-r--r-- | 3.9 KB |
bootstrap | -rwxr-xr-x | 51.7 KB |
cmake_uninstall.cmake.in | -rw-r--r-- | 790 bytes |
configure | -rwxr-xr-x | 99 bytes |
doxygen.config | -rw-r--r-- | 27.4 KB |
Computing file changes ...