From 98e97602134d3e5c24de9a11f98a9a44d49ddb2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20R=C3=B6hling?= Date: Tue, 25 Jul 2023 16:45:07 +0200 Subject: [PATCH] Fix regressions with Fortran Closes: #1041853 --- debian/patches/series | 2 + ...ran_PREPROCESS-property-initializati.patch | 24 ++++ ...ormation-track-OBJECT-library-depend.patch | 107 ++++++++++++++++++ 3 files changed, 133 insertions(+) create mode 100644 debian/patches/upstream/0002-fix-typo-in-Fortran_PREPROCESS-property-initializati.patch create mode 100644 debian/patches/upstream/0003-cmComputeLinkInformation-track-OBJECT-library-depend.patch diff --git a/debian/patches/series b/debian/patches/series index 812333042..a42c52c68 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1 +1,3 @@ 0001-Prefer-default-Python-version.patch +upstream/0002-fix-typo-in-Fortran_PREPROCESS-property-initializati.patch +upstream/0003-cmComputeLinkInformation-track-OBJECT-library-depend.patch diff --git a/debian/patches/upstream/0002-fix-typo-in-Fortran_PREPROCESS-property-initializati.patch b/debian/patches/upstream/0002-fix-typo-in-Fortran_PREPROCESS-property-initializati.patch new file mode 100644 index 000000000..42568440c --- /dev/null +++ b/debian/patches/upstream/0002-fix-typo-in-Fortran_PREPROCESS-property-initializati.patch @@ -0,0 +1,24 @@ +From: =?utf-8?q?Timo_R=C3=B6hling?= +Date: Tue, 25 Jul 2023 16:38:44 +0200 +Subject: fix typo in Fortran_PREPROCESS property initialization + +Origin: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8654 +Bug: https://gitlab.kitware.com/cmake/cmake/-/issues/25123 +Bug-Debian: https://bugs.debian.org/1041853 +--- + Source/cmTarget.cxx | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx +index 81497f5..b53adf8 100644 +--- a/Source/cmTarget.cxx ++++ b/Source/cmTarget.cxx +@@ -420,7 +420,7 @@ TargetProperty const StaticTargetProperties[] = { + { "Fortran_FORMAT"_s, IC::CanCompileSources }, + { "Fortran_MODULE_DIRECTORY"_s, IC::CanCompileSources }, + { "Fortran_COMPILER_LAUNCHER"_s, IC::CanCompileSources }, +- { "Fortran_PREPRPOCESS"_s, IC::CanCompileSources }, ++ { "Fortran_PREPROCESS"_s, IC::CanCompileSources }, + { "Fortran_VISIBILITY_PRESET"_s, IC::CanCompileSources }, + // ---- HIP + COMMON_LANGUAGE_PROPERTIES(HIP), diff --git a/debian/patches/upstream/0003-cmComputeLinkInformation-track-OBJECT-library-depend.patch b/debian/patches/upstream/0003-cmComputeLinkInformation-track-OBJECT-library-depend.patch new file mode 100644 index 000000000..f89710d73 --- /dev/null +++ b/debian/patches/upstream/0003-cmComputeLinkInformation-track-OBJECT-library-depend.patch @@ -0,0 +1,107 @@ +From: Ben Boeckel +Date: Sat, 22 Jul 2023 06:46:31 -0400 +Subject: 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/.dir/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. + +Bug: https://gitlab.kitware.com/cmake/cmake/-/issues/25112 +--- + Source/cmCommonTargetGenerator.cxx | 12 +++++++++--- + Source/cmComputeLinkInformation.cxx | 14 ++++++++++++-- + Source/cmComputeLinkInformation.h | 3 +++ + 3 files changed, 24 insertions(+), 5 deletions(-) + +diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx +index e635dd9..1924235 100644 +--- a/Source/cmCommonTargetGenerator.cxx ++++ b/Source/cmCommonTargetGenerator.cxx +@@ -170,9 +170,15 @@ std::vector cmCommonTargetGenerator::GetLinkedTargetDirectories( + cmGlobalCommonGenerator* const gg = this->GlobalCommonGenerator; + if (cmComputeLinkInformation* cli = + this->GeneratorTarget->GetLinkInformation(config)) { +- cmComputeLinkInformation::ItemVector const& items = cli->GetItems(); +- for (auto const& item : items) { +- cmGeneratorTarget const* linkee = item.Target; ++ std::vector targets; ++ for (auto const& item : cli->GetItems()) { ++ targets.push_back(item.Target); ++ } ++ for (auto const* target : cli->GetObjectLibrariesLinked()) { ++ targets.push_back(target); ++ } ++ ++ for (auto const* linkee : targets) { + if (linkee && + !linkee->IsImported() + // Skip targets that build after this one in a static lib cycle. +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& ++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(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) +diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h +index a4ada1f..8393a29 100644 +--- a/Source/cmComputeLinkInformation.h ++++ b/Source/cmComputeLinkInformation.h +@@ -96,6 +96,8 @@ public: + std::string GetRPathString(bool for_install) const; + std::string GetChrpathString() const; + std::set const& GetSharedLibrariesLinked() const; ++ std::vector const& GetObjectLibrariesLinked() ++ const; + std::vector const& GetRuntimeDLLs() const + { + return this->RuntimeDLLs; +@@ -132,6 +134,7 @@ private: + std::vector FrameworkPaths; + std::vector RuntimeSearchPath; + std::set SharedLibrariesLinked; ++ std::vector ObjectLibrariesLinked; + std::vector RuntimeDLLs; + + // Context information.