Open nmattia opened 2 years ago
When you refer to "matching outputs" do you mean the compiled wasm binaries?
I don't think rustc guarantees binary stability between compilations performed on the same machine, let alone those performed on different host platforms.
Rust does not guarantee reproducible builds between compilers built from different commits, but you should be able to rely on getting reproducible builds given the same target, same toolchain versions and some --remap-path-prefix
action.
Are you sure this isn't just an example of some host paths leaking into the wasm output?
When you refer to "matching outputs" do you mean the compiled wasm binaries?
Yes!
Are you sure this isn't just an example of some host paths leaking into the wasm output?
Maybe, but when I looked at the wasm (or rather .wat) code there seemed to be differences in the code itself, not just the strings. Will have another go at it with --remap-path-prefix
!
Is "B" specified by relative path? It doesn't look like you included your Cargo.toml.
If it's specified by relative path my #98185 might be a duplicate of this issue.
Building this (simpler) library also results in mismatching WASM hashes on Ubuntu and macOS:
#[no_mangle]
pub fn greet(name: i32) -> usize {
aux(name.to_string()).len()
}
fn aux(x: String) -> String {
format!("Hello, {}", x)
}
I am seeing differences in simple wasm binaries when compiled with 1.79 and 1.80 on both macos and linux. I have used --remap-path-prefix
and there are no differences in paths between the binaries.
The two differences I see are:
The latter seems the most important, as it could conceivably influence the former.
I see that cargo is passing different values for -C metadata
to our crates, depending on platform. There is an existing cargo issue about this: https://github.com/rust-lang/cargo/issues/8140
The above issue may be fixed by https://github.com/rust-lang/cargo/pull/14107, which references https://github.com/rust-lang/rust/issues/117597, which this may be a duplicate of.
I tried this code:
When building using the
wasm32-unknown-unknown
target, I expect the output to be the same on Ubuntu and macOS. Instead, I'm getting different outputs. I've tried on different Ubuntu and macOS versions, and the output is consistent across all versions of the same platform. What's really odd is that the slightest various of the code above makes the output match again.This is the command I use to build:
This could be a cargo issue, I'm not sure of what's happening under the hood.
Meta
rustc --version --verbose
: