-
Notifications
You must be signed in to change notification settings - Fork 100
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
Allow to find include files / modules in CPATH environment variable #444
Conversation
This will not resolve the issue that GFortran is not searching in the systems default include directory from the C compiler (like Any ideas how to force GFortran to actually look for system installed module files? |
We could try to parse the cpp include paths from the output of
and manually append them. But now we are getting into working around compiler bugs. I'll mark this as won't fix until we established a strategy how to deal with such issues, see #447. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tried it and it works. It needed a small fix to os_is_unix()
.
So if others support it, I think this is a step forward.
I added 4 reviewers to this, with hope to get consensus on whether we should merge this or not. |
Can you explain the use case that this is trying to fix? I think no doubt I don't think we should depend on environment variables like CPATH, FFLAGS, FC, etc., or do we? This is part of the design decisions what we want |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I explained above, it seems to me currently we do not want to do this. But let's discuss it, I am happy to change my mind if presented with good arguments.
The use case is to tell the compiler where to find modules, without having to do it on the CLI which is possible but unwieldy. I don't know about the background on CPATH. I haven't used it before for Fortran, and I think the motivation for that name is that other compilers use it. I think the more relevant question is whether to use env vars in fpm at all. If yes, this could be fpm-specific, like FPM_MODULES_PATH or similar. |
I still don't understand the use case: why do you need to tell (Yes, |
This is for finding external dependencies, like HDF5 and NetCDF. |
I see. I can see a use case where you use Spack or the module system at an HPC machine to load quite a few such dependencies and you would like to use fpm and still pick them up. So for that |
Like the title says, it's not just about modules but also include files. Taking as an example the NLopt library. If I install the developer files with
However, since this location is not on |
@ivan-pi we could do |
Sure, and I typically set paths manually to my own builds from source, so that's another use case. |
There are some subtle issue with this patch and I also think it is trying to solve the wrong problem. The main issue here is about consistency IMO. There are two way a Fortran processor can depend on external files:
For the C preprocessor Leaving aside that GFortran at least lacks proper documentation on this behaviour, this discrepancy burns the Eventually, it boils down to the issue why we started fpm: dependencies between Fortran projects. The actual issue is that Fortran projects install their compiler dependent module files in the system include path together with their compiler agnostic include files. I think we all agree that this is not the way this problem is to be solved. Let's focus on the question at hand, is there a way we can allow an fpm user to work around the problem of compiler not properly documenting its behaviour and a Fortran package installing files where they don't belong in a minimally painful way? The answer so far is |
@awvwgk does this fix your use case: #444 (comment) ? |
I would refrain from introducing new environment variables whenever possible. But the general idea to split the module search from the include file search is a good one, there are indeed compilers that implement this approach (at least one, don't remember which), but it is not generally available from all vendors so we can't implement it. |
@awvwgk What's the alternative then? |
I wish I had an (easy) answer for you. My concern are mainly reproducible builds here. Would you consider a change in this environment variable a change in the build environment? Should it go into the build hash or not? If it does not, interesting things might happen if change the HDF5 external module path from version 1.10 to 1.12 and do an incremental rebuild. Also, I'm currently not seeing how this would solve the issue if I'm building with multiple compilers (different versions, different vendors). |
Well, that's the issue with depending on external libraries. I feel using CPATH would make it even worse, at least we can control |
Reproducible builds are important.
Yes, it should. And that's not enough for reproducible builds. A module file under any path (regardless of how it's passed, In that sense, current approaches to external modules are not reproducible either. But env. variable would not make it worse in this regard, and would be better relative to the
This:
is easier to do than replacing module files in |
I wonder if we are over-stating the issue of external
A first step would be to add a section to the |
It's relevant for any 3rd party package that provides a module. There may not be many of them, but the few of them have a huge surface area. So the number of packages is not necessarily the relevant variable. If you mean to say "I won't use it, so we shouldn't support it", that's not a helpful argument and it's dismissive of other users. The issue is overstated if you don't need it, and it's understated if you do need it. I need it. :) Support for external modules allows me to use fpm for professional work and not just hobby toy projects. Before #438 I could only play with fpm and that's it. So I feel strongly about this feature. NetCDF is the main one. MPI is mostly taken care of thanks to its wrappers. Once I have those two working well, ESMF will be the next one. Maintaining these as fpm packages will be possible, but extremely challenging (HPC-oriented, cross-platform, multi-language, in active development i.e. a moving target, etc.). So it's not a reasonable solution in the present. And we already support this thanks to #438. So the question now is not whether to support it, but how to improve the UI? Currently it's not good, see #452.
Yes, we should do this, and it's a long-term goal for fpm for all Fortran packages to be fpm packages. But it's a separate and orthogonal issue. Until all packages are fpm packages, there must be good support for 3rd party modules. |
How do packages like NetCDF and HDF5 deal with the problem that Personally, I prefer command line arguments to environment variables. I get a bit annoyed at things cluttering up my environment. Also, they get documented in the help message, so if I forget how to supply that info, a simple Also, given the (relatively) small number of external packages that may need to be supported this way, should they be supported as "features" that are on for a package that needs them, and users have a config file (maybe |
I don't think they do at all. If you get them through the package manager, it's its responsibility. If you build them from source, it's your responsibility. I don't know what Conda or Spack do about it. I use both the system provided-package for system-provided gfortran, and builds from source for custom versions and other compilers.
Try it with include paths. I did. It's pretty bad. You have to try it to really appreciate it. :) |
I'm sorry if my comment sounded dismissive. I understand NetCDF is a highly used library relevant to potentially hundreds of Fortran projects. I am aware of circumstances around such packages (some outlined in your second paragraph) that make them a difficult target. To use the (third-party) I just thought that if there is only of a handful of such libraries, it might be easier to focus our effort on implementing fpm support "upstream" (e.g. in a fortran-lang fork of the netcdf-fortran repository) than to design temporary "shortcuts" in
Now that I have better grasp of your usage case, I can appreciate why a (compiler-independent) way to specify module locations is needed. The next breakpoint for the transformation of third-party libraries into |
I don't think that @ivan-pi was dismissive. We all agree that we need to support this somehow. What we are discussing is a short term as well as a long term solution. The short term solution is to make |
Right, that's why I was careful to phrase it as "If you mean to say "I won't use it, so we shouldn't support it"". ;) I 100% agree with what you wrote. |
I strongly believe that fpm will eventually be the build system and package manager of almost all Fortran packages, and all new ones. In other words, there will be a time when it will be weird for a package to not have fpm.toml in it, like Cargo.toml in Rust. For legacy (unmaintained) packages, we may have to maintain a fork under fortran-lang.org, which is more work. For active packages like NetCDF or MPI, I think it would be easier to convince and collaborate their developers to adopt an fpm.toml and restructure if needed. Then we wouldn't have to maintain a fork ourselves and make sure it's synced with the original project. Convincing their developers to include and then maintain an fpm manifest may be even easier if we can point them to the large number of fpm packages that use their library as a dependency. In that sense, it's possible that the short-term solution would help the long-term vision by developing a track record and a network effect within the fpm ecosystem. |
@ivan-pi I apologize for assuming too much about your comment and not taking it in the best light. I know that you didn't mean to be dismissive. |
FYI, I wrote a small program (already some time ago in response to this ticket, but I seem to have forgotten to post it) that reads these pkgconfig files, including the substitution of macros. Maybe it is useful for fpm. |
Since I don't intend to continue working on this pull request, I'm going to close it. This branch can be resurrected from e0767b4 if needed. |
This should make it easier for GFortran based builds to find modules in non-standard locations