Skip to content

Conversation

hahnjo
Copy link
Member

@hahnjo hahnjo commented Oct 1, 2025

Garbage collect unused sections and strip the library after build, reducing its size from 120 MB to 88 MB in a Release configuration with GCC. See the individual commit messages for more details.

FYI @vepadulano maybe interesting for the Python wheels, though we will grow in size again with each LLVM upgrade...

hahnjo added 2 commits October 1, 2025 13:35
After inlining and hiding symbols, some of them are not referenced
anymore and can be collected by the linker, reducing the library
size from 120 MB to 105 MB in a Release configuration with GCC.
This is optional during installation, but we always want it because
of the large gains, reducing the size of the library further from
105 MB to 88 MB.
@hahnjo hahnjo self-assigned this Oct 1, 2025
@hahnjo hahnjo requested a review from bellenot as a code owner October 1, 2025 12:03
Copy link
Member

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

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

Lgtm!

We might be able to do better because even if libCling is a shared library it is self contained. That is we don’t expose any of these llvm interfaces outside. I am not sure if we can express that to the linker but practically we can strip a lot of symbols as if we were building a binary.

@hahnjo
Copy link
Member Author

hahnjo commented Oct 1, 2025

We might be able to do better because even if libCling is a shared library it is self contained. That is we don’t expose any of these llvm interfaces outside. I am not sure if we can express that to the linker but practically we can strip a lot of symbols as if we were building a binary.

Hiding symbols, garbage collecting unused stuff and strip already does this effectively.

@vgvassilev
Copy link
Member

We might be able to do better because even if libCling is a shared library it is self contained. That is we don’t expose any of these llvm interfaces outside. I am not sure if we can express that to the linker but practically we can strip a lot of symbols as if we were building a binary.

Hiding symbols, garbage collecting unused stuff and strip already does this effectively.

I believe if I build some binary on top of llvm built with hidden visibility I will get the overall size to be smaller. In addition, it seems some of the linked in JIT components might not be needed. Forgot what those were but I am surprised that if the linker does not find them.

Copy link
Member

@vepadulano vepadulano left a comment

Choose a reason for hiding this comment

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

Nice ideas, thanks!

@github-actions
Copy link

github-actions bot commented Oct 1, 2025

Test Results

    21 files      21 suites   3d 16h 34m 39s ⏱️
 3 683 tests  3 683 ✅ 0 💤 0 ❌
75 527 runs  75 527 ✅ 0 💤 0 ❌

Results for commit 99ee373.

@hahnjo hahnjo merged commit 4731fd5 into root-project:master Oct 6, 2025
28 of 29 checks passed
@hahnjo hahnjo deleted the libCling-size branch October 6, 2025 11:09
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.

4 participants