Skip to content
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

fpm recompiles the whole project when a line is modified #967

Open
certik opened this issue Oct 20, 2023 · 3 comments
Open

fpm recompiles the whole project when a line is modified #967

certik opened this issue Oct 20, 2023 · 3 comments

Comments

@certik
Copy link
Member

certik commented Oct 20, 2023

On the other hand, cmake only recompiles the given module (if not function interface was changed) and links everything together, so things are much faster.

So this is a big usability deterioration compared to cmake.

@milancurcic
Copy link
Member

milancurcic commented Oct 20, 2023

I was surprised to read this and I haven't used fpm in several weeks so I went back to look. What I observe is actually that if I change one source file (but not changing a procedure interface), fpm rebuilds only the sources that depend on the module(s) in that source file (as opposed to the whole project). This makes sense to me assuming that fpm is only checking if a source file has changed, rather than actually analyzing the source to determine if an interface has changed.

Indeed, doing the same experiment with CMake, sources that depend on that file are not recompiled (if an interface hasn't changed, as you wrote).

@perazz
Copy link
Contributor

perazz commented Oct 21, 2023

To do so, you will have to use submodules as fpm has no embedded Fortran parser, it only checks for used modules to build the dependency tree. I've just checked with the submodules example in example_packages and it actually seems pretty cool: if you only update the submodule, neither the parent module nor any other files depending on it are updated

@certik
Copy link
Member Author

certik commented Nov 30, 2023

I don't use submodules (I personally do not find them useful, I prefer to just write my functions in a regular module, it's less code and I have all the code in one place).

CMake looks at the mod file, if it changed, it will assume the interface changed and it will recompile. This does not work with all compilers. For example Intel apparently embeds a timestamp in it, so cmake always recompiles. LFortran stores all the code in the mod file, so the file also always changes.

I think that this points to a broader issue: the build system must cooperate with the compiler. For example, LFortran could generate just the interface part, so that cmake could check it if it changed. Possibly it can just output a hash of the interface part, that would be easily to deal with.

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

3 participants