From 27f3097f8f882abc710e94bcb9a177319140d0b9 Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Fri, 26 Sep 2025 17:47:47 +0100 Subject: [PATCH] build: add 'sections' option to show unused functions --- meson.build | 10 ++++++++++ meson_options.txt | 1 + 2 files changed, 11 insertions(+) diff --git a/meson.build b/meson.build index 5f4cfe9b..0ac5cea1 100644 --- a/meson.build +++ b/meson.build @@ -134,6 +134,15 @@ if get_option('static_analyzer').enabled() add_project_arguments(['-fanalyzer'], language: 'c') 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')) if msgfmt.found() source_root = meson.current_source_dir() @@ -193,6 +202,7 @@ executable( include_directories: [labwc_inc], dependencies: labwc_deps, install: true, + link_args: link_args, ) install_data('data/labwc.desktop', install_dir: get_option('datadir') / 'wayland-sessions') diff --git a/meson_options.txt b/meson_options.txt index ec3fe85d..a3da65a8 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -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('static_analyzer', type: 'feature', value: 'disabled', description: 'Run gcc static analyzer') option('test', type: 'feature', value: 'disabled', description: 'Run tests') +option('sections', type: 'feature', value: 'disabled', description: 'Show unused functions')