-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
linker: do not force keep common kernel objects #28486
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
The compliance complain is about linker script not acting like C code... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this!
However, this still seems to leave stuff in that should not be there:
west build -b reel_board -t rom_report samples/basic/minimal/ -- -DCONF_FILE="common.conf no-mt.conf no-timers.conf arm.conf"
So it doesn't fix #20663 entirely.
You will likely need something like:
carlescufi@a0d30e2#diff-4560d3c90a6d35d90781757e85d2056dR12
and
carlescufi@a0d30e2#diff-9112b5bcdb85f9fc628e8175f32264b5R28
to stop pulling heap and mempool code when not needed.
Is it the cross-dependencies between kernel/ and lib/ that are defeating the |
The iterable section macros Z_ITERABLE_SECTION_ROM()/_RAM() uses Z_LINK_ITERABLE() which does KEEP() on all symbols. This results in all symbols under those sections being kept in final image even though these symbols are not referred directly from the code. This adds the new set of macros which does not force KEEP() on the symbols, and allows symbols to be garbage collected. The existing macros are kept as-is so as not to change their behaviors. Signed-off-by: Daniel Leung <[email protected]>
This uses the new macros so the common kernel objects can be garbage collected if they are not referred directly anywhere in the code. This is useful for reducing library data size as not all library functions and their corresponding kobjects are being used. Fixes zephyrproject-rtos#20663 Signed-off-by: Daniel Leung <[email protected]>
Adds a kconfig CONFIG_KERNEL_MEM_POOL to decide whether kernel memory pool related code is compiled. This option can be disabled to shrink code size. If k_heap is not being used at all, kheap.c will also not be compiled, resulting in further smaller code size. Signed-off-by: Daniel Leung <[email protected]>
This adds the option to disable kernel memory pool when multithreading is also not enabled. This saves some code space. Signed-off-by: Daniel Leung <[email protected]>
28a0b00
to
acac115
Compare
It looks like @carlescufi if you want, I can have |
I'm not sure if the multithreading=n matters much. This configuration is deprecated and is going away soon.
I think it's a general issue we need to solve, I don't think we want to go down a path where we have to have Kconfigs for core kernel APIs because of some interaction in dependencies between What specifically is pulling in what, with respect to lib/os/mempool.c and kernel/kheap.c? I have a feeling that the real proper fix for this is to finish what we started in #24358 I don't understand why that issue keeps bouncing back and forth between "enhancement" and "bug" status |
It's caused by calling of Setting To completely prevent either |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am happy with the outcome. Thank you @dcpleung.
This uses the new macros so the common kernel objects can be
garbage collected if they are not referred directly anywhere
in the code. This is useful for reducing library data size
as not all library functions and their corresponding kobjects
are being used.
Fixes #20663
Signed-off-by: Daniel Leung [email protected]