summaryrefslogtreecommitdiffstats
path: root/src/cmake/library.cmake
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2020-10-22 14:23:47 +0200
committerFlorin Coras <florin.coras@gmail.com>2020-11-05 20:51:03 +0000
commitaf7892c08b2d4984f4c93bb8c7cc07aec36b5055 (patch)
tree2d09c5297cc8b1e38f3ec7a755054e88957ec9e0 /src/cmake/library.cmake
parent066cd812374460e5ca8be9a88f494fe3f5bf911e (diff)
build: link time optimization for release builds
Type: improvement Change-Id: I0e24f1d2ad5c7a11a8bd40125428f86aca867bec Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/cmake/library.cmake')
-rw-r--r--src/cmake/library.cmake9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/cmake/library.cmake b/src/cmake/library.cmake
index 06248a57aa3..a5b6c76d2d1 100644
--- a/src/cmake/library.cmake
+++ b/src/cmake/library.cmake
@@ -13,7 +13,7 @@
macro(add_vpp_library lib)
cmake_parse_arguments(ARG
- ""
+ "LTO"
"COMPONENT"
"SOURCES;MULTIARCH_SOURCES;API_FILES;LINK_LIBRARIES;INSTALL_HEADERS;DEPENDS"
${ARGN}
@@ -38,6 +38,13 @@ macro(add_vpp_library lib)
COMPONENT ${ARG_COMPONENT}
)
+ if (ARG_LTO AND VPP_USE_LTO)
+ set_property(TARGET ${lib} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
+ target_compile_options (${lib} PRIVATE "-ffunction-sections")
+ target_compile_options (${lib} PRIVATE "-fdata-sections")
+ target_link_libraries (${lib} "-Wl,--gc-sections")
+ endif()
+
if(ARG_MULTIARCH_SOURCES)
vpp_library_set_multiarch_sources(${lib} "${ARG_DEPENDS}" ${ARG_MULTIARCH_SOURCES})
endif()