how to set debug and optimization flag with meson

1,145 views
Skip to first unread message

Massimiliano Cialdi

unread,
Nov 12, 2020, 2:20:38 AM11/12/20
to The Meson Build System

I use meson 0.53.2 on ubuntu 20.04.
I would like to have a maximally optimized executable (`-Ofast`) but contain all debug symbols (`-g3`)

 - If I use `--buildtype=release` it optimizes `-O2` and the executable contains no debug symbol.
 - If I use `--buildtype=debug` it does not optimize at all and uses `-g`.
 - If I use `--buildtype=debugoptimized` it optimizes `-O2` and uses `-g`.

I tried to use `--debug` which seems not to work, because the executable does not contain any debug symbol. Instead if I use `-Ddebug=true` the debug symbols are there but with the flag `-g`.

So how do I get `gcc` to compile with `-Ofast -g3` flags in the least dirty way possible?

best regards
Max

Jussi Pakkanen

unread,
Nov 12, 2020, 4:15:37 PM11/12/20
to Massimiliano Cialdi, The Meson Build System
Set buildtype to "plain". Meson will not add any optimization or debug
flags in this case. You can then inject your own in the `c_args`,
`cpp_args` and other compiler flag options manually.
Reply all
Reply to author
Forward
0 new messages