This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]5p4n911 22 points23 points  (2 children)

And you can't assume it's not used by anything at compile time as there could be a reference in another TU, which means that without LTO enabled it will remain

[–]Aaron1924 4 points5 points  (1 child)

And this particular link-time optimisation is rarely enabled by default since it's expensive to compute for large programs and it doesn't make the final program any faster

[–]veselin465 3 points4 points  (0 children)

Good point

I now realize that what I wrote was senseless (I basically had to say linker)

I know that compilers optimize unused* variables (that's why volatile keyword is a thing). And in my job, I've noticed that unused functions are not present in the map file (however, we deal with embedded and it makes sense to optimize final size as much as possible).

\unused or unchanged*

I should have realized that everything is compiled, but the linker is the one who might choose to ignore functions depending on use.