-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[Zephyr] Fix build issues with LTO #34633
Merged
Merged
Conversation
This file contains 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
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]>
The flash usage on this app/platform is close to the limit. Enable LTO to prevent from blocking the incoming PRs. Signed-off-by: Damian Krolik <[email protected]>
Review changes with SemanticDiff. |
pullapprove
bot
requested review from
andy31415,
andyg-apple,
anush-apple,
arkq,
axelnxp,
bauerschwan,
bzbarsky-apple,
carol-apple,
cecille,
chapongatien,
chrisdecenzo,
chshu,
chulspro,
cliffamzn,
dhrishi,
doru91,
fessehaeve,
harimau-qirex,
harsha-rajendran and
hawk248
July 30, 2024 14:43
pullapprove
bot
requested review from
tima-q,
tobiasgraf,
turon,
vivien-apple,
wiba-nordic,
woody-apple,
younghak-hwang and
yufengwangca
July 30, 2024 14:43
pullapprove
bot
added
review - pending
examples
platform
zephyr
lib
config
shell
and removed
examples
platform
zephyr
lib
config
shell
labels
Jul 30, 2024
andy31415
approved these changes
Jul 30, 2024
PR #34633: Size comparison from 87393f8 to 653f21a Full report (96 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, mbed, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
bzbarsky-apple
approved these changes
Jul 30, 2024
j-ororke
pushed a commit
to j-ororke/connectedhomeip
that referenced
this pull request
Jul 31, 2024
* [Zephyr] Fix sys_heap malloc build with LTO 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]> * [nrfconnect] Do not link libCHIPShell.a with --whole-archive 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]> * [nrfconnect] Build all clusters app for nRF7002 with LTO The flash usage on this app/platform is close to the limit. Enable LTO to prevent from blocking the incoming PRs. Signed-off-by: Damian Krolik <[email protected]> --------- Signed-off-by: Damian Krolik <[email protected]>
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.
[nrfconnect] Build all clusters app for nRF7002 with LTO
The flash usage on this app/platform is close to the limit.
Enable LTO to prevent from blocking the incoming PRs.
[nrfconnect] Do not link libCHIPShell.a with --whole-archive
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.
[Zephyr] Fix sys_heap malloc build with LTO
Fix the build of Matter samples with sys_heap malloc enabled. The linker errors would occur because:
Mark malloc/calloc/realloc/free as externally visible.