Filter and sort compilation messages for dups.

This makes the output much more easily handled is there's a particularly
noisy templated line, for instance.