From 7c1e52be875548c243168a5630a054e84b47026a Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 17 Nov 2023 10:53:34 -0500 Subject: Tests/FortranModules: add test for TARGET_OBJECTS-as-sources module usage Test module usage across a `$`-as-sources use case. See: #25425 --- Tests/FortranModules/CMakeLists.txt | 4 ++++ .../ModulesViaSubdirTargetObjectsSource/CMakeLists.txt | 6 ++++++ .../subdir/CMakeLists.txt | 1 + .../ModulesViaSubdirTargetObjectsSource/subdir/obj.f90 | 11 +++++++++++ .../ModulesViaSubdirTargetObjectsSource/use.f90 | 13 +++++++++++++ .../ModulesViaTargetObjectsSource/CMakeLists.txt | 4 ++++ Tests/FortranModules/ModulesViaTargetObjectsSource/obj.f90 | 11 +++++++++++ Tests/FortranModules/ModulesViaTargetObjectsSource/use.f90 | 13 +++++++++++++ 8 files changed, 63 insertions(+) create mode 100644 Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/CMakeLists.txt create mode 100644 Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/subdir/CMakeLists.txt create mode 100644 Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/subdir/obj.f90 create mode 100644 Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/use.f90 create mode 100644 Tests/FortranModules/ModulesViaTargetObjectsSource/CMakeLists.txt create mode 100644 Tests/FortranModules/ModulesViaTargetObjectsSource/obj.f90 create mode 100644 Tests/FortranModules/ModulesViaTargetObjectsSource/use.f90 diff --git a/Tests/FortranModules/CMakeLists.txt b/Tests/FortranModules/CMakeLists.txt index 16ea0d4..8e95152e 100644 --- a/Tests/FortranModules/CMakeLists.txt +++ b/Tests/FortranModules/CMakeLists.txt @@ -137,3 +137,7 @@ add_subdirectory(Issue25252-iface-sources) add_subdirectory(Issue25365-target-objects) add_subdirectory(Issue25365-target-objects-iface) + +# Issue#25425 +add_subdirectory(ModulesViaTargetObjectsSource) +add_subdirectory(ModulesViaSubdirTargetObjectsSource) diff --git a/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/CMakeLists.txt b/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/CMakeLists.txt new file mode 100644 index 0000000..255e8a7 --- /dev/null +++ b/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/CMakeLists.txt @@ -0,0 +1,6 @@ +add_subdirectory(subdir) + +add_library(mvstos_lib "$") +target_include_directories(mvstos_lib PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/subdir") +add_library(mvstos_use use.f90) +target_link_libraries(mvstos_use PRIVATE mvstos_lib) diff --git a/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/subdir/CMakeLists.txt b/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/subdir/CMakeLists.txt new file mode 100644 index 0000000..acc0da9 --- /dev/null +++ b/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/subdir/CMakeLists.txt @@ -0,0 +1 @@ +add_library(mvstos_obj OBJECT obj.f90) diff --git a/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/subdir/obj.f90 b/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/subdir/obj.f90 new file mode 100644 index 0000000..6b5ddd5 --- /dev/null +++ b/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/subdir/obj.f90 @@ -0,0 +1,11 @@ +module m1 + +implicit none + +contains + +pure real function pi() +pi = 4*atan(1.) +end function + +end module m1 diff --git a/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/use.f90 b/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/use.f90 new file mode 100644 index 0000000..f971909 --- /dev/null +++ b/Tests/FortranModules/ModulesViaSubdirTargetObjectsSource/use.f90 @@ -0,0 +1,13 @@ +module lib + +use m1, only : pi + +implicit none + +contains + +pure real function func() +func = pi() +end function + +end module diff --git a/Tests/FortranModules/ModulesViaTargetObjectsSource/CMakeLists.txt b/Tests/FortranModules/ModulesViaTargetObjectsSource/CMakeLists.txt new file mode 100644 index 0000000..9113a11 --- /dev/null +++ b/Tests/FortranModules/ModulesViaTargetObjectsSource/CMakeLists.txt @@ -0,0 +1,4 @@ +add_library(mvtos_obj OBJECT obj.f90) +add_library(mvtos_lib "$") +add_library(mvtos_use use.f90) +target_link_libraries(mvtos_use PRIVATE mvtos_lib) diff --git a/Tests/FortranModules/ModulesViaTargetObjectsSource/obj.f90 b/Tests/FortranModules/ModulesViaTargetObjectsSource/obj.f90 new file mode 100644 index 0000000..6b5ddd5 --- /dev/null +++ b/Tests/FortranModules/ModulesViaTargetObjectsSource/obj.f90 @@ -0,0 +1,11 @@ +module m1 + +implicit none + +contains + +pure real function pi() +pi = 4*atan(1.) +end function + +end module m1 diff --git a/Tests/FortranModules/ModulesViaTargetObjectsSource/use.f90 b/Tests/FortranModules/ModulesViaTargetObjectsSource/use.f90 new file mode 100644 index 0000000..f971909 --- /dev/null +++ b/Tests/FortranModules/ModulesViaTargetObjectsSource/use.f90 @@ -0,0 +1,13 @@ +module lib + +use m1, only : pi + +implicit none + +contains + +pure real function func() +func = pi() +end function + +end module -- cgit v0.12 From 9d2769ecbd497dd51405ae2586ae62b828712a07 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 17 Nov 2023 10:53:34 -0500 Subject: Tests/FortranModules: add test for TARGET_OBJECTS-as-linked-items module usage Test module usage across a `$`-as-linked-items use case. See: #25425 --- Tests/FortranModules/CMakeLists.txt | 2 ++ .../ModulesViaSubdirTargetObjectsLink/CMakeLists.txt | 7 +++++++ .../ModulesViaSubdirTargetObjectsLink/dummy.f90 | 3 +++ .../ModulesViaSubdirTargetObjectsLink/subdir/CMakeLists.txt | 1 + .../ModulesViaSubdirTargetObjectsLink/subdir/obj.f90 | 11 +++++++++++ .../ModulesViaSubdirTargetObjectsLink/use.f90 | 13 +++++++++++++ .../ModulesViaTargetObjectsLink/CMakeLists.txt | 5 +++++ Tests/FortranModules/ModulesViaTargetObjectsLink/dummy.f90 | 3 +++ Tests/FortranModules/ModulesViaTargetObjectsLink/obj.f90 | 11 +++++++++++ Tests/FortranModules/ModulesViaTargetObjectsLink/use.f90 | 13 +++++++++++++ 10 files changed, 69 insertions(+) create mode 100644 Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/CMakeLists.txt create mode 100644 Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/dummy.f90 create mode 100644 Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/subdir/CMakeLists.txt create mode 100644 Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/subdir/obj.f90 create mode 100644 Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/use.f90 create mode 100644 Tests/FortranModules/ModulesViaTargetObjectsLink/CMakeLists.txt create mode 100644 Tests/FortranModules/ModulesViaTargetObjectsLink/dummy.f90 create mode 100644 Tests/FortranModules/ModulesViaTargetObjectsLink/obj.f90 create mode 100644 Tests/FortranModules/ModulesViaTargetObjectsLink/use.f90 diff --git a/Tests/FortranModules/CMakeLists.txt b/Tests/FortranModules/CMakeLists.txt index 8e95152e..1e5ff89 100644 --- a/Tests/FortranModules/CMakeLists.txt +++ b/Tests/FortranModules/CMakeLists.txt @@ -141,3 +141,5 @@ add_subdirectory(Issue25365-target-objects-iface) # Issue#25425 add_subdirectory(ModulesViaTargetObjectsSource) add_subdirectory(ModulesViaSubdirTargetObjectsSource) +add_subdirectory(ModulesViaTargetObjectsLink) +add_subdirectory(ModulesViaSubdirTargetObjectsLink) diff --git a/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/CMakeLists.txt b/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/CMakeLists.txt new file mode 100644 index 0000000..b52b423 --- /dev/null +++ b/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/CMakeLists.txt @@ -0,0 +1,7 @@ +add_subdirectory(subdir) + +add_library(mvstol_lib dummy.f90) +target_link_libraries(mvstol_lib PRIVATE "$") +target_include_directories(mvstol_lib PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/subdir") +add_library(mvstol_use use.f90) +target_link_libraries(mvstol_use PRIVATE mvstol_lib) diff --git a/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/dummy.f90 b/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/dummy.f90 new file mode 100644 index 0000000..96a8138 --- /dev/null +++ b/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/dummy.f90 @@ -0,0 +1,3 @@ +pure real function dummy() +dummy = 4*atan(1.) +end function diff --git a/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/subdir/CMakeLists.txt b/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/subdir/CMakeLists.txt new file mode 100644 index 0000000..b2a250d --- /dev/null +++ b/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/subdir/CMakeLists.txt @@ -0,0 +1 @@ +add_library(mvstol_obj STATIC obj.f90) diff --git a/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/subdir/obj.f90 b/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/subdir/obj.f90 new file mode 100644 index 0000000..6b5ddd5 --- /dev/null +++ b/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/subdir/obj.f90 @@ -0,0 +1,11 @@ +module m1 + +implicit none + +contains + +pure real function pi() +pi = 4*atan(1.) +end function + +end module m1 diff --git a/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/use.f90 b/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/use.f90 new file mode 100644 index 0000000..f971909 --- /dev/null +++ b/Tests/FortranModules/ModulesViaSubdirTargetObjectsLink/use.f90 @@ -0,0 +1,13 @@ +module lib + +use m1, only : pi + +implicit none + +contains + +pure real function func() +func = pi() +end function + +end module diff --git a/Tests/FortranModules/ModulesViaTargetObjectsLink/CMakeLists.txt b/Tests/FortranModules/ModulesViaTargetObjectsLink/CMakeLists.txt new file mode 100644 index 0000000..202e59e --- /dev/null +++ b/Tests/FortranModules/ModulesViaTargetObjectsLink/CMakeLists.txt @@ -0,0 +1,5 @@ +add_library(mvtol_obj STATIC obj.f90) +add_library(mvtol_lib dummy.f90) +target_link_libraries(mvtol_lib PRIVATE "$") +add_library(mvtol_use use.f90) +target_link_libraries(mvtol_use PRIVATE mvtol_lib) diff --git a/Tests/FortranModules/ModulesViaTargetObjectsLink/dummy.f90 b/Tests/FortranModules/ModulesViaTargetObjectsLink/dummy.f90 new file mode 100644 index 0000000..96a8138 --- /dev/null +++ b/Tests/FortranModules/ModulesViaTargetObjectsLink/dummy.f90 @@ -0,0 +1,3 @@ +pure real function dummy() +dummy = 4*atan(1.) +end function diff --git a/Tests/FortranModules/ModulesViaTargetObjectsLink/obj.f90 b/Tests/FortranModules/ModulesViaTargetObjectsLink/obj.f90 new file mode 100644 index 0000000..6b5ddd5 --- /dev/null +++ b/Tests/FortranModules/ModulesViaTargetObjectsLink/obj.f90 @@ -0,0 +1,11 @@ +module m1 + +implicit none + +contains + +pure real function pi() +pi = 4*atan(1.) +end function + +end module m1 diff --git a/Tests/FortranModules/ModulesViaTargetObjectsLink/use.f90 b/Tests/FortranModules/ModulesViaTargetObjectsLink/use.f90 new file mode 100644 index 0000000..f971909 --- /dev/null +++ b/Tests/FortranModules/ModulesViaTargetObjectsLink/use.f90 @@ -0,0 +1,13 @@ +module lib + +use m1, only : pi + +implicit none + +contains + +pure real function func() +func = pi() +end function + +end module -- cgit v0.12 From ec1e589bec6567c955db24adeb6294258e3db463 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 21 Nov 2023 09:19:08 -0500 Subject: Ninja: Revert exact collation dependencies for 3.27 Revert commit b6a5382217 (Ninja: depend on language module information files directly, 2023-02-10, v3.27.0-rc1~502^2) from !8197. This reverts the "exact dependencies" for collation inputs and returns to "get all targets" and target-ordering. Use of exact dependencies caused a parade of use cases that had not been tested previously to be found and need fixing over the 3.27 release series. To stop the flow on 3.27, revert to the 3.26 strategy. We will continue in 3.28. Note that this is a restoration of 3.26 semantics where incremental rebuilds may be subtly incorrect in the presence of stale `Modules.json` files. However, since C++ support is experimental and Fortran has always had this problem as of 3.27, it is not considered a regression. See: #25112 See: #25123 See: #25252 See: #25365 See: #25417 See: #25425 --- Source/cmNinjaTargetGenerator.cxx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index d712d71..bc04d1f 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1034,11 +1034,6 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements( cmNinjaBuild build(this->LanguageDyndepRule(language, config)); build.Outputs.push_back(this->GetDyndepFilePath(language, config)); - build.ImplicitOuts.push_back( - cmStrCat(this->Makefile->GetCurrentBinaryDirectory(), '/', - this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget), - this->GetGlobalGenerator()->ConfigDirectory(config), '/', - language, "Modules.json")); for (auto const& scanFiles : scanningFiles) { if (!scanFiles.ScanningOutput.empty()) { build.ExplicitDeps.push_back(scanFiles.ScanningOutput); @@ -1050,10 +1045,17 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements( this->WriteTargetDependInfo(language, config); - for (std::string const& l : - this->GetLinkedTargetDirectories(language, config)) { - build.ImplicitDeps.push_back(cmStrCat(l, '/', language, "Modules.json")); - } + // Make sure dyndep files for all our dependencies have already + // been generated so that the 'Modules.json' files they + // produced as side-effects are available for us to read. + // Ideally we should depend on the 'Modules.json' files + // from our dependencies directly, but we don't know which of + // our dependencies produces them. Fixing this will require + // refactoring the Ninja generator to generate targets in + // dependency order so that we can collect the needed information. + this->GetLocalGenerator()->AppendTargetDepends( + this->GeneratorTarget, build.OrderOnlyDeps, config, fileConfig, + DependOnTargetArtifact); this->GetGlobalGenerator()->WriteBuild(this->GetImplFileStream(fileConfig), build); -- cgit v0.12