Replies: 12 comments 17 replies
-
I think this is a fair point, particularly with recent discussion now moving towards a two- or three- dimensional space of possible flag combinations (compiler, build profile, flag type/scope). This will inevitably lead to quite lengthy manifest entries. I agree that having fpm understand and abstract common compiler flags would be greatly beneficial. Ivan @ivan-pi has nicely summarised different compiler optimisation flags in #112 (comment) and compiler runtime checks in #50 (comment). With that said, I think we are always going to need a way for developers to manually specify flags, which leads us back to the current proposed approach under discussion. I think the current plan is to move forward with #112/#350 and then use the resulting infrastructure in fpm to provide abstractions to common features such as |
Beta Was this translation helpful? Give feedback.
-
I think this is nearly orthogonal to being able to specify compiler flags manually. And the amount of effort required for every option we want to support in a "compiler agnostic" way will be huge. With such a variety of compiler flags and their meanings, each one will have to be discussed ad nauseam, probably putting together a large number of different tables and running lots of tests. I think we should design such a feature to work in tandem with a "features" capability similar to what Cargo has. Basically some intrinsic features that fpm knows the semantics about, and involves adding the appropriate compiler flags with the proper "propagation" up and/or down the dependency tree. I don't think the proposed solution for manually specifying compiler flags (#350) will preclude such a functionality. I do think they will possibly end up being mutually exclusive (i.e. you can't manually specify compiler flags and use "intrinsic features", as it's quite possible to end up specifying conflicting flags that way). For that reason I think adding a warning when using manually specified compiler flags is perfectly reasonable, including the |
Beta Was this translation helpful? Give feedback.
-
I think that user not having to specify flags should be a high priority for fpm. This warrants "sane" profiles like "debug" and "release" that we already have for gfortran (maybe ifort too?), and I'd suggest even adding a 3rd profile called "fast", which would include things like fpm should also be inclusive, so when a user really needs to set a specific flag per source file, they can. I don't think sane profiles and custom flags are at odds. |
Beta Was this translation helpful? Give feedback.
-
Some applications need some source files compiled with -O2, because they break with -O3
Reminds me of this tweet from @jeffhammond: https://twitter.com/science_dot/status/1380323169127387143
It’s good to allow mixing but in the case of my tweet, the bug existed at all levels of optimization. However, I’m aware of plenty of cases where mixing -O2 and -Ofast (or equivalent) is necessary or useful.
|
Beta Was this translation helpful? Give feedback.
-
Smart features like automatic compiler independent profiles are certainly a nice idea, but I don't think they exclude fine-grained low-level access to specify compiler flags. Nothing is more frustrating than running into a smart feature that knows what you want to do better than yourself without a mean to circumvent it. I think we might even be able to implement the necessary logic for handling something like [dependencies]
fast-math = "no-fast-math" Maybe the fast-math package and its no-fast-math version will be a horrible mess of package manifest to handle all the nifty details for different compiler vendors, but it would be a well contained and manageable mess, downstream your package manifest will be clean and expressive. |
Beta Was this translation helpful? Give feedback.
-
I don't have all the answers, but I would like us to keep discussing this and figure out a good design. Another angle is that I want to be able to compile the packages in various "profiles", such as Debug, Release, Strict, fast-math, no fast-math, etc. Ideally I want to set this at a command line for the final application, and fpm would recompile everything correctly. So if we allow to specify compiler options directly, it needs to play well with that design. In the "Release" profile, I know that different people have different requirements. Some people want strict standard conformance, and within that as fast as possible (e.g., no Part of the solution could be not to hardwire all this into fpm itself, but somehow allow the user to modify / customize the "profiles" somehow. |
Beta Was this translation helpful? Give feedback.
-
Another option to search for community compiler profiles would be https://fortran-lang.org/packages. This data mining effort is a lot of work, because hunting for compiler profiles in build systems is one of the least fun tasks I could imagine. |
Beta Was this translation helpful? Give feedback.
-
Let's discuss it at the Fortran call this Thursday: https://fortran-lang.discourse.group/t/fortran-monthly-call-april-2021/954/6?u=certik. The proposal at #350 is fine, but ultimately it just allows to specify compiler dependent flags that are opaque to fpm. That is only the first step. I would like to brainstorm and discuss ways to improve fpm so that one does not have to use that. Perhaps let's list the use cases. Here are some off the top of my head that I had to handle in the past, I'll just list them for gfortran, there are similar options for other compilers. Here are options that you have to specify otherwise the code would not even compile:
Then there are options regarding correctness of output / optimizations:
Then there are warning options that I frequently use, this is related to Debug/Release:
Enabling features:
I think these are most of the options that I use, so it's not that many actually (given that GFortran has hundreds of options I believe). So for my use cases, at the very least @everythingfunctional, @milancurcic, @awvwgk and others, why don't you list all the flags flags that you use? Once we have most of the use cases, let's brainstorm how to make @everythingfunctional you mentioned that you are worried about the amount of effort to support every option. I suggest we support the most used options, but not every option for every compiler. I only use about ~20 options (listed above) out of hundreds, so it's a very small percentage, yet it covers very large percentage of use cases. The general design that we have been following so far for |
Beta Was this translation helpful? Give feedback.
-
I have sets for Gfortran and Intel and (untested) PGI/Nvidia |
Beta Was this translation helpful? Give feedback.
-
This is what is used in the conda-build setup for GFortran on conda-forge in a native compilation. Micro architecture cross-compilation (very architecture specific):
Security:
Compiler performance:
Packaging:
|
Beta Was this translation helpful? Give feedback.
-
There are some options that go with non-standard extensions, some compilers like NVHPC have enabled non-standard extensions by default and provide arguments to disable those. C style escape character:
|
Beta Was this translation helpful? Give feedback.
-
I've also used:
|
Beta Was this translation helpful? Give feedback.
-
See for example #112.
We need to be able to specify specific compiler flags per file as an option, in order to allow people to get their stuff built. However, I am worried that we could become just like "cmake", where each project hardwires compiler flags as needed.
Rather, I would like to encourage
fpm
to know as much as possible, such as good default Debug / Release flags, and-ffast-math
handling for all compilers, and any other such flags in a compiler independent manner. That way, when we want to add support for a new compiler, we just have to modifyfpm
, and packages should (in theory) just work, if they only use thefpm
integrated facilities, as opposed to compiler dependent flags directly.Another way to look at it: if each package adds
-ffast-math
as a direct compiler flag, thenfpm
does not know the "semantics" of it, it is just an opaque compiler flag, so it cannot help. But if each package usesfast-math
built-infpm
flag, thenfpm
knows exactly what semantics the user is trying to achieve, and can ensure and check that all packages are compatible with it and that things just work in any compiler. And we can iteratively keep improvingfpm
's handling offast-math
to get better error messages and better support, as we discover bugs. We do not need to fix every package, we just have to improvefpm
. The same with any other flag.Do you agree / disagree?
Beta Was this translation helpful? Give feedback.
All reactions