-
Notifications
You must be signed in to change notification settings - Fork 3k
Disable global objects destruction #2745
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
Conversation
This behavior is realized by enabling the flag --no_static_destruction when the compilerin the invoked.
This prevent destructors for global C++ objects to be invoked at exit. By default atexit handlers registration involved dynamic allocation.
With this call, destructors are not registered for execution atexit.
This change simplify the exit and initialization process. It also reduce the number of hidden memory allocation made by atexit.
Can you elaborate? how does this differ from the rest toolchains? |
This PR shutdown completely On ARMCC, the result is identical to shutting down |
Good to know, I would have assumed all of them would do __eabi_atexit.
Memory savings? 😄 We can ask IAR. Looks good to me the way it is. |
/morph test |
@mbed-bot: TEST HOST_OSES=ALL |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
Outputmbed Build Number: 906 All builds and test passed! |
[Build 952] |
Description
This pull request disable the destruction of global objects when exit is called.
A different method is applied for each compiler:
--no_static_destruction
.__aeabi_atexit
,__cxa_atexit
and__cxa_finalize
. The methodology is explained here.exit
has been overridden to directly call_exit
instead of calling in reverse order every function registered byatexit
. In the meantime,atexit
has been overridden to be a stub which does nothing.Related PRs
This PR is a follow up of #2715 #2741
Gain:
The test have been conducted upon mbed-os-example-blinky compiled with NDEBUG enabled.