Skip to content

Tracking issue for wasm32-unknown-unknown's future-incompat warning for C ABI changes #138762

Open
@alexcrichton

Description

@alexcrichton

This issue is intended to be a tracking issue for the future-incompat warning being added in #138601. This lint is notifying users of an upcoming change to the C ABI used by the wasm32-unknown-unknown target, notably around passing aggregates-by-value in parameter position. An exampe of code that will change is:

#[repr(C)]
pub struct Pair {
    x: u32,
    y: u32,
}

#[unsafe(no_mangle)]
pub extern "C" fn pair_add(pair: Pair) -> u32 {
    pair.x + pair.y
}

where today this generates:

(func $pair_add (param i32 i32) (result i32)
  local.get 1
  local.get 0
  i32.add
)

but in the future this will generate:

(func (param i32) (result i32)
  local.get 0
  i32.load offset=4
  local.get 0
  i32.load
  i32.add
)

More details about this change and its history can be found in the blog post associated with this change. In short though users need to do one of the following to resolve the warnings:

  1. Pin to a stable compiler and don't update until the default has changed.
  2. Update to nightly, pass -Zwasm-c-abi=spec, and then use that until the default changes. This means signatures will change immediately and work will be necessary to port external JS for example.
  3. Update to nightly, pass -Zwasm-c-abi=legacy. This will silence the warnings but be warned that code will still break in the future when the ABI changes.
  4. Update function signatures to not pass aggregates-by-value, but instead pass them by reference. This works both today and with the future ABI.

The current plan is to change the default ABI mid-summer 2025. This'll get updated with exact timelines as things happen. More background can be found in #122532

Implementation history

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ABIArea: Concerning the application binary interface (ABI)C-future-incompatibilityCategory: Future-incompatibility lintsC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCO-wasmTarget: WASM (WebAssembly), http://webassembly.org/T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions