-
Notifications
You must be signed in to change notification settings - Fork 260
Compiled functions are repeated due to use of static inline
#2179
Comments
Ad. the wiki quote: all of this is just a workaround for us not using Link Time Optimization and having all code in C files. CC: @boryspoplawski |
When compiled with DEBUG, -O2 isn't specified. See Scripts/Makefile.configs. So this isn't surprise. |
Agreed with @mkow, but is there a particular problem with the current situation? Is it just annoying for debugging, or something else is blocked by this? |
Roughly similar to just -O2:
Since it turns out the issue is mostly with As for blocking... well, we were hesitant to enable inlining for a frequently-used function in #2177 because of this (because in debug-mode it would appear in 50+ copies, one for each Anyway, yes, I agree we should do both: fix the issue with |
Yes, we need to rework checkpointing first (it uses section sorting, don't ask me why it's done this way). Regarding this issue: tbh I don't see the problem, we will get rid of this once we have LTO. For now I don't mind having 5 functions repeated couple of times (especially considering they are very small). |
I guess it's not too serious, but having fifty-three copies of |
Our header files define functions as
static inline
. That means than when a function is not inlined by compiler, is treated asstatic
, i.e. separate for a compilation unit. As a result, if it's used in multiple compilation units, it gets repeated in the binary:That's compiled with DEBUG. Without DEBUG the list is much shorter:
(I'm not sure if the first two are due to this issue of a quirk of GCC compilation).
I haven't checked but (at least with DEBUG) these repeated functions might account for a significant part of the LibOS binary (and some of libpal as well).
These functions should be defined as
inline
. However, that currently breaks the build during linking. For example, after changingcreate_event
fromstatic inline
toinline
:I suspect that the definitions are
static inline
because the above did not work, and that's probably because we have a custom linker script.Proposed solution
Change all instances of
static inline
in header files toinline
, and fix the build process so that we can useinline
.More information
Wikipedia, emphasis mine:
The text was updated successfully, but these errors were encountered: