-
Notifications
You must be signed in to change notification settings - Fork 60
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
LTO build fixes #339
LTO build fixes #339
Conversation
f3edecc
to
f2dffc6
Compare
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.
This is awesome! Thank you 👍
I would like to merge the changes needed to enable LTO, but would like to either (ideally) have KConfig option to enable LTO for Matter, or alternatively not adding -flto flags now yet - those will be added for generic CONFIG_LTO
soon.
f2dffc6
to
2173686
Compare
@LuDuda The commit to enable LTO was added just for testing. I removed it, so the PR can be merged now. |
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.
Awesome!
Fix the build of Matter samples with sys_heap malloc enabled. The linker errors would occur because: 1. The realloc() function is not used outside the LTO- optimized code. 2. Thus, the LTO linker plugin would mark __wrap_realloc symbol as PREVAILING_DEF_IRONLY, which would enable the compiler to optimize away the function. 3. As a result, undefined references to realloc() could not be resolved by the linker. Mark malloc/calloc/realloc/free as externally visible. Signed-off-by: Damian Krolik <[email protected]>
libCHIPShell.a is already part of libCHIP.a but the former had to be linked additionally with --whole-archive flag to process the shell and init objects defined with SHELL_XXX and SYS_INIT Zephyr macros and, in turn, register Matter shell commands properly. This symbol duplication between the two libraries causes issues when building Matter with LTO, so replace the current approach with explicitly pulling in one symbol from MainLoopZephyr.cpp file. Signed-off-by: Damian Krolik <[email protected]>
2173686
to
95c9783
Compare
[Zephyr] Fix sys_heap malloc build with LTO
[nrfconnect] Do not link libCHIPShell.a with --whole-archive