raiden00pl commented on PR #20723:
URL: https://github.com/apache/nuttx/pull/20723#issuecomment-6976243640

   @casaroli @xiaoxiang781216 @GUIDINGLI 
   
   
   This change costs every LTO image ~1.5 KB of flash, even when nothing in the 
image uses `__thread`. The `-u __wrap___emutls_get_address` / `-u 
__wrap___emutls_register_common` options force `tls_emutls.c` into the link, 
and it also pulls `realloc()`, `memmove()` and the semaphore code.
   
   Measured on `nucleo-f302r8` with `CONFIG_DEFAULT_SMALL=y` and 
`CONFIG_LTO_FULL=y`, simple hello world, GCC 16.2, master 8a282a51d4:
   
   | | flash | sram |
   |---|---|---|
   | `CONFIG_TLS_EMUTLS=y` (default) | 23208 B | 1160 B |
   | `CONFIG_TLS_EMUTLS=n` | 21752 B | 1120 B |
   
   That is +1456 B (+6.7%) of flash for a feature the image doesn't use. The 
smallest image I have (no console, no files) goes from 8.8 KB to 10.1 KB. 
Without LTO the difference is only 12 B, so the cost comes only from the forced 
`-u` symbols.
   
   The PR description mentions ~800 B and one board that overflowed, so the 
cost was known. But the option defaults to `y` for everyone, including 
`CONFIG_DEFAULT_SMALL=y` configurations, where users expect the smallest image. 
Most small boards will never use `__thread`, and users won't know that a new 
option silently ate 1.5 KB of their flash.
   
   Can we at least make it:
   
   ```
   config TLS_EMUTLS
        bool "Per-thread copies of emulated TLS variables"
        default !DEFAULT_SMALL
   ```
   
   Even better would be to link this code only when `__thread` is used, without 
the unconditional `-u` for LTO builds.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to