You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Static functions are private to the compilation unit they are emitted
in, so they cannot be shared between compilation units. This means that
any source file that uses `core_debug()` where the compiler does not
inline (all) calls, will have its own private copy of this function
emitted. In practice, gcc seems to never inline this function (even with
-O3), leading to one copy of the function for each compilation unit it
is used in.
This fixes this by removing the `static` keyword from the function.
However, this prevents the function from being emitted completely in
C compilation units (C++ is different and emits multiple copies,
discarding all but one later). This means that if the function is only
used from C compilation units and not inlined everywhere, you get
a linker error. Thet `static` keyword was probably added to work around
this, without realizing the overhead.
The proper way to prevent this linker error is to add an `extern`
definition for the function in a single source file, so this adds
a `core_debug.c` with exactly that.
In practice, this means that this commit saves 40 bytes of space for
each compilation unit where `core_debug()` is used (beyond the first).
0 commit comments