Skip to content

Implicit relationship between the names of a module and the source file that contains it assumed #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
arjenmarkus opened this issue Jul 21, 2020 · 8 comments

Comments

@arjenmarkus
Copy link
Member

arjenmarkus commented Jul 21, 2020

I have run into a problem that is illustrated with the attached project:

`
$ d:/fortran/fpm/fpm.exe build

gfortran (for build/gfortran_debug/mxmy/mx.o build/gfortran_debug/mxmy/mx.mod)

fpm.exe: Error when running Shake build system:
at want, called at src\Build.hs:205:11 in fpm-0.1.0.0-9a29EtwrI5D7C1C0BiAJeV:Build

  • Depends on: build/gfortran_debug/mxmy/libmxmy.a
    at need, called at src\Build.hs:203:13 in fpm-0.1.0.0-9a29EtwrI5D7C1C0BiAJeV:Build
  • Depends on: build/gfortran_debug/mxmy/mx.o
    at &%>, called at src\Build.hs:183:11 in fpm-0.1.0.0-9a29EtwrI5D7C1C0BiAJeV:Build
  • Depends on: build/gfortran_debug/mxmy/mx.o build/gfortran_debug/mxmy/mx.mod
    at error, called at src\Development\Shake\Internal\Rules\Files.hs:245:13 in shake- 0.18.5-7VS8ovPeUeSCopHgkQQ1Vu:Development.Shake.Internal.Rules.Files
  • Raised the exception:
    Error, &%> rule failed to produce 1 file (out of 2)
    build/gfortran_debug/mxmy/mx.o
    build/gfortran_debug/mxmy/mx.mod - MISSING
    `

The source file is called "mx.f90" but it contains a module "my". Apparently this is not currently supported, whether by design or otherwise. It seems to me to be a bug.
test-fpm-mxmy.zip

@milancurcic
Copy link
Member

Hi Arjen, yes, it's by design, see https://github.com/fortran-lang/fpm/blob/master/PACKAGING.md#single-module-library.

The rationale is that if we have higher constraints on the user application or library structure, we can design a more robust build system that has a "sane default" with fewer edge cases.

Do you think the packaging guide could be improved in any way?

@milancurcic
Copy link
Member

However, the unhelpful response from fpm is not by design, but is due to this exception handling not being implemented. In scenarios like this fpm must be helpful to the user, for example:

fpm error: I noticed that you defined a module `my` in file `src/mx.f90`. The module name must match the source (path) name. Either rename your module to `mx`, or place it in `src/my.f90`.

or similar.

@certik
Copy link
Member

certik commented Jul 21, 2020

Yes, the default layout that fpm expects is on purpose restricted, similar to how Cargo does it. The module names must be consistent with the filename.

However, I am all for allowing exceptions, which you could specify by hand in fpm.toml. We should do that.

The error message is not helpful. But we should work on fixing both of these things in the Fortran implementation (see #124).

@arjenmarkus
Copy link
Member Author

arjenmarkus commented Jul 21, 2020 via email

@milancurcic
Copy link
Member

@certik I opened #129 and #130 to track these specific exception handling and error message issues.

I also created the fpm-fortran tag so that we can tag any issue to be specific to the Fortran implementation and not Haskell. You'll notice that I didn't initially tag #129 and #130 as fpm-fortran, as I'm unsure whether we should leave these unattended for a long time before fpm-fortran is up to speed. I think they're quite critical UI issues.

@certik
Copy link
Member

certik commented Jul 21, 2020

And I implemented the initial infrastructure for Fortran at #131 to start getting things moving.

@awvwgk
Copy link
Member

awvwgk commented Oct 31, 2020

This might be fixed with #213.

@everythingfunctional
Copy link
Member

The bootstrap version is no longer enforcing any match between module and source file name.

@awvwgk awvwgk closed this as completed Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants