2023-08-04 04:27 PM
I'm working through some code size optimization efforts and noticed that our list file includes some calls to __assert_func. We're not using asserts in our codebase so I'm guessing one of the standard libs is using it. I checked and we have defined NDEBUG in the project properties. If I redefine __assert_func as an empty function, the calls disappear and we get back 4kB of flash. Any idea why it's being linked?
2023-08-04 05:32 PM
Preprocessor defines aren't going to impact pre-compiled components.
Grep the libraries.
See what's calling it from a disassembly/listing. Perhaps the linker has some verbose mode or output?
2023-08-05 11:12 AM - edited 2023-08-05 11:17 AM
> If I redefine __assert_func as an empty function, the calls disappear
Probably, effect of link-time optimization (LTCG)
ST libraries use error handler named assert_failed, not assert_func. The latter can come from the newlib in the latest CubeIDE toolchain build...
2023-08-07 11:51 AM
Ah, yes I overlooked that these are precompiled and therefore wont care about my flags. Is there any way to disable the newlib asserts or is overwriting the function, and relying on flto the best solution?