cargo: i686-unknown-linux-gnu/bin/cargo: error while loading shared libraries: libatomic.so.1
Maintainer’s note:
In Rust 1.87, Cargo in the official Rust distribution will have a hard dependency on libatomic on 32-bit platforms.
For more, see
- This comment for how to fix the error.
- This comment for the previous investigation.
- https://github.com/rust-lang/cargo/pull/15232
When running cargo in a quay.io/pypa/manylinux2014_i686:latest Docker container, it gives the following error
/root/.rustup/toolchains/nightly-i686-unknown-linux-gnu/bin/cargo: error while loading shared libraries: libatomic.so.1: cannot open shared object file: No such file or directory
Is libatomic.so.1 a hard requirement for cargo now?
Meta
rustc --version --verbose:
rustc 1.78.0-nightly (d18480b84 2024-03-04)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 24 (14 by maintainers)
Commits related to this issue
- chore: downgrade to openssl v1.1.1 (again) See rust-lang/cargo#13546 and sfackler/rust-openssl#2163 — committed to weihanglo/cargo by weihanglo 3 years ago
- chore: downgrade to openssl v1.1.1 (again) See rust-lang#13546 — committed to weihanglo/cargo by weihanglo 3 years ago
- Auto merge of #13731 - weihanglo:openssl, r=epage chore: downgrade to openssl v1.1.1 (again) Accidentally updated by <https://github.com/rust-lang/cargo/pull/13674> See https://github.com/rust-lang... — committed to rust-lang/cargo by bors 3 years ago
- Auto merge of #14391 - weihanglo:downgrade-openssl, r=epage chore: downgrade to openssl v1.1.1 (again) It happened again in <https://github.com/rust-lang/cargo/pull/14299>. See <https://github.com/r... — committed to rust-lang/cargo by bors 2 years ago
- chore: downgrade to openssl v1.1.1 (again) See rust-lang/cargo#13546 and sfackler/rust-openssl#2163 — committed to charmitro/cargo by weihanglo 3 years ago
- # This is a combination of 3 commits. # This is the 1st commit message: chore: remove x86 support (https://github.com/rust-lang/cargo/issues/13546) # The commit message #2 will be skipped: # ci: tr... — committed to aqora-io/cli by Angel-Dijoux 2 years ago
- chore: remove x86 support (https://github.com/rust-lang/cargo/issues/13546) — committed to aqora-io/cli by Angel-Dijoux 2 years ago
- chore: remove x86 support (https://github.com/rust-lang/cargo/issues/13546) — committed to aqora-io/cli by Angel-Dijoux 2 years ago
- chore: remove x86 support (https://github.com/rust-lang/cargo/issues/13546) — committed to aqora-io/cli by Angel-Dijoux 2 years ago
- chore: remove x86 support (https://github.com/rust-lang/cargo/issues/13546) — committed to aqora-io/cli by Angel-Dijoux 2 years ago
- chore: remove x86 support (https://github.com/rust-lang/cargo/issues/13546) — committed to aqora-io/cli by Angel-Dijoux 2 years ago
- feat: init a Git repo for default use_case template (#97) * feat: init a repo for default use_case template * fix: pr suggestions * feat: create repo after cloning template & commit after tests... — committed to aqora-io/cli by Angel-Dijoux 2 years ago
- chore: depend on openssl-sys to correctly pin its version (#15224) ### What does this PR try to resolve? From https://github.com/rust-lang/cargo/issues/13546#issuecomment-2676629906 > This was an o... — committed to rust-lang/cargo by ehuss 2 years ago
- chore: bump openssl to v3 (#15232) ### What does this PR try to resolve? After this, Cargo in the official Rust distribution will have a hard dependency on libatomic on 32-bit platforms, until upstr... — committed to rust-lang/cargo by epage 2 years ago
The Cargo team has discussed this issue in today’s meeting. The root cause is convoluted, but can be seen as a bad interaction between Clang not providing built-in libatomic, and a bug in OpenSSL v3 that it doesn’t use aligned intergers on 32-bit platforms.
Folks on Zulip have evaluated some possible solutions, and agree with that the most straightforward solution is requiring libatomic on 32-bit platforms when running Cargo.
libatomic is generally available in major Linux distributions. If you’re seeing an error like this:
You could install libatomic through your system package manager. See the list of libatomic on every distros: https://pkgs.org/search/?q=libatomic.
Better get it reverted before it reaches stable I think?
I don’t think so.
openssl@1.0.66has a hard requirement of OpenSSL v3, and just one comment above you can see how convoluted it is for the bump (or how dumb I am 😞).In Cargo we only call
openssl::version::version(). None of our dependencies require openssl (only openssl-sys through libgit2-sys/libssh2-sys), so I doubt Cargo is affected.is it possible to temporarily pin openssl to 1.0.66? openssl has a vulnerability prior to 1.0.66, i don’t know if this affect the cargo code base.
Let me jot down what I’ve found so far, for building OpenSSL v3.4[^0] into Cargo with rust-lang CI.
cargoexecutable that dynamically links tolibatomic.so.1. Thelddoutput looks like On some distributions there is no libatomic available, so it failed.-DBROKEN_CLANG_ATOMICSin openssl-src build didn’t help.-latomic(cargo:rustc-link-lib=atomic)from rust-openssl didn’t help.cargofrom thedist-x86_64-linuxjob doesn’t dynamically link to libatomic at all. The ldd output is likeCCtogcceliminates the dynamic links. The ldd output looks likeThe potential reason is that we set
CCin the dist-i686-linux job image, so it builds acargolinking tolibatomic.soinstead of statically linkage. Andclangdoesn’t provide built-in atomic lib, according to its doc. It has also be discussed in https://github.com/llvm/llvm-project/issues/73361 and https://github.com/mstorsjo/llvm-mingw/issues/384. I’ve tried adding-DCOMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=OFF[^1] and-DCOMPILER_RT_USE_ATOMIC_LIBRARY=ONwhen bootstrapping the firstclangin the dist-i686-linudex job. Nothing changed.It has been more than one year since OpenSSL v1.1.1 EOL (2023-09-11), we should take action on this, either try harder upgrading to OpenSSL v3, or find an alternative like rustls or aws-lc. See also how rustup struggles to upgrade OpenSSL https://github.com/rust-lang/rustup/issues/3790.
[^0]:
openssl@0.10.68,openssl-sys@0.9.104, andopenssl-src@300.4.0+3.4.0respectively [^1]: requires gcc10 to fix preprocessor errors and-DCOMPILER_RT_HAS_WBUILTIN_DECLARATION_MISMATCH_FLAG=OFFto surpress some errors.@messense should have been fixed via rust-lang/cargo#14391 and rust-lang/rust#129066. (Sorry I should have paid more attention to manual
cargo update🙇🏾♂️ )This seems to happen again in
rust version 1.79.0-nightly (8b2459c1f 2024-04-09)