Skip to content

llext: Add option to garbage-collect unused syms #86108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

WorldofJARcraft
Copy link
Contributor

This commit adds a new configuration LLEXT_SYMBOL_GC. It enables link-time garbage collection for symbols in llexts. This can reduce code size in extensions that statically link libraries or have many unused functions for any reason. The implementation relies on gcc-specific linker flags for the actual garbage collection. To this end, the compiler is instructed to separate functions and global data into individual sections. The linker can then remove sections that are not referenced by the GC roots, which currently consist of the sections that contain the explicitly exported symbols.
Additionally, a linker script for llext extensions was added - its purpose is to merge the function and data sections after the link, as llext currently cannot handle having multiple text/data sections.
This feature is currently not supported on Xtensa.

Ths commit adds a new configuration LLEXT_SYMBOL_GC.
It enables link-time garbage collection for symbols in llexts.
This can reduce code size in extensions that statically link
libraries or have many unused functions for any reason.
The implementation relies on gcc-specific linker flags for the
actual garbage collection. To this end, the compiler is instructed
to separate functions and global data into individual sections.
The linker can then remove sections that are not referenced by the
GC roots, which currently consist of the sections that contain the
explicitly exported symbols.
Additionally, a linker script for llext extensions was added - its
purpose is to merge the function and data sections after the link,
as llext currently cannot handle having multiple text/data sections.
This feature is currently not supported on Xtensa.

Signed-off-by: Eric Ackermann <[email protected]>
Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant