[PATCH] configure: Add --enable-lto

Richard Henderson posted 1 patch 1 year, 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20221204000340.282718-1-richard.henderson@linaro.org
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Thomas Huth <thuth@redhat.com>
configure | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
[PATCH] configure: Add --enable-lto
Posted by Richard Henderson 1 year, 4 months ago
Separately control b_lto without --enable-cfi.
Also add --disable-lto for completeness.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 configure | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 26c7bc5154..d9c9babfc3 100755
--- a/configure
+++ b/configure
@@ -301,6 +301,7 @@ fdt="auto"
 # 2. Automatically enable/disable other options
 tcg="auto"
 cfi="false"
+lto="true"
 
 # parse CC options second
 for opt do
@@ -837,12 +838,14 @@ for opt do
   ;;
   --disable-safe-stack) safe_stack="no"
   ;;
-  --enable-cfi)
-      cfi="true";
-      meson_option_add -Db_lto=true
+  --enable-cfi) cfi="true" lto="true"
   ;;
   --disable-cfi) cfi="false"
   ;;
+  --enable-lto) lto="true"
+  ;;
+  --disable-lto) lto="false"
+  ;;
   --disable-fdt) fdt="disabled"
   ;;
   --enable-fdt) fdt="enabled"
@@ -2591,6 +2594,7 @@ if test "$skip_meson" = no; then
   test "$default_feature" = no && meson_option_add -Dauto_features=disabled
   test "$pie" = no && meson_option_add -Db_pie=false
   test "$werror" = yes && meson_option_add -Dwerror=true
+  test "$lto" = true && meson_option_add "-Db_lto=true"
 
   # QEMU options
   test "$cfi" != false && meson_option_add "-Dcfi=$cfi"
-- 
2.34.1
Re: [PATCH] configure: Add --enable-lto
Posted by Peter Maydell 1 year, 4 months ago
On Sun, 4 Dec 2022 at 00:04, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Separately control b_lto without --enable-cfi.
> Also add --disable-lto for completeness.

Before this patch, CFI defaults to false and therefore LTO
also defaults to false. After this patch, LTO defaults to
true even if CFI is false. Intentional change ?

Do we have figures for whether LTO produces an interesting
performance improvement ?

We should probably complain if the user tries '--enable-cfi --disable-lto'
rather than silently doing something that presumably doesn't work.

thanks
-- PMM
Re: [PATCH] configure: Add --enable-lto
Posted by Richard Henderson 1 year, 4 months ago
On 12/4/22 11:40, Peter Maydell wrote:
> On Sun, 4 Dec 2022 at 00:04, Richard Henderson
> <richard.henderson@linaro.org> wrote:
>>
>> Separately control b_lto without --enable-cfi.
>> Also add --disable-lto for completeness.
> 
> Before this patch, CFI defaults to false and therefore LTO
> also defaults to false. After this patch, LTO defaults to
> true even if CFI is false. Intentional change ?

Nope.  Oops.

> Do we have figures for whether LTO produces an interesting
> performance improvement ?

No idea.  I wrote this after finding a bug report in which someone tried to add -flto via 
--extra-cflags.

> We should probably complain if the user tries '--enable-cfi --disable-lto'
> rather than silently doing something that presumably doesn't work.

We do, in meson.build:

if get_option('cfi')
   cfi_flags=[]
   # Check for dependency on LTO
   if not get_option('b_lto')
     error('Selected Control-Flow Integrity but LTO is disabled')


r~