[PATCH 1/2] docs: compiling: Add a note about use of CFLAGS for optimization

Peter Krempa posted 2 patches 1 year ago
[PATCH 1/2] docs: compiling: Add a note about use of CFLAGS for optimization
Posted by Peter Krempa 1 year ago
Meson doesn't interpret what's set in CFLAGS, but rather simply appeds
it to the command line. Thus any logic which is based on the
optimization level will not work.

Note the caveat in the docs and instruct users to use
``--optimization=N`` instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 docs/compiling.rst | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/docs/compiling.rst b/docs/compiling.rst
index 800264d2f9..0a47a50569 100644
--- a/docs/compiling.rst
+++ b/docs/compiling.rst
@@ -112,6 +112,11 @@ Please ensure that you have the appropriate minimal ``meson`` version installed
 in your build environment. The minimal version for a specific package can be
 checked in the top level ``meson.build`` file in the ``meson_version`` field.

+**DO NOT** use the ``CFLAGS`` environment variable to set optimizations
+(e.g. ``CFLAGS=-O0``), but rather use Meson's ``--optimization=0`` option.
+Certain internal build options are based on the configured optimization value
+and Meson does not interpret ``CFLAGS``.
+

 Compiling the sources
 ---------------------
-- 
2.41.0
Re: [PATCH 1/2] docs: compiling: Add a note about use of CFLAGS for optimization
Posted by Daniel P. Berrangé 1 year ago
On Mon, Sep 04, 2023 at 12:13:36PM +0200, Peter Krempa wrote:
> Meson doesn't interpret what's set in CFLAGS, but rather simply appeds
> it to the command line. Thus any logic which is based on the
> optimization level will not work.
> 
> Note the caveat in the docs and instruct users to use
> ``--optimization=N`` instead.
> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>  docs/compiling.rst | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/docs/compiling.rst b/docs/compiling.rst
> index 800264d2f9..0a47a50569 100644
> --- a/docs/compiling.rst
> +++ b/docs/compiling.rst
> @@ -112,6 +112,11 @@ Please ensure that you have the appropriate minimal ``meson`` version installed
>  in your build environment. The minimal version for a specific package can be
>  checked in the top level ``meson.build`` file in the ``meson_version`` field.
> 
> +**DO NOT** use the ``CFLAGS`` environment variable to set optimizations
> +(e.g. ``CFLAGS=-O0``), but rather use Meson's ``--optimization=0`` option.
> +Certain internal build options are based on the configured optimization value
> +and Meson does not interpret ``CFLAGS``.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|