[RFC PATCH 02/16] kvm tools: only enable LTO if supported by GCC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit 99423f12db2a ("kvm tools: enable LTO") unconditionally enabled
link-time-optimisations when building kvmtool. Unfortunately, passing
-flto to a GCC without support for the option, results in a fatal build
error:

  cc1: error: LTO support has not been enabled in this configuration

This patch adds a check to the kvm tools Makefile so that LTO is only
enabled if the host compiler supports it.

Signed-off-by: Will Deacon <will.deacon@xxxxxxx>
---
 tools/kvm/Makefile |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/tools/kvm/Makefile b/tools/kvm/Makefile
index f12e587..23a7c40 100644
--- a/tools/kvm/Makefile
+++ b/tools/kvm/Makefile
@@ -226,6 +226,11 @@ ifeq ($(call try-cc,$(SOURCE_AIO),$(FLAGS_AIO) -static),y)
 	LIBS_STATOPT	+= -laio
 endif
 
+FLAGS_LTO := -flto
+ifeq ($(call try-cc,$(SOURCE_HELLO),$(FLAGS_LTO)),y)
+	CFLAGS		+= $(FLAGS_LTO)
+endif
+
 ifneq ($(call try-build,$(SOURCE_STATIC),-static,),y)
 $(error No static libc found. Please install glibc-static package.)
 endif
@@ -244,7 +249,7 @@ DEFINES	+= -DKVMTOOLS_VERSION='"$(KVMTOOLS_VERSION)"'
 DEFINES	+= -DBUILD_ARCH='"$(ARCH)"'
 
 KVM_INCLUDE := include
-CFLAGS	+= $(CPPFLAGS) $(DEFINES) -I$(KVM_INCLUDE) -I$(ARCH_INCLUDE) -I$(KINCL_PATH)/include/uapi -I$(KINCL_PATH)/include -I$(KINCL_PATH)/arch/$(ARCH)/include/uapi -I$(KINCL_PATH)/arch/$(ARCH)/include/ -O2 -fno-strict-aliasing -g -flto
+CFLAGS	+= $(CPPFLAGS) $(DEFINES) -I$(KVM_INCLUDE) -I$(ARCH_INCLUDE) -I$(KINCL_PATH)/include/uapi -I$(KINCL_PATH)/include -I$(KINCL_PATH)/arch/$(ARCH)/include/uapi -I$(KINCL_PATH)/arch/$(ARCH)/include/ -O2 -fno-strict-aliasing -g
 
 WARNINGS += -Wall
 WARNINGS += -Wcast-align
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux