Skip to content
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

Function get_name could not be found for wasm::thread::Thread #121932

Closed
Iansa9 opened this issue Mar 3, 2024 · 3 comments · Fixed by #121933
Closed

Function get_name could not be found for wasm::thread::Thread #121932

Iansa9 opened this issue Mar 3, 2024 · 3 comments · Fixed by #121933
Labels
A-thread Area: `std::thread` O-wasm Target: WASM (WebAssembly), http://webassembly.org/ T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@Iansa9
Copy link
Contributor

Iansa9 commented Mar 3, 2024

Compilation of any code using the atomics feature flag for the wasm target fails when building the std library due to the following error:

No function or associated item named get_name found for struct pal::wasm::thread::Thread in the current scope.

I tried this code:

fn main() {
    println!("Hello, world!");
}

With these flags enabled

$env:RUSTFLAGS='-C target-feature=+atomics'
cargo build --target wasm32-unknown-unknown -Z build-std=std

I expected to see this happen:

Compilation succesful
Finished dev [unoptimized + debuginfo] target(s) in 0.59s

Instead, this happened:

error[E0599]: no function or associated item named `get_name` found for struct `pal::wasm::thread::Thread` in the current scope        
  --> \toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys_common\thread_info.rs:28:88
   |
28 |                     thread_info.thread.get_or_init(|| Thread::new(sys::thread::Thread::get_name()));
   |                                                                                        ^^^^^^^^ function or associated item not found in `Thread`
   |
  ::: \toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\pal\wasm\atomics\thread.rs:7:1
   |
7  | pub struct Thread(!);
   | ----------------- function or associated item `get_name` not found for this struct
   |
error: could not compile `std` (lib) due to 1 previous error

Meta

rustc --version --verbose:

rustc 1.78.0-nightly (5119208fd 2024-03-02)
binary: rustc
commit-hash: 5119208fd78a77547c705d1695428c88d6791263
commit-date: 2024-03-02
host: x86_64-pc-windows-msvc
release: 1.78.0-nightly
LLVM version: 18.1.0
Backtrace

Backtrace doesn't seem to add useful information.

@Iansa9 Iansa9 added the C-bug Category: This is a bug. label Mar 3, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 3, 2024
@Iansa9
Copy link
Contributor Author

Iansa9 commented Mar 3, 2024

While playing around locally, adding this, in thread.rs fixes the compiler error, not sure if there are undesired side effects.

use crate::ffi::CString;
...
impl Thread {
    ...
    pub fn get_name() -> Option<CString> { None }
    ...
}

@ChrisDenton
Copy link
Member

That looks great! Would you be willing to submit a PR?

@Iansa9
Copy link
Contributor Author

Iansa9 commented Mar 3, 2024

Definitely!

@Noratrieb Noratrieb added O-wasm Target: WASM (WebAssembly), http://webassembly.org/ T-libs Relevant to the library team, which will review and decide on the PR/issue. A-thread Area: `std::thread` and removed C-bug Category: This is a bug. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 3, 2024
@ChrisDenton ChrisDenton linked a pull request Mar 3, 2024 that will close this issue
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Mar 3, 2024
…strieb

Add missing get_name for wasm::thread.

Fixing rust-lang#121932 by implementing `get_name` in `wasm::thread::Thread`.
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 3, 2024
Rollup merge of rust-lang#121933 - Iansa9:thread-name-wasm-fix, r=Nilstrieb

Add missing get_name for wasm::thread.

Fixing rust-lang#121932 by implementing `get_name` in `wasm::thread::Thread`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-thread Area: `std::thread` O-wasm Target: WASM (WebAssembly), http://webassembly.org/ T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants