How could it ever infer it, given C's compilation model?
The only option is when all TU are given at the same time to the compiler, or when LTO is used (in which case it is actually the linker doing the work).
Even then, this won't apply to libraries.