Bug 107313

Summary: Meson instructions on web site are non-optimal
Product: Mesa Reporter: Jussi Pakkanen <jpakkane>
Component: OtherAssignee: Dylan Baker <baker.dylan.c>
Status: RESOLVED FIXED QA Contact: mesa-dev
Severity: normal    
Priority: medium CC: baker.dylan.c
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Jussi Pakkanen 2018-07-20 18:45:18 UTC
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.
Comment 1 Dylan Baker 2018-07-20 19:08:48 UTC
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.

Run this:
CXXFLAGS=-Wall meson build
ninja -C build
unset CXXFLAGS
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.
Comment 2 Jussi Pakkanen 2018-07-20 19:14:34 UTC
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.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.