Skip to content

std compilation error when compiling for wasm32-wasi with -C target-feature=+atomics,+bulk-memory #109727

Closed
@tomaka

Description

@tomaka

In order to reproduce:

cargo new hello-world
cd hello-world
RUSTFLAGS="-C target-features=+atomics,+bulk-memory" cargo +nightly build -Z build-std=std --target=wasm32-wasi

This leads to:

   Compiling std v0.0.0 (/home/tomaka/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std)
error[E0308]: mismatched types
  --> /home/tomaka/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/wasi/../unsupported/once.rs:63:28
   |
63 |                       inner: OnceState {
   |  ____________________________^
64 | |                         poisoned: state == State::Poisoned,
65 | |                         set_state_to: Cell::new(State::Complete),
66 | |                     },
   | |_____________________^ expected `OnceState`, found a different `OnceState`
   |
   = note: `OnceState` and `OnceState` have similar names, but are actually distinct types
note: `OnceState` is defined in module `crate::sys::wasi::once` of the current crate
  --> /home/tomaka/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/wasi/../unsupported/once.rs:8:1
   |
8  | pub struct OnceState {
   | ^^^^^^^^^^^^^^^^^^^^
note: `OnceState` is defined in module `crate::sys_common::once::futex` of the current crate
  --> /home/tomaka/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/once/futex.rs:31:1
   |
31 | pub struct OnceState {
   | ^^^^^^^^^^^^^^^^^^^^

error[E0616]: field `set_state_to` of struct `sys_common::once::futex::OnceState` is private
  --> /home/tomaka/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/wasi/../unsupported/once.rs:69:60
   |
69 | ...p_to = f_state.inner.set_state_to.get();
   |                         ^^^^^^^^^^^^ private field

Some errors have detailed explanations: E0308, E0616.
For more information about an error, try `rustc --explain E0308`.
error: could not compile `std` due to 2 previous errors

This happens with both nightly-2023-03-28 and nightly-2023-02-08.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-wasmTarget: WASM (WebAssembly), http://webassembly.org/T-libsRelevant to the library 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