Hash full signature for imported functions #4269
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #4268
The problem in #4268 was the short hash added to disambiguate imported functions only hashed the Rust identifier of the function. This is enough to ensure uniqueness within a single Rust module, but not across modules as in #4268. This resulted in 2 different wasm functions being exported under the same name.
I fixed this by hashing not just the function name, but the whole signature (name + inputs + outputs + some extra). This means that 2 function will only have the same hash if they have the same name, input, and outputs. If this happens, the functions also have the same ABI and exporting them both under the same name actually works.
(Note: I don't like that 2 functions with the same signature have the same hash, so if you want to, I can hash the source code position of the function as well to make collisions very unlikely.)
Consequently, the hashes of all imported functions are now different. A lot of tests were updated, but the main new test is called
modules.rs
.I also had to enable the
'extra-traits'
feature onsyn
. This feature enables implementingHash
forsyn::Signature
and other types.