Strange failure with ficticious Fortran module dependency

46 views
Skip to first unread message

Keith Refson

unread,
Dec 20, 2022, 2:22:52 PM12/20/22
to ninja-build
I discovered an odd failure while attempting to port a large (mostly-)Fortran project to cmake+ninja under Msys2.

The failure is clearly in the Fortran source code parser attempting to search for "module" statements, which misfires on the line in my codebase:

      call io_abort("Error in "//subroutine_name//": attempting to initialise ion_ion &
                    &module when module has already been initialised.")


The parser erroneously imagines it spots the start of a new module, failing to notice that the text "module when" is part of a quoted string, continued from the previous line.  This generates a .ddi file containing

   "provides" :
     [
         {
             "compiled-module-path" : "mod/ion_ion.mod",
             "logical-name" : "ion_ion.mod"
         }
         {
             "compiled-module-path" : "mod/when.mod",
             "logical-name" : "when.mod"
         }
     ],


and ultimately leads to an aborted build with
ninja: build stopped: multiple rules generate mod/when.mod.

This failure occurs in msys2/ucrt64 on Windows 10 with cmake 2.24.2 and ninja 1.11.1.  I have attempted to reproduce this under linux with the same versions of cmake and ninja, but on that platform the error does not occur. I am very new to ninja, and I hope I have it write that the dependency generation is part of ninja and not cmake.

I wonder if the failure to detect a continued quoted string might be due to some issue with regexp matching and windows like endings?  Any thoughts/suggestions welcome.

Ben Boeckel

unread,
Dec 20, 2022, 7:09:37 PM12/20/22
to Keith Refson, ninja-build
On Mon, Dec 19, 2022 at 06:55:22 -0800, Keith Refson wrote:
> I discovered an odd failure while attempting to port a large
> (mostly-)Fortran project to cmake+ninja under Msys2.
>
> The failure is clearly in the Fortran source code parser attempting to
> search for "module" statements, which misfires on the line in my codebase:

This is a CMake issue, not a Ninja issue. Please file it on the issue
tracker[1] or discuss it on Discourse[2].

> I wonder if the failure to detect a continued quoted string might be due to
> some issue with regexp matching and windows like endings? Any
> thoughts/suggestions welcome.

Once it's open there I'll respond more fully (feel free to ping me
`@ben.boeckel`) to avoid distracting this list.

Thanks,

--Ben

[1]https://gitlab.kitware.com/cmake/cmake/-/issues
[2]https://discourse.cmake.org/

Keith Refson

unread,
Dec 21, 2022, 5:40:46 AM12/21/22
to ninja-build
Ah, since posting this I had worked out, looking at the build.ninja file that ninja does a callback of "cmake -E" to generate the dependencies.  Over to the cmake sites then.
K.
Reply all
Reply to author
Forward
0 new messages