diff mbox series

[07/30] meson: support meson 0.64 -Doptimization=plain

Message ID 20221209112409.184703-8-pbonzini@redhat.com
State New
Headers show
Series Meson changes for QEMU 8.0 | expand

Commit Message

Paolo Bonzini Dec. 9, 2022, 11:23 a.m. UTC
In Meson 0.64, the optimization built-in option now accepts the "plain" value,
which will not set any optimization flags.  While QEMU does not check the
contents of the option and therefore does not suffer any ill effect
from the new value, it uses get_option to print the optimization flags
in the summary.  Clean the code up to remove duplication, and check for
-Doptimization=plain at the same time.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 meson.build | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

Comments

Marc-André Lureau Dec. 12, 2022, 8:21 a.m. UTC | #1
Hi

On Fri, Dec 9, 2022 at 3:31 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> In Meson 0.64, the optimization built-in option now accepts the "plain" value,
> which will not set any optimization flags.  While QEMU does not check the
> contents of the option and therefore does not suffer any ill effect
> from the new value, it uses get_option to print the optimization flags
> in the summary.  Clean the code up to remove duplication, and check for
> -Doptimization=plain at the same time.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  meson.build | 16 +++++++---------
>  1 file changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/meson.build b/meson.build
> index d61c7a82f112..dbd0b5563446 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -3752,18 +3752,16 @@ endif
>  if targetos == 'darwin'
>    summary_info += {'Objective-C compiler': ' '.join(meson.get_compiler('objc').cmd_array())}
>  endif
> -summary_info += {'CFLAGS':            ' '.join(get_option('c_args')
> -                                               + ['-O' + get_option('optimization')]
> -                                               + (get_option('debug') ? ['-g'] : []))}
> +option_cflags = (get_option('debug') ? ['-g'] : [])
> +if get_option('optimization') != 'plain'
> +  option_cflags += ['-O' + get_option('optimization')]
> +endif
> +summary_info += {'CFLAGS':            ' '.join(get_option('c_args') + option_cflags)}
>  if link_language == 'cpp'
> -  summary_info += {'CXXFLAGS':        ' '.join(get_option('cpp_args')
> -                                               + ['-O' + get_option('optimization')]
> -                                               + (get_option('debug') ? ['-g'] : []))}
> +  summary_info += {'CXXFLAGS':        ' '.join(get_option('cpp_args') + option_cflags)}
>  endif
>  if targetos == 'darwin'
> -  summary_info += {'OBJCFLAGS':       ' '.join(get_option('objc_args')
> -                                               + ['-O' + get_option('optimization')]
> -                                               + (get_option('debug') ? ['-g'] : []))}
> +  summary_info += {'OBJCFLAGS':       ' '.join(get_option('objc_args') + option_cflags)}
>  endif
>  link_args = get_option(link_language + '_link_args')
>  if link_args.length() > 0
> --
> 2.38.1
>
>
Daniel P. Berrangé Dec. 16, 2022, 2:53 p.m. UTC | #2
On Fri, Dec 09, 2022 at 12:23:46PM +0100, Paolo Bonzini wrote:
> In Meson 0.64, the optimization built-in option now accepts the "plain" value,
> which will not set any optimization flags.  While QEMU does not check the
> contents of the option and therefore does not suffer any ill effect
> from the new value, it uses get_option to print the optimization flags
> in the summary.  Clean the code up to remove duplication, and check for
> -Doptimization=plain at the same time.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  meson.build | 16 +++++++---------
>  1 file changed, 7 insertions(+), 9 deletions(-)
> 
> diff --git a/meson.build b/meson.build
> index d61c7a82f112..dbd0b5563446 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -3752,18 +3752,16 @@ endif
>  if targetos == 'darwin'
>    summary_info += {'Objective-C compiler': ' '.join(meson.get_compiler('objc').cmd_array())}
>  endif
> -summary_info += {'CFLAGS':            ' '.join(get_option('c_args')
> -                                               + ['-O' + get_option('optimization')]
> -                                               + (get_option('debug') ? ['-g'] : []))}
> +option_cflags = (get_option('debug') ? ['-g'] : [])
> +if get_option('optimization') != 'plain'
> +  option_cflags += ['-O' + get_option('optimization')]
> +endif

Instead of trying to secondguess what these flags will be turned into
by Meson, why not just log them directly

  summary_info += {'optimization': get_option('optimization')}
  summary_info += {'debug': get_option('debug')}

> +summary_info += {'CFLAGS':            ' '.join(get_option('c_args') + option_cflags)}
>  if link_language == 'cpp'
> -  summary_info += {'CXXFLAGS':        ' '.join(get_option('cpp_args')
> -                                               + ['-O' + get_option('optimization')]
> -                                               + (get_option('debug') ? ['-g'] : []))}
> +  summary_info += {'CXXFLAGS':        ' '.join(get_option('cpp_args') + option_cflags)}
>  endif
>  if targetos == 'darwin'
> -  summary_info += {'OBJCFLAGS':       ' '.join(get_option('objc_args')
> -                                               + ['-O' + get_option('optimization')]
> -                                               + (get_option('debug') ? ['-g'] : []))}
> +  summary_info += {'OBJCFLAGS':       ' '.join(get_option('objc_args') + option_cflags)}
>  endif
>  link_args = get_option(link_language + '_link_args')
>  if link_args.length() > 0
> -- 
> 2.38.1
> 
> 

With regards,
Daniel
diff mbox series

Patch

diff --git a/meson.build b/meson.build
index d61c7a82f112..dbd0b5563446 100644
--- a/meson.build
+++ b/meson.build
@@ -3752,18 +3752,16 @@  endif
 if targetos == 'darwin'
   summary_info += {'Objective-C compiler': ' '.join(meson.get_compiler('objc').cmd_array())}
 endif
-summary_info += {'CFLAGS':            ' '.join(get_option('c_args')
-                                               + ['-O' + get_option('optimization')]
-                                               + (get_option('debug') ? ['-g'] : []))}
+option_cflags = (get_option('debug') ? ['-g'] : [])
+if get_option('optimization') != 'plain'
+  option_cflags += ['-O' + get_option('optimization')]
+endif
+summary_info += {'CFLAGS':            ' '.join(get_option('c_args') + option_cflags)}
 if link_language == 'cpp'
-  summary_info += {'CXXFLAGS':        ' '.join(get_option('cpp_args')
-                                               + ['-O' + get_option('optimization')]
-                                               + (get_option('debug') ? ['-g'] : []))}
+  summary_info += {'CXXFLAGS':        ' '.join(get_option('cpp_args') + option_cflags)}
 endif
 if targetos == 'darwin'
-  summary_info += {'OBJCFLAGS':       ' '.join(get_option('objc_args')
-                                               + ['-O' + get_option('optimization')]
-                                               + (get_option('debug') ? ['-g'] : []))}
+  summary_info += {'OBJCFLAGS':       ' '.join(get_option('objc_args') + option_cflags)}
 endif
 link_args = get_option(link_language + '_link_args')
 if link_args.length() > 0