I recently figured out that by default Arduino only creates an archive (.a) for the core, and not for any libraries. Despite almost all C developers being familiar with the convention of combining .o files in to a .a, for the Arduino IDE all .o's built from a library are included on the link line.
I made a UART library that has optional support for interrupt-driven receive. By putting the rx_data_ready() function in the same .o as the ISR (where the vector is defined), and linking the library .a, the ISR only gets installed if the rx_data_ready() function is used. When I tried using the library in the Arduino IDE, I ran into the problem. With the Arduino library build process, the ISR code gets included even if it is never used.
I see from the arduino libary specs that it is possible to create archive files.
My tolerance for learning Arduino internals is rather limited, as I have to suppress the impulse to bang my head against the wall every time I read another stupid way it does things. :-)
Is anyone aware of a reasonably simple and well written Arduino library I can use as a template?