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

Copy link
Copy Markdown

Test Results

2 603 tests   2 603 ✅  1h 9m 49s ⏱️
    1 suites      0 💤
    1 files        0 ❌

Results for commit ff35da8.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate/Remove potentially unnecessary explicit linking

2 participants