# Problem with fpm build --flag

**URL:** <https://fortran-lang.discourse.group/t/problem-with-fpm-build-flag/6010>\
**Category:** fpm\
**Created:** [June 21, 2023, 8:11am UTC](https://fortran-lang.discourse.group/t/problem-with-fpm-build-flag/6010 "2023-06-21T08:11:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)\
**Post date:** [June 21, 2023, 8:11am UTC](https://fortran-lang.discourse.group/t/problem-with-fpm-build-flag/6010/1 "2023-06-21T08:11:52Z")

</div>

I want to detect unused variables when building a project with fpm. For example:

```auto
program main
  implicit none
  integer :: i

end program main

```

With GFortran, I do:

```bash
$ 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:

```bash
$ 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](https://fpm.fortran-lang.org/index.html).

---

<div class="post-metadata">

**Author:** ![ludnic](https://avatars.discourse-cdn.com/v4/letter/l/958977/32.png) [@ludnic](https://fortran-lang.discourse.group/u/ludnic)\
**Post date:** [June 21, 2023, 8:23am UTC](https://fortran-lang.discourse.group/t/problem-with-fpm-build-flag/6010/2 "2023-06-21T08:23:56Z")

</div>

Have you tried the -verbose output flag? It might be there but hidden.

---

<div class="post-metadata">

**Author:** ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)\
**Post date:** [June 21, 2023, 8:39am UTC](https://fortran-lang.discourse.group/t/problem-with-fpm-build-flag/6010/3 "2023-06-21T08:39:01Z")

</div>

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:

```bash
$ fpm build --flag "-Wunused"

```

does not do what the naive user expects.

---

<div class="post-metadata">

**Author:** ![egio](https://avatars.discourse-cdn.com/v4/letter/e/dbc845/32.png) [@egio](https://fortran-lang.discourse.group/u/egio)\
**Post date:** [June 21, 2023, 2:04pm UTC](https://fortran-lang.discourse.group/t/problem-with-fpm-build-flag/6010/4 "2023-06-21T14:04:18Z")

</div>

Is there the possibility, after compilation, to see the produced warning messages? Without having to dig inside the build directory?  
A command like:

```auto
fpm log display beatiful_module.f90

```

---

<div class="post-metadata">

**Author:** ![lkedward](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/lkedward/32/72_2.png) [@lkedward](https://fortran-lang.discourse.group/u/lkedward)\
**Post date:** [June 21, 2023, 2:21pm UTC](https://fortran-lang.discourse.group/t/problem-with-fpm-build-flag/6010/5 "2023-06-21T14:21:30Z")

</div>

Yes, this has been discussed and is planned, see:

> <https://github.com/fortran-lang/fpm/pull/622#issuecomment-982790258>
>
> \> 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.

> <https://github.com/fortran-lang/fpm/issues/619#issuecomment-1039446964>
>
> 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.
