When I recently looked at the v0 name mangling scheme, I was confused why generics had a suffix that is not based on the crate that defined the generic, but the one that instantiated it, because that makes using ODR linkage to avoid duplicate function definitions in the final binary impossible due to different symbol names. I then looked through the code and noticed that ODR linkage is gone. We used to use ODR linkage for generics when codegen units were introduced, but it seems to have been removed when incremental compilation has been introduced. Is that because there were problems that completely prohibit ODR linkage in the context of incremental compilation, or was it just the easier approach at the time? After all, the old name mangling scheme made ODR across crates impossible as well, but I had hoped that the new one would allow for it.
cc @mw ^
I don't think there are conceptual reasons for not using ODR linkage. If I remember correctly the reasons we removed it were:
However, that was a long time ago (2016?) and those reasons might not be valid anymore. In fact, I hoped that I or someone else would look into reenabling ODR linkage in the first half of this year. It would make some things easier to implement and it might reduce code size (maybe even compile times?)
Questions that would need clarification:
The new mangling scheme supports those "instantiating crate" suffixes because the compiler currently needs them. But the suffixes could just be omitted.