Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
alexcrichton opened this issue Mar 21, 2025 · 8 comments
Labels
A-ABI Area: Concerning the application binary interface (ABI) C-future-incompatibility Category: Future-incompatibility lints C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC O-wasm Target: WASM (WebAssembly), http://webassembly.org/ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@alexcrichton
Copy link
Member

alexcrichton commented Mar 21, 2025

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

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 21, 2025
@alexcrichton alexcrichton changed the title Tracking issue for wasm32-unknown-unknown's future-incompat warning Tracking issue for wasm32-unknown-unknown's future-incompat warning for C ABI changes Mar 21, 2025
@jieyouxu jieyouxu added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. O-wasm Target: WASM (WebAssembly), http://webassembly.org/ C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC C-future-incompatibility Category: Future-incompatibility lints A-ABI Area: Concerning the application binary interface (ABI) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 21, 2025
tgross35 added a commit to tgross35/rust that referenced this issue Mar 22, 2025
add FCW to warn about wasm ABI transition

See rust-lang#122532 for context: the "C" ABI on wasm32-unk-unk will change. The goal of this lint is to warn about any function definition and calls whose behavior will be affected by the change. My understanding is the following:
- scalar arguments are fine
  - including 128 bit types, they get passed as two `i64` arguments in both ABIs
- `repr(C)` structs (recursively) wrapping a single scalar argument are fine (unless they have extra padding due to over-alignment attributes)
- all return values are fine

`@bjorn3` `@alexcrichton` `@Manishearth` is that correct?

I am making this a "show up in future compat reports" lint to maximize the chances people become aware of this. OTOH this likely means warnings for most users of Diplomat so maybe we shouldn't do this?

IIUC, wasm-bindgen should be unaffected by this lint as they only pass scalar types as arguments.

Tracking issue: rust-lang#138762
Transition plan blog post: rust-lang/blog.rust-lang.org#1531
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 24, 2025
add FCW to warn about wasm ABI transition

See rust-lang#122532 for context: the "C" ABI on wasm32-unk-unk will change. The goal of this lint is to warn about any function definition and calls whose behavior will be affected by the change. My understanding is the following:
- scalar arguments are fine
  - including 128 bit types, they get passed as two `i64` arguments in both ABIs
- `repr(C)` structs (recursively) wrapping a single scalar argument are fine (unless they have extra padding due to over-alignment attributes)
- all return values are fine

`@bjorn3` `@alexcrichton` `@Manishearth` is that correct?

I am making this a "show up in future compat reports" lint to maximize the chances people become aware of this. OTOH this likely means warnings for most users of Diplomat so maybe we shouldn't do this?

IIUC, wasm-bindgen should be unaffected by this lint as they only pass scalar types as arguments.

Tracking issue: rust-lang#138762
Transition plan blog post: rust-lang/blog.rust-lang.org#1531
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 25, 2025
add FCW to warn about wasm ABI transition

See rust-lang#122532 for context: the "C" ABI on wasm32-unk-unk will change. The goal of this lint is to warn about any function definition and calls whose behavior will be affected by the change. My understanding is the following:
- scalar arguments are fine
  - including 128 bit types, they get passed as two `i64` arguments in both ABIs
- `repr(C)` structs (recursively) wrapping a single scalar argument are fine (unless they have extra padding due to over-alignment attributes)
- all return values are fine

`@bjorn3` `@alexcrichton` `@Manishearth` is that correct?

I am making this a "show up in future compat reports" lint to maximize the chances people become aware of this. OTOH this likely means warnings for most users of Diplomat so maybe we shouldn't do this?

IIUC, wasm-bindgen should be unaffected by this lint as they only pass scalar types as arguments.

Tracking issue: rust-lang#138762
Transition plan blog post: rust-lang/blog.rust-lang.org#1531

try-job: dist-various-2
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 25, 2025
add FCW to warn about wasm ABI transition

See rust-lang#122532 for context: the "C" ABI on wasm32-unk-unk will change. The goal of this lint is to warn about any function definition and calls whose behavior will be affected by the change. My understanding is the following:
- scalar arguments are fine
  - including 128 bit types, they get passed as two `i64` arguments in both ABIs
- `repr(C)` structs (recursively) wrapping a single scalar argument are fine (unless they have extra padding due to over-alignment attributes)
- all return values are fine

`@bjorn3` `@alexcrichton` `@Manishearth` is that correct?

I am making this a "show up in future compat reports" lint to maximize the chances people become aware of this. OTOH this likely means warnings for most users of Diplomat so maybe we shouldn't do this?

IIUC, wasm-bindgen should be unaffected by this lint as they only pass scalar types as arguments.

Tracking issue: rust-lang#138762
Transition plan blog post: rust-lang/blog.rust-lang.org#1531

try-job: dist-various-2
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 25, 2025
add FCW to warn about wasm ABI transition

See rust-lang#122532 for context: the "C" ABI on wasm32-unk-unk will change. The goal of this lint is to warn about any function definition and calls whose behavior will be affected by the change. My understanding is the following:
- scalar arguments are fine
  - including 128 bit types, they get passed as two `i64` arguments in both ABIs
- `repr(C)` structs (recursively) wrapping a single scalar argument are fine (unless they have extra padding due to over-alignment attributes)
- all return values are fine

`@bjorn3` `@alexcrichton` `@Manishearth` is that correct?

I am making this a "show up in future compat reports" lint to maximize the chances people become aware of this. OTOH this likely means warnings for most users of Diplomat so maybe we shouldn't do this?

IIUC, wasm-bindgen should be unaffected by this lint as they only pass scalar types as arguments.

Tracking issue: rust-lang#138762
Transition plan blog post: rust-lang/blog.rust-lang.org#1531

try-job: dist-various-2
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 26, 2025
add FCW to warn about wasm ABI transition

See rust-lang#122532 for context: the "C" ABI on wasm32-unk-unk will change. The goal of this lint is to warn about any function definition and calls whose behavior will be affected by the change. My understanding is the following:
- scalar arguments are fine
  - including 128 bit types, they get passed as two `i64` arguments in both ABIs
- `repr(C)` structs (recursively) wrapping a single scalar argument are fine (unless they have extra padding due to over-alignment attributes)
- all return values are fine

`@bjorn3` `@alexcrichton` `@Manishearth` is that correct?

I am making this a "show up in future compat reports" lint to maximize the chances people become aware of this. OTOH this likely means warnings for most users of Diplomat so maybe we shouldn't do this?

IIUC, wasm-bindgen should be unaffected by this lint as they only pass scalar types as arguments.

Tracking issue: rust-lang#138762
Transition plan blog post: rust-lang/blog.rust-lang.org#1531

try-job: dist-various-2
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this issue Mar 27, 2025
add FCW to warn about wasm ABI transition

See rust-lang/rust#122532 for context: the "C" ABI on wasm32-unk-unk will change. The goal of this lint is to warn about any function definition and calls whose behavior will be affected by the change. My understanding is the following:
- scalar arguments are fine
  - including 128 bit types, they get passed as two `i64` arguments in both ABIs
- `repr(C)` structs (recursively) wrapping a single scalar argument are fine (unless they have extra padding due to over-alignment attributes)
- all return values are fine

`@bjorn3` `@alexcrichton` `@Manishearth` is that correct?

I am making this a "show up in future compat reports" lint to maximize the chances people become aware of this. OTOH this likely means warnings for most users of Diplomat so maybe we shouldn't do this?

IIUC, wasm-bindgen should be unaffected by this lint as they only pass scalar types as arguments.

Tracking issue: rust-lang/rust#138762
Transition plan blog post: rust-lang/blog.rust-lang.org#1531

try-job: dist-various-2
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this issue Apr 2, 2025
add FCW to warn about wasm ABI transition

See rust-lang#122532 for context: the "C" ABI on wasm32-unk-unk will change. The goal of this lint is to warn about any function definition and calls whose behavior will be affected by the change. My understanding is the following:
- scalar arguments are fine
  - including 128 bit types, they get passed as two `i64` arguments in both ABIs
- `repr(C)` structs (recursively) wrapping a single scalar argument are fine (unless they have extra padding due to over-alignment attributes)
- all return values are fine

`@bjorn3` `@alexcrichton` `@Manishearth` is that correct?

I am making this a "show up in future compat reports" lint to maximize the chances people become aware of this. OTOH this likely means warnings for most users of Diplomat so maybe we shouldn't do this?

IIUC, wasm-bindgen should be unaffected by this lint as they only pass scalar types as arguments.

Tracking issue: rust-lang#138762
Transition plan blog post: rust-lang/blog.rust-lang.org#1531

try-job: dist-various-2
@SimonSapin
Copy link
Contributor

Is the wasm32v1-none target affected by this ABI change?

The blog post suggests no: “If you don't use the wasm32-unknown-unknown target, you are not affected by this change.” But the target is documented as “very similar to wasm32-unknown-unknown” with ABI not mentioned in the list of “only three minor differences”

@alexcrichton
Copy link
Member Author

No, wasm32v1-none is not affected, it's already using the correct ABI definition

@danielhjacobs
Copy link

danielhjacobs commented Apr 7, 2025

Every use of #[wasm_bindgen] in our code or our dependencies is causing the warning "this function definition involves an argument of type () which is affected by the wasm ABI transition". Is that accurate? rustwasm/wasm-bindgen#3454 seems to imply wasm-bindgen is now compliant with the "C" ABI.

@danielhjacobs

This comment has been minimized.

@danielhjacobs
Copy link

The wasm-bindgen folks say this is a false positive.

@alexcrichton
Copy link
Member Author

Yes, that's a false positive, and I've submitted #139498 to update the lint.

@hkratz
Copy link
Contributor

hkratz commented Apr 14, 2025

This causes warnings when using simd, e.g. for

use std::arch::wasm32::{
    v128,
    v128_any_true};

#[no_mangle]
pub fn any_true(a: v128) -> bool {
    v128_any_true(a)
}

see https://godbolt.org/z/333b8n7dY

@alexcrichton
Copy link
Member Author

I've sent #139809 to address that

alexcrichton added a commit to alexcrichton/rust that referenced this issue Apr 14, 2025
This has other warnings if necessary and doesn't need extra warnings
from this FCW.

cc rust-lang#138762
alexcrichton added a commit to alexcrichton/rust that referenced this issue Apr 17, 2025
This commit fixes a false positive of the warning triggered for rust-lang#138762
and the fix is to codify that zero-sized types are "safe" in both the
old and new ABIs.
alexcrichton added a commit to alexcrichton/rust that referenced this issue Apr 17, 2025
This has other warnings if necessary and doesn't need extra warnings
from this FCW.

cc rust-lang#138762
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 17, 2025
…eywiser

Ignore zero-sized types in wasm future-compat warning

This commit fixes a false positive of the warning triggered for rust-lang#138762 and the fix is to codify that zero-sized types are "safe" in both the old and new ABIs.
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 18, 2025
Rollup merge of rust-lang#139498 - alexcrichton:wasm-zst-safe, r=wesleywiser

Ignore zero-sized types in wasm future-compat warning

This commit fixes a false positive of the warning triggered for rust-lang#138762 and the fix is to codify that zero-sized types are "safe" in both the old and new ABIs.
alexcrichton added a commit to alexcrichton/rust that referenced this issue Apr 18, 2025
This has other warnings if necessary and doesn't need extra warnings
from this FCW.

cc rust-lang#138762
alexcrichton added a commit to alexcrichton/rust that referenced this issue Apr 22, 2025
This has other warnings if necessary and doesn't need extra warnings
from this FCW.

cc rust-lang#138762
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ABI Area: Concerning the application binary interface (ABI) C-future-incompatibility Category: Future-incompatibility lints C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC O-wasm Target: WASM (WebAssembly), http://webassembly.org/ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants