Skip to content

Conversation

@rgrinberg
Copy link
Member

@rgrinberg rgrinberg commented Oct 25, 2025

Introduce an alias unused-libs that will error out if it detects any used libraries.

  • add a way to add intentionally unused libraries
  • add some docs
  • add a test demonstrate that some unused dependency cannot be detected
  • changes

In the future, we could consider adding an alias per library or executable stanza if anybody wants such granularity.

Fixes #650

@rgrinberg rgrinberg marked this pull request as ready for review October 25, 2025 03:03
Alizter
Alizter previously approved these changes Oct 27, 2025
@rgrinberg rgrinberg force-pushed the ocamlobjinfo-multi-files branch from ff31b91 to 5ea10af Compare October 27, 2025 15:33
@rgrinberg rgrinberg changed the title refactor: ocamlobjinfo with multiple files feature: add an unused-libs alias Oct 27, 2025
@rgrinberg rgrinberg requested a review from nojb October 27, 2025 15:34
@rgrinberg rgrinberg marked this pull request as draft October 27, 2025 15:34
@rgrinberg rgrinberg force-pushed the ocamlobjinfo-multi-files branch 5 times, most recently from 49e8456 to 848e13e Compare October 27, 2025 21:20
@rgrinberg rgrinberg force-pushed the ocamlobjinfo-multi-files branch from 848e13e to 9f7438c Compare November 6, 2025 23:01
@rgrinberg rgrinberg marked this pull request as ready for review November 6, 2025 23:01
@rgrinberg rgrinberg force-pushed the ocamlobjinfo-multi-files branch from 9f7438c to 00742fd Compare November 6, 2025 23:02
@rgrinberg
Copy link
Member Author

@nojb this is ready now

@rgrinberg rgrinberg force-pushed the ocamlobjinfo-multi-files branch from 00742fd to 1f46798 Compare November 9, 2025 21:28
@rgrinberg
Copy link
Member Author

ping @nojb. We're preparing a release and I think users would be pleased to see this feature finally arrive.

Copy link
Collaborator

@nojb nojb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sorry for the lag, been really busy, as usual.

Just to confirm: if one links an executable with -linkall then none of the libraries will be "unused", right?

Copy link
Collaborator

@nojb nojb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, a quick follow-up to the previous review (see question below). Also, I think the allow_unused_libraries field is not documented.

@rgrinberg rgrinberg force-pushed the ocamlobjinfo-multi-files branch from 1f46798 to 6f15c31 Compare November 15, 2025 18:54
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
Introduce an alias to detect unused libraries in libraries and
executable stanzas.

This stanza relies on information extracted using ocamlobjinfo to detect
which modules are actually used

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>

feature: allow_unused_libraries

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
@rgrinberg rgrinberg force-pushed the ocamlobjinfo-multi-files branch from 6f15c31 to 5f76e87 Compare November 15, 2025 22:25
@rgrinberg
Copy link
Member Author

Sorry, a quick follow-up to the previous review (see question below). Also, I think the allow_unused_libraries field is not documented.

Been disabled now. It will need a bit more refactoring and thought to support without unnecessary duplication.

@rgrinberg rgrinberg merged commit 8329919 into ocaml:main Nov 15, 2025
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dune should warn about dependencies on unused libraries

3 participants