# Gprbuild & command-line args

**URL:** <https://forum.ada-lang.io/t/gprbuild-command-line-args/4977>\
**Category:** General\
**Created:** [November 21, 2026, 1:37am UTC](https://forum.ada-lang.io/t/gprbuild-command-line-args/4977 "2026-11-21T01:37:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sidisyom](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/s/5fc32e/32.png) [@sidisyom](https://forum.ada-lang.io/u/sidisyom)\
**Post date:** [November 21, 2026, 1:37am UTC](https://forum.ada-lang.io/t/gprbuild-command-line-args/4977/1 "2026-11-21T01:37:12Z")

</div>

Not sure how feasible or practical that would be but I am wondering if there would be any value for `gprbuild` to save the state of the command-line arguments used in its last run as that could come in handy in some scenarios:

My exact use-case isn’t massively relevant but to give a bit of context, I was trying to build a bareboard runtime with some custom logic I added in some file so I ran the following command:

```ada
gprbuild -j0 -P ravenscar_build.gpr -XDUILD=Debug

```

which printed out some info lines with the file that I’d changed so I could tell that my change had been picked-up. However, when I later tried debugging my code the runtime symbols were nowhere to be found! The problem as you might have spotted, was that the `-X` key name had been misspelled (`DUILD` instead of `BUILD`) so naturally no debug symbols were inserted in the elf file. So, I fixed that and ran again but still nothing! The command returned immediately without any diagnostic messages which I thought was a bit odd but nevertheless got the impression it _had_ run but because no files had been changed it just didn’t print anything.

The solution was to change my file (any file would do the trick really) save it then revert the change and save it again so that the last access timestamp would be bumped. And `gprbuild` then built the runtime in debug mode.

So, I’m wondering (just thinking out loud really) would it make sense to save the arguments of the last run (maybe in some hidden file in the root project dir) and use that (along with the files modification state) when deciding whether to run the given command or not?

Or even maybe just print some diagnostic message when it hasn’t actually run?

Any thoughts?

Thanks!

---

<div class="post-metadata">

**Author:** ![godunko](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/godunko/32/22_2.png) [@godunko](https://forum.ada-lang.io/u/godunko)\
**Post date:** [November 21, 2026, 4:11am UTC](https://forum.ada-lang.io/t/gprbuild-command-line-args/4977/2 "2026-11-21T04:11:34Z")

</div>

1. Wait for `gprbuild2`, it can detect changes of switches.
2. Use `-f` to force recompilation.

---

<div class="post-metadata">

**Author:** ![dmitry-kazakov](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/dmitry-kazakov/32/522_2.png) [@dmitry-kazakov](https://forum.ada-lang.io/u/dmitry-kazakov)\
**Post date:** [November 21, 2026, 8:44am UTC](https://forum.ada-lang.io/t/gprbuild-command-line-args/4977/3 "2026-11-21T08:44:47Z")

</div>

A function should be function of its arguments only. That is the golden rule of SW design.

**P**. **S**. _gprclean_ is a handy utility for removing project’s artefacts.

**P**. **P**. **S**. GNAT Studio remembers command line arguments set for build and run.

---

<div class="post-metadata">

**Author:** ![bjorn-lundin](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/bjorn-lundin/32/106_2.png) [@bjorn-lundin](https://forum.ada-lang.io/u/bjorn-lundin)\
**Post date:** [November 21, 2026, 8:55am UTC](https://forum.ada-lang.io/t/gprbuild-command-line-args/4977/4 "2026-11-21T08:55:33Z")

</div>

```ada
package Builder is
     for Default_Switches ("Ada") use ("-s", -- recompile if switches change

```

I’m not sure if it will catch your case, since it is the value of a switch that changed, and not the switch itself. But I would try it.
