-
Notifications
You must be signed in to change notification settings - Fork 104
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
Ability to pass any compiler flags directly to the compiler #1096
Comments
My understanding of the fortran features structure is to hide compiler details behind the flags, so I'm not 100% sure adding compiler-specific flags is the best approach here. Regarding max line length, not all compilers support varying it but GNU definitely offers this good option. Instead of adding one more structure (remember that custom flags are passed via CLI rather than manifest), could we instead just change this: Line 173 in 1cfcaf8
to this? flag_gnu_free_form = " -ffree-form -ffree-line-length-none -ffixed-line-length-none", & |
Thank you for your speedy comments!
This is intended to not be specific to any compiler and the responsibility then is passed to the "user". But I understand that hiding compiler specifics is a design choice and therefore shouldn't be changed lightly. However, I can still see the benefit of having a way to specify any compiler flags via the manifest, rather than requiring
I think this sounds good and would solve issues with that particular flag. I shall raise another issue/PR to update the free-form but I am still interested in this mechanism of passing any compiler flag through the manifest. Happy to be proved wrong though. |
I agree, would probably make the most sense to have them under the [build]
link = ["blas","lapack"]
flags = ["-some-other-flag"]
c-flags = ["-c-only-flag"]
cxx-flags = ["-cpp-only-flag"] |
I like this idea, it would make it easier to pass flags for |
Would it be possible to define different sets of flags for each supported compiler? I guess there are projects, that are only working with one specific compiler, or maybe don't work with one specific compiler. It would be nice to define this in the toml. This would be an opportunity for defining compiler specific flags. E.g. [build]
default_flags = ["-O3", "-g"]
[build.compilers.ifort]
flags = ["-O2", "-fast"]
min_version = "19.1.0"
[build.compilers.gfortran]
supported = false |
One would need to cross this with the OS. Intel uses slightly different nomenclature for the same flags depending on the OS. |
Exactly, that's why flags for shared Fortran features are standardized via the Lines 160 to 174 in 1cfcaf8
so I think this structure seems preferable. For example for unlimited line length, I think it should be the default setting for the "Free" source form on all compilers ( Then, one may still want compiler-based flags, I think it could make sense to have just the flag name so the initial symbol is resolved internally (e.g. because Intel wants [build]
link = ["blas","lapack"]
flags = ["some-other-flag"] # note: no dash
flags.intel = ["intel-only-flag"]
c-flags = ["c-only-flag"]
c-flags.gnu = ["gnu-only-flag"]
cxx-flags = ["cpp-only-flag"]
note OpenMP is a metapackage: I believe openacc could be implemented the same way, especially as it may carry over additional linking flags |
it would be |
This seems to be a subset of allowing for profile definitions in the fpm.toml manifest file. Extensive work was being done on that at one time, and their is a related pull request but no action since that I see of. Allowing compiler options in the fpm.toml file seems like it should take into account how the package is built when it is a dependency, and which compiler and which OS as discussed; |
Description
It would be very useful to pass compiler flags from the fpm.toml file directly to the compilation commands. It seems that currently it is possible to pass very specific flags such as -ffree-form but something more generic would be more flexible. For example
The new
user-defined-flags
would then be passed straight through to the compiler and the compiler allowed to catch any errors with the flags.Possible Solution
get_feature_flags could handle a new feature
user_defined_flags
This would of course require further changes to add
user-defined-flags
. Could this be added everywheresource-form
also is currently?Additional Information
No response
The text was updated successfully, but these errors were encountered: