This should make both static and dynamic NewPM plugins work with LTO. And as a bonus, it makes static linking of OldPM plugins more reliable for plugins with both an OldPM and NewPM interface.
I only implemented the command-line flag to specify NewPM plugins in llvm-lto2, to show it works. Support can be added for other tools later.
I'm not confident the dynamic plugin bits work the way they should, but it's at least enough to make the included test pass.
That's the exact same lines as above. Maybe it's worth putting that in a function?