]> git.ipfire.org Git - thirdparty/systemd.git/commit
tools: Add script to detect unused symbols in libshared
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 19 Nov 2025 09:30:01 +0000 (10:30 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 19 Nov 2025 12:14:15 +0000 (13:14 +0100)
commit3f0fc9321932f8e0e35922586c7369eec557793d
tree69b9cb438d63776f3f9eab8fe9c3c7fe3ee4da17
parent4186aad3740446b929913ecf902dccc4be27ddb3
tools: Add script to detect unused symbols in libshared

Symbols exported by libshared can't get pruned by the linker, so
every unused exported symbol is effectively dead code we ship to users
for no good reason. Let's add a script to analyze how many such symbols
we have.

We also add a meson test to run the script on all of our binaries.
Since it detects unused symbols and still has a few false positives,
don't enable the test by default similar to the clang-tidy tests.

The script was 100% vibe coded by Github Copilot with Claude Sonnet 4.5
as the model.

Current results are (without the unused symbols list):

Analysis of libsystemd-shared-259.so
======================================================================
Total exported symbols: 4830
  (excluding public API symbols starting with 'sd_')
Used symbols: 4672
Unused symbols: 158
Usage rate: 96.7%
meson.build
tools/find-unused-library-symbols.py [new file with mode: 0755]