build: add 'sections' option to show unused functions

This commit is contained in:
Johan Malm 2025-09-26 17:47:47 +01:00 committed by Johan Malm
parent c5cd1f691d
commit 27f3097f8f
2 changed files with 11 additions and 0 deletions

View file

@ -134,6 +134,15 @@ if get_option('static_analyzer').enabled()
add_project_arguments(['-fanalyzer'], language: 'c') add_project_arguments(['-fanalyzer'], language: 'c')
endif endif
link_args = []
if get_option('sections').enabled()
add_project_arguments(['-ffunction-sections'], language: 'c')
link_args += [
'-Wl,--gc-sections',
'-Wl,--print-gc-sections',
]
endif
msgfmt = find_program('msgfmt', required: get_option('nls')) msgfmt = find_program('msgfmt', required: get_option('nls'))
if msgfmt.found() if msgfmt.found()
source_root = meson.current_source_dir() source_root = meson.current_source_dir()
@ -193,6 +202,7 @@ executable(
include_directories: [labwc_inc], include_directories: [labwc_inc],
dependencies: labwc_deps, dependencies: labwc_deps,
install: true, install: true,
link_args: link_args,
) )
install_data('data/labwc.desktop', install_dir: get_option('datadir') / 'wayland-sessions') install_data('data/labwc.desktop', install_dir: get_option('datadir') / 'wayland-sessions')

View file

@ -5,3 +5,4 @@ option('icon', type: 'feature', value: 'enabled', description: 'Enable window ic
option('nls', type: 'feature', value: 'auto', description: 'Enable native language support') option('nls', type: 'feature', value: 'auto', description: 'Enable native language support')
option('static_analyzer', type: 'feature', value: 'disabled', description: 'Run gcc static analyzer') option('static_analyzer', type: 'feature', value: 'disabled', description: 'Run gcc static analyzer')
option('test', type: 'feature', value: 'disabled', description: 'Run tests') option('test', type: 'feature', value: 'disabled', description: 'Run tests')
option('sections', type: 'feature', value: 'disabled', description: 'Show unused functions')