The Meson page on the web site says, among other things, the following:
> if ninja decides to re-initialize meson, for example, if a meson.build file has been changed. Changing these variables will not cause all targets to be rebuilt, so running ninja clean is recommended
This is not good advice. We have spent a lot of effort in making sure that rebuilds are reliable. If you change something and only a portion of your sources are rebuilt, it means that the rest _did not need rebuilding_. The reason for this is increased productivity so you don't need to rebuild files unnecessarily.
Please remove the above segment from the web site or reword it to match reality. If you have cases where our rebuild detection logic leaves something unbuilt when it should have rebuilt it, please file bugs in Meson. We want to get all those fixed.
The whole quote is:
Meson supports the standard CC and CXX environment variables for changing the default compiler, and CFLAGS, CXXFLAGS, and LDFLAGS for setting options to the compiler and linker. The default compilers depends on your operating system. Meson supports most of the popular compilers, a complete list is available here. These arguments are consumed and stored by meson when it is initialized or re-initialized. Therefore passing them to meson configure will not do anything, and passing them to ninja will only do something if ninja decides to re-initialize meson, for example, if a meson.build file has been changed. Changing these variables will not cause all targets to be rebuilt, so running ninja clean is recommended when changing CFLAGS or CXXFLAGS. Meson will never change compiler in a configured build directory.
Unless something has changed meson does not honor changes to the CFLAGS or CXXFLAGS variables because it treats them as default arguments.
CXXFLAGS=-Wall meson build
ninja -C build
ninja -C build
> ninja: Entering directory `build'
> ninja: no work to do.
My understanding was that this behavior was intentional, if it's not I'll file a bug.
To change compiler flags that originally come from CFLAGS et al on an existing build dir, you should use `meson configure -Dc_args=...'.
We don't persist environment variables. That only leads to madness.