build: run garbage collection while linking plugins
Ask linker to remove symbols which are not referenced or exported.
Type: improvement
@@ -46,6 +46,9 @@ macro(add_vpp_plugin name)
add_library(${plugin_name} SHARED ${PLUGIN_SOURCES} ${api_includes})
set_target_properties(${plugin_name} PROPERTIES NO_SONAME 1)
target_compile_options(${plugin_name} PRIVATE "-fvisibility=hidden")
+ target_compile_options (${plugin_name} PRIVATE "-ffunction-sections")
+ target_compile_options (${plugin_name} PRIVATE "-fdata-sections")
+ target_link_libraries (${plugin_name} "-Wl,--gc-sections")
set(deps "")
if(PLUGIN_API_FILES)
list(APPEND deps ${plugin_name}_api_headers)
