Earlier quoted context omitted.
Seems like something the compiler should take care of.
It can when you use LTO, but that tends to be very slow for large programs.
You hit most of the same issues (and some additional ones) when compiling the same code within one translation unit...