Skip to content

Mismatched wasm output on darwin vs Ubuntu #97919

Open
@nmattia

Description

@nmattia

I tried this code:

// Crate A
use std::cell::{RefCell};
use std::collections::HashMap;

use internet_identity_interface as other;

#[export_name = "the name"]
fn dummy()
{
    let _err_info = "hello".to_string(); // Removing this makes the outputs match

    other::unreachable(); // Calling unreachable! from this crate makes the outputs match
}


pub type SomeType = u8; // Inlining 'u8' in the ASSETS below makes the outputs match

thread_local! {
    static ASSETS: RefCell<HashMap<&'static str, (Vec<SomeType>, &'static [u8])>> = RefCell::new(HashMap::default());
}

fn main() {}
// Crate B ("other")
pub fn unreachable() {
    unreachable!();
}

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:

cargo build --manifest-path ./src/path/to/Crate/A/Cargo.toml --target wasm32-unknown-unknown --release -j1

This could be a cargo issue, I'm not sure of what's happening under the hood.

Meta

rustc --version --verbose:

rustc 1.58.1 (db9d1b20b 2022-01-20)
binary: rustc
commit-hash: db9d1b20bba1968c1ec1fc49616d4742c1725b4b
commit-date: 2022-01-20
host: x86_64-apple-darwin
release: 1.58.1
LLVM version: 13.0.0

---

rustc 1.58.1 (db9d1b20b 2022-01-20)
binary: rustc
commit-hash: db9d1b20bba1968c1ec1fc49616d4742c1725b4b
commit-date: 2022-01-20
host: x86_64-unknown-linux-gnu
release: 1.58.1
LLVM version: 13.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-reproducibilityArea: Reproducible / deterministic buildsC-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions