@ryanofsky That’s what I’m seeing at -O0
(when inlining is disabled). With -O1
or higher, no symbol is emitted with either inline
or static inline
when all call sites are inlinable.
Also, when compiling with g++
, with multiple object files where the call sites are not inlinable, each object gets indeed a symbol, but they’re turned into a single symbol in the final executable. When compiling with gcc
, the final executable has one symbol per original object.
I think that’s the explanation: all translation units with a non-inlinable call site of an inline function indeed get an emitted symbol, but those are combined into one by the linker.
Given that C++ requires that all translation units in which a non-static
inline
function appears mark it as inline
, it means there can’t be any actual external calls from another unit to an inline function symbol; they’re required to have their own definition, so no symbol is required to be emitted. If it is emitted however, it will be combined across all units by the linked.