Skip to content

[CMake] Link only what is used: drop unused explicit library deps#22669

Open
guitargeek wants to merge 1 commit into
root-project:masterfrom
guitargeek:issue-20731
Open

[CMake] Link only what is used: drop unused explicit library deps#22669
guitargeek wants to merge 1 commit into
root-project:masterfrom
guitargeek:issue-20731

Conversation

@guitargeek

Copy link
Copy Markdown
Contributor

Address #20731 by removing explicitly-linked-but-unused libraries reported by ldd -u. The recurring offenders all came from foundational libraries exporting internal-only dependencies through their PUBLIC link interface (CMake DEPENDENCIES), so every consumer inherited them. These are now PRIVATE (CMake LIBRARIES), and genuinely-spurious links dropped:

  • RIO: Thread -> PRIVATE (TFilePrefetch only holds a TThread* member)
  • Tree: Imt/Net/MathCore -> PRIVATE, declares its own Thread
    (RIO stays PUBLIC: TBufferSQL/TTreeCache derive from RIO types)
  • RHTTP/HistPainter/RooStats/RooFitMore/RCsg: internal deps -> PRIVATE
  • Hbook/Spectrum/HistFactory: spurious Matrix/Foam removed
  • ntuple_merger/stressRooFit tests: declare the deps they actually use

RIO -> Thread alone cuts Thread over-linking from 62 reports to 2; in total the tree drops from 510 reports (77 libs) to 422 (69), and every library still links cleanly under -Wl, --no-undefined.

This closes #20731: the remaining reports are not over-linking and PUBLIC/PRIVATE cannot remove them. They are either inline-header dependencies (e.g. Tree using TMath: a real compile dependency with no exported symbol, which ldd -u mis-flags) or deliberate public API (Hist exposes TVectorD/TMatrixD; TMessage derives from TBufferFile).

Closes #20731.

🤖 Done with the help of AI.

Address root-project#20731 by removing explicitly-linked-but-unused libraries
reported by `ldd -u`. The recurring offenders all came from foundational
libraries exporting internal-only dependencies through their PUBLIC link
interface (CMake DEPENDENCIES), so every consumer inherited them. These
are now PRIVATE (CMake LIBRARIES), and genuinely-spurious links dropped:

  * RIO: Thread -> `PRIVATE` (TFilePrefetch only holds a TThread* member)
  * Tree: Imt/Net/MathCore -> `PRIVATE`, declares its own Thread
          (RIO stays PUBLIC: TBufferSQL/TTreeCache derive from RIO types)
  * RHTTP/HistPainter/RooStats/RooFitMore/RCsg: internal deps -> PRIVATE
  * Hbook/Spectrum/HistFactory: spurious Matrix/Foam removed
  * ntuple_merger/stressRooFit tests: declare the deps they actually use

RIO -> Thread alone cuts Thread over-linking from 62 reports to 2; in
total the tree drops from 510 reports (77 libs) to 422 (69), and every
library still links cleanly under `-Wl`, `--no-undefined`.

This closes root-project#20731: the remaining reports are not over-linking and
PUBLIC/PRIVATE cannot remove them. They are either inline-header
dependencies (e.g. Tree using TMath: a real compile dependency with no
exported symbol, which `ldd -u` mis-flags) or deliberate public API
(Hist exposes TVectorD/TMatrixD; TMessage derives from TBufferFile).

Closes root-project#20731.

🤖 Done with the help of AI.
@github-actions

github-actions Bot commented Jun 20, 2026

Copy link
Copy Markdown

Test Results

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit ff35da8.

♻️ This comment has been updated with latest results.

@dpiparo dpiparo added the clean build Ask CI to do non-incremental build on PR label Jun 22, 2026
@dpiparo dpiparo closed this Jun 22, 2026
@dpiparo dpiparo reopened this Jun 22, 2026
@dpiparo

dpiparo commented Jun 22, 2026

Copy link
Copy Markdown
Member

Added the "clean build" label and restarted, this is perhaps necessary to better understand any failure since the complication of pre-existing artifacts is lifted.

@guitargeek

Copy link
Copy Markdown
Contributor Author

Looks like it still doesn't work, probably because my local configuration is very different from the default or what is run on the CI. Will investigate!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖AI-Assisted clean build Ask CI to do non-incremental build on PR in:Build System

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate/Remove potentially unnecessary explicit linking

2 participants