Skip to content

Store only the base name of a source file in the fsmod file#321

Open
dorchard wants to merge 9 commits intomainfrom
storeBaseNames
Open

Store only the base name of a source file in the fsmod file#321
dorchard wants to merge 9 commits intomainfrom
storeBaseNames

Conversation

@dorchard
Copy link
Copy Markdown
Member

@dorchard dorchard commented Jan 9, 2026

Previously .fsmod files were storing the file filename, which makes them not very portable when using a tool at a different relative directory to the fsmod (this was the underlying issue behind camfort/camfort#190 in CamFort.

This simple fix stores only the files base name in the fsmod file which makes them more portable/referable from different directory contexts.

Show a warning if we cannot find the original source file. This should help prevent some silent failures.
@mrd
Copy link
Copy Markdown
Collaborator

mrd commented Jan 22, 2026

Ok, thoughts:

  • genUniqNameToFilenameMap will only work on a list of parsed modfiles that occur in the same dir
  • .fsmod files will have to accompany the source fortran files in the same dir, they can't be gathered into another dir (e.g. a build/ dir) without losing track of the original source file

plus side:

  • may fix a related bug where it attempts to prepend the dirname to the already fully-specified (absolute/relative) path

@dorchard
Copy link
Copy Markdown
Member Author

How problematic do you see the first couple of points being? (note this fixes this issue in CamFort: camfort/camfort#207)

@mrd
Copy link
Copy Markdown
Collaborator

mrd commented Jan 27, 2026

How problematic do you see the first couple of points being? (note this fixes this issue in CamFort: camfort/camfort#207)

I had originally envisioned the .fsmod files as being something that could be collected separately as part of a build system, like .o files going into a build/ dir. I could relax that view personally, I don't know if there are any people out there using .fsmod files in this way (collecting them in a separate dir from the source) who might object to changes.

Largely, I think this pull request does make things cleaner, aside from that.

@mrd
Copy link
Copy Markdown
Collaborator

mrd commented Feb 2, 2026

I'm not sure why there's a problem with ghc 9.0, the other ones seem to work though. Seems to be a linking problem with th-orphans - unrelated?

@mrd
Copy link
Copy Markdown
Collaborator

mrd commented Feb 22, 2026

I'm not sure why there's a problem with ghc 9.0, the other ones seem to work though. Seems to be a linking problem with th-orphans - unrelated?

The problem fixed itself. Best kind of problems. 😄

@mrd
Copy link
Copy Markdown
Collaborator

mrd commented Feb 22, 2026

One idea, going back to the fundamental conflict, is perhaps to store a SHA1 hash of the original Fortran file, rather than its path. At least then there is something that can be compared, given different Fortran files of the same name (or perhaps different revisions in time of the 'same file').

@dorchard
Copy link
Copy Markdown
Member Author

Yes this is a great idea... perhaps we should do this!

@mrd mrd force-pushed the storeBaseNames branch 4 times, most recently from ae7d9c0 to db20660 Compare March 5, 2026 15:04
@mrd mrd force-pushed the storeBaseNames branch from db20660 to 85cc3b8 Compare March 5, 2026 16:28
@dorchard
Copy link
Copy Markdown
Member Author

sorry need to review - will do next week. does it solve the the camfort issue camfort/camfort#207?

@mrd
Copy link
Copy Markdown
Collaborator

mrd commented Mar 26, 2026

I'm making a new camfort branch fortran-src-0.17 since the API has changed for modfiles. You can see how it affects things there. camfort/camfort#227

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

Successfully merging this pull request may close these issues.

2 participants