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

[Minios-devel] [UNIKRAFT PATCH v2 2/2] build: Provide LTO as build option



Introduces a build option that enables link time optmizations (LTO).
When enabled, GCC is doing code optimization also while linking.
Although the overall building time is increased, more efficient
Unikraft images can be created.

Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
---
 Config.uk   | 8 ++++++++
 Makefile.uk | 6 ++++++
 2 files changed, 14 insertions(+)

diff --git a/Config.uk b/Config.uk
index eea961e..21cec9b 100644
--- a/Config.uk
+++ b/Config.uk
@@ -78,6 +78,14 @@ config OPTIMIZE_DEADELIM
 comment "Hint: Enable dropping of unused code to further reduce target image 
size"
        depends on OPTIMIZE_SIZE && !OPTIMIZE_DEADELIM
 
+config OPTIMIZE_LTO
+       bool "Link time optimizations (LTO)"
+       default n
+       help
+               Enables GCC to do code optimizations during linking. This option
+               will increase overall building time but creates more efficient
+               Unikraft binaries.
+
 config DEBUG_SYMBOLS
        bool "Debugging information"
        default n
diff --git a/Makefile.uk b/Makefile.uk
index c540ada..1964563 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -34,6 +34,12 @@ CFLAGS-$(OPTIMIZE_DEADELIM)        += -fdata-sections 
-ffunction-sections
 CXXFLAGS-$(OPTIMIZE_DEADELIM)      += -fdata-sections -ffunction-sections
 LDFLAGS-$(OPTIMIZE_DEADELIM)       += -Wl,--gc-sections
 
+# LTO requires the compiler flags to be handed over also for linking
+CFLAGS-$(OPTIMIZE_LTO)             += -flto
+CXXFLAGS-$(OPTIMIZE_LTO)           += -flto
+LIBLDFLAGS-$(OPTIMIZE_LTO)         += $(CFLAGS) $(CFLAGS-y)
+LDFLAGS-$(OPTIMIZE_LTO)            += $(CFLAGS) $(CFLAGS-y)
+
 ifneq ($(DEBUG_SYMBOLS),y)
 CFLAGS                             += -g0
 CXXFLAGS                           += -g0
-- 
2.7.4


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.