diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2023-07-22 10:46:31 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2023-07-22 11:12:43 (GMT) |
commit | b665966933c8656d1dafde06b8f29fe7e4901738 (patch) | |
tree | 3a006a29d8ced92cf5662cb7a9216c0f0cb8d8e7 /Source/cmComputeLinkInformation.cxx | |
parent | a99b87a6285d9801ed429d5f44308b24c4706fb8 (diff) | |
download | CMake-b665966933c8656d1dafde06b8f29fe7e4901738.zip CMake-b665966933c8656d1dafde06b8f29fe7e4901738.tar.gz CMake-b665966933c8656d1dafde06b8f29fe7e4901738.tar.bz2 |
cmComputeLinkInformation: track OBJECT library dependencies
In commit b6a5382217 (Ninja: depend on language module information files
directly, 2023-02-10), introduced via !8197, language-specific module
information files (`CMakeFiles/<target>.dir/<lang>Modules.json`) files
were added as real dependencies to the dyndep collation steps.
Previously, the behavior was to inform the collator of all possible
targets and search for the files manually ignoring those which did not
exist with ordering enforced by depending on the linker output of all
dependent targets. This behavior could lead to stale information being
used (e.g., if a target stops providing any targets) and also did not
reliably build everything needed on rebuilds. Afterwards, the internal
computation changed the dependency from all possible targets to an exact
set of "these targets might have modules" query, however one that did
not include `OBJECT` libraries since do not have `LinkEntry` items
internally (their objects are instead treated as source files).
As a stopgap measure, track `OBJECT` libraries in a separate list and
query them explicitly when gathering targets which may have interesting
information. Future work can add `LinkEntry` items to represent these
targets once all `LinkEntry` consumers have been audited to make sure
they are not surprised by any `OBJECT` library entries.
Fixes: #25112
Diffstat (limited to 'Source/cmComputeLinkInformation.cxx')
-rw-r--r-- | Source/cmComputeLinkInformation.cxx | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index b80b3cb..ebbb88f 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -525,6 +525,12 @@ cmComputeLinkInformation::GetSharedLibrariesLinked() const return this->SharedLibrariesLinked; } +const std::vector<const cmGeneratorTarget*>& +cmComputeLinkInformation::GetObjectLibrariesLinked() const +{ + return this->ObjectLibrariesLinked; +} + bool cmComputeLinkInformation::Compute() { // Skip targets that do not link. @@ -1147,8 +1153,12 @@ void cmComputeLinkInformation::AddItem(LinkEntry const& entry) this->AddItem(BT<std::string>(libName, item.Backtrace)); } } else if (tgt->GetType() == cmStateEnums::OBJECT_LIBRARY) { - // Ignore object library! - // Its object-files should already have been extracted for linking. + if (!tgt->HaveCxx20ModuleSources() && !tgt->HaveFortranSources(config)) { + // Ignore object library! + // Its object-files should already have been extracted for linking. + } else { + this->ObjectLibrariesLinked.push_back(entry.Target); + } } else { // Decide whether to use an import library. cmStateEnums::ArtifactType artifact = tgt->HasImportLibrary(config) |