diff mbox series

configure: Add --enable-lto

Message ID 20221204000340.282718-1-richard.henderson@linaro.org
State New
Headers show
Series configure: Add --enable-lto | expand

Commit Message

Richard Henderson Dec. 4, 2022, 12:03 a.m. UTC
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(-)

Comments

Peter Maydell Dec. 4, 2022, 5:40 p.m. UTC | #1
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
Richard Henderson Dec. 5, 2022, 1:10 a.m. UTC | #2
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~
diff mbox series

Patch

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"