Repository navigation
[c++] hide symbols that aren't in the C API - #7496
Merged
Merged
Conversation
jameslamb
commented
Oct 18, 2026
Comment on lines
+42
to
+43
| --max-allowed-size-compressed '4M' \ | ||
| --max-allowed-size-uncompressed '10M' \ |
Member
Author
There was a problem hiding this comment.
slightly smaller binary, yay 😁
3 of 9 tasks
jameslamb
marked this pull request as ready for review
October 18, 2026 03:23
jameslamb
requested review from
borchero,
guolinke,
jmoralez,
mayer79 and
shiyu1994
as code owners
October 18, 2026 03:23
Member
Author
|
I think this is ready for review. I'm very excited about this one, have been wanting to do it for a long time 😊 |
Member
Author
|
Thanks very much for taking a look (and all other reviews) @borchero ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Notes for Reviewers
Contributes to #7327
By convention, we consider the
LGBM_*functions in the C API to be the full public API oflib_lightgbm.{dll,dylib,so}. Everything else is considered an internal implementation detail and not intended to be accessed directly.I say "by convention" because today there are 1,000+ symbols exported from the shared library on macOS / Linux. On my Mac using
clang, I saw:LGBM_functionsjson11code_Arrow*symbols fromnanoarrowfmt::symbols fromfmt_.gomp_critical_user_.reduction.var)code to see them (click me)
This proposes limiting the visibility of all those unintentionally-exported symbols.
Benefits of these changes
lib_lightgbm'sfmt::symbols being found at load time by some other library that was compiled against a different version offmt::See "Why is the new C++ visibility support so useful?" at https://gcc.gnu.org/wiki/Visibility for more.
Notes for Reviewers
I have been wanting to do this for a looooong time 😊
Is this safe?
I think so. I had an AI agent check (and I manually spot-checked) all the projects listed in https://github.com/lightgbm-org/LightGBM#external-unofficial-repositories. All but 1 of them either do not call into
lib_lightgbm.{dll,dylib,so}at all or do so only through the C API. There's plenty of software that isn't public on GitHub but still... I think we should make this change.The only exception is https://github.com/microsoft/LightGBM-transform, but that was abandoned 3 years ago, and builds its own copy of
lib_lightgbmanyway, AND I'd like to drop support for it soon anyway: #7381There's more work to do after this
I'd hoped this would fix #6595 but it doesn't, the reproducible example from there still reproduces.
But still, this will help prevent stuff like that!
References