I want to detect unused variables when building a project with fpm. For example:
program main
implicit none
integer :: i
end program main
With GFortran, I do:
$ gfortran main.f90 -Wall
main.f90:3:14:
3 | integer :: i
| 1
Warning: Unused variable āiā declared at (1) [-Wunused-variable]
but fpm says nothing with the same flag:
$ fpm build --flag "-Wall"
fpm: Entering directory '/tmp/essai'
libessai.a done.
main.f90 done.
essai done.
[100%] Project compiled successfully.
fpm: Leaving directory '/tmp/essai'
What am I doing wrong?
By the way, the --flag
option seems not documented in the fpm doc .
ludnic
June 21, 2023, 8:23am
2
Have you tried the -verbose output flag? It might be there but hidden.
Thanks @ludnic
yes, with fpm build --verbose
I can see it. That interesting option should also be documented (it is cited only in the new fpm publish
section of the doc).
But it is really troubling that fpm overrides (or rather hides) my flags in its standard output:
$ fpm build --flag "-Wunused"
does not do what the naive user expects.
egio
June 21, 2023, 2:04pm
4
Is there the possibility, after compilation, to see the produced warning messages? Without having to dig inside the build directory?
A command like:
fpm log display beatiful_module.f90
Yes, this has been discussed and is planned, see:
fortran-lang:main
ā LKedward:backend-output
> somewhat ironically, I immediately miss being able to get all the messages on ā¦ a built project. Is that something you were going to build back in?
I agree we should build this in but I'm not sure what the user interface would be right now (`fpm log`, `fpm build --log`?) and so I suggest leaving this for a future PR.
opened 05:22PM - 21 Nov 21 UTC
easy
user experience
Currently fpm's output is very verbose and it's hard to see what is going on. A ā¦ bunch of commands (typically compiler invocations) are printed to stdout. Instead, let's do something like Rust's Cargo does:
```
$ cargo build
Compiling libc v0.2.103
Compiling autocfg v1.0.1
Compiling proc-macro2 v1.0.26
Compiling unicode-xid v0.2.2
Compiling syn v1.0.72
Compiling pkg-config v0.3.19
Compiling cfg-if v1.0.0
Compiling serde_derive v1.0.130
...
Compiling path_abs v0.5.1
Compiling encoding v0.2.33
Building [============> ] 79/150: encoding, proc-macro-hack...
```
Or the Julia's Pkg:
```
julia> import Pkg
julia> Pkg.add("SymEngine")
Resolving package versions...
Installed RecipesBase āāā v1.1.2
Installed MPC_jll āāāāāāā v1.2.1+0
Installed SymEngine_jll ā v0.6.0+1
Installed SymEngine āāāāā v0.8.6
Downloaded artifact: SymEngine
Downloaded artifact: MPC
Updating `~/.julia/environments/v1.6/Project.toml`
[123dc426] + SymEngine v0.8.6
Updating `~/.julia/environments/v1.6/Manifest.toml`
[3cdcf5f2] + RecipesBase v1.1.2
[123dc426] + SymEngine v0.8.6
[2ce0c516] + MPC_jll v1.2.1+0
[3428059b] + SymEngine_jll v0.6.0+1
[781609d7] + GMP_jll
[3a97d323] + MPFR_jll
Precompiling project...
6 dependencies successfully precompiled in 4 seconds (48 already precompiled)
```
Note that Julia's Pkg prints all kinds of nice progress markers that all disappear when it is done, so the above output only captures the final result. I recommend you try the above commands yourself to see what I mean.
The final output of Cargo seems cleaner and it seems it contains all the information you need to know, which is which package got built and which version. We can also print which Fortran compiler was used (I am not sure).
P.S I thought I already opened up an issue for exactly this, but I can't find it, so I opened a new one.
3 Likes