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

Cargo error after installing last nightly on aarch64-unknown-linux-musl (Alpine 3.15 based docker container) #121980

Closed
yogh333 opened this issue Mar 4, 2024 · 12 comments

Comments

@yogh333
Copy link

yogh333 commented Mar 4, 2024

Problem

After upgrading to the last nightly rustup update nightly, I have an error when trying to use cargo:

cargo +nightly
Error relocating /opt/rustup/toolchains/nightly-aarch64-unknown-linux-musl/bin/cargo: pthread_getname_np: symbol not found

Same issue with rustc

Steps

No response

Possible Solution(s)

No response

Notes

No response

Version

No response

@yogh333 yogh333 added the C-bug Category: This is a bug. label Mar 4, 2024
@weihanglo
Copy link
Member

Please include the version of the toolchain via cargo -vV, and also the steps to reproduce. Thank you.

@yogh333
Copy link
Author

yogh333 commented Mar 4, 2024

cargo -vV
cargo 1.75.0 (1d8b05cdd 2023-11-20)
release: 1.75.0
commit-hash: 1d8b05cdd1287c64467306cf3ca2c8ac60c11eb0
commit-date: 2023-11-20
host: aarch64-unknown-linux-musl
libgit2: 1.7.1 (sys:0.18.1 vendored)
libcurl: 8.4.0-DEV (sys:0.4.68+curl-8.4.0 vendored ssl:OpenSSL/1.1.1u)
ssl: OpenSSL 1.1.1u  30 May 2023
os: Alpine Linux 3.15.11 [64-bit]

Steps to reproduce:

  • rustup update nightly
  • cargo +nightly -vV => Error relocating /opt/rustup/toolchains/nightly-aarch64-unknown-linux-musl/bin/cargo: pthread_getname_np: symbol not found

@ehuss ehuss transferred this issue from rust-lang/cargo Mar 4, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 4, 2024
@ehuss
Copy link
Contributor

ehuss commented Mar 4, 2024

Transferred to rust-lang/rust, since this was a change via #121666.

cc @ChrisDenton

@ehuss
Copy link
Contributor

ehuss commented Mar 4, 2024

I believe the issue is that pthread_getname_np was added in musl 1.2.3, but that version of Alpine has musl 1.2.2.

@ChrisDenton
Copy link
Contributor

ChrisDenton commented Mar 4, 2024

@ehuss
Copy link
Contributor

ehuss commented Mar 4, 2024

Ah. Yea, the minimum requirements were updated to musl 1.2.3 in Rust 1.71.

Should the minimum version be specified in https://doc.rust-lang.org/nightly/rustc/platform-support.html? cc @wesleywiser if you had a reason to not document that?

@wesleywiser
Copy link
Member

@ehuss No reason not to document it, the platform support doc just slipped my mind when I did the change. I've opened #121994 to document it.

@ehuss
Copy link
Contributor

ehuss commented Mar 5, 2024

Unless someone knows of a way for the binary to produce a better error message when a too-old environment is used for the -linux-musl target, I would suggest this issue be closed as resolved. I'm not familiar with musl or how to handle versioning with its .so.

@saethlin saethlin 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 5, 2024
@wesleywiser
Copy link
Member

I'm not aware of an option here either so I'm going to close this. The proper solution is probably to have musl's loader detect the situation and offer a better error message.

@rochdev
Copy link

rochdev commented Mar 6, 2024

Just want to make sure I properly understand the resolution of this thread since I'm getting the same error. Does this mean that musl 1.1 and earlier 1.2.x versions are no longer supported by Rust and it's now expected that it's not possible to build on these versions?

@wesleywiser
Copy link
Member

Hi @rochdev, Alpine uses a different numbering scheme than musl does. You are correct that Rust expects at least musl 1.2.3 to operate which is available in Alpine 3.16 and newer (Alpine 3.15 and older are EOL).

@kennytm
Copy link
Member

kennytm commented Mar 13, 2024

if you don't need to rely on the default thread name and don't want to edit libstd you can put this somewhere in your code to stub out the missing function.

use std::{ffi::{c_int, c_char}, os::unix::thread::RawPthread};
#[no_mangle]
pub extern "C" fn pthread_getname_np(_thread: RawPthread, _name: *mut c_char, _len: usize) -> c_int {
    13 // EACCES
}

BTW if we are serious about dropping musl 1.2.2 support this cfg can also be changed:

// Note: musl didn't add pthread_getname_np until 1.2.3
all(target_os = "linux", target_env = "gnu"),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants