Does the compiled binary of a sketch include uncalled functions from a library?
In general only the functions actually used by your code are included in the final linkage of the binary.
However it's not always possible for the compiler to know what is used and what isn't.
In the case of simple functions and classes there's no problem - the linker is intelligent enough to work it out and only link in the functions that are actually used.
However when it comes to more complex systems with polymorphism or when working with function pointers there are times when the compiler won't really know what is needed and what isn't so sometimes some code gets included that isn't actually wanted.
As the compiler advances those times are getting fewer and farther between, so unless you really have a dire need to reduce your code size there's really nothing much to gain. If you do have that need then you would gain more by reducing the complexity of the code in general and collapsing any polymorphism rather than removing unused functions.
BTW: the &quot;optimize for size&quot; has nothing to do with what code is included / excluded. Instead it controls such things as which function are selected for inline, and what loops are unrolled or not, amongst other things.