This is a followup to D151165. Instead of using the module ID, use the module hash for sorting the import list. The module hash is what will actually be included in the hash.
This has the advantage of being independent of the module order, which is something that Rust relies on.
A caveat here is that the test doesn't quite work for linkonce_odr functions, because the function may be imported from two different modules, and the first one on the llvm-lto2 command line gets picked (rather than, say, the prevailing copy). This doesn't really matter for Rust's purposes (because it does not use linkonce_odr linkage), but may still be worth addressing. For now I'm using a variant of the test using internal instead of linkonce_odr functions.