A Rust toolchain downloaded through the rustup
package installs a rust-lld
binary that lacks libstdc++.so.6
. This doesn't seem to be a problem when using cargo
or rustc
with default options, but breaks rustc
when targeting WASM.
rustup
:nix-shell -iA rustup
rustup
to install a toolchain, nightly for example:rustup toolchain install nightly-x86_64-unknown-linux-gnu
ldd ~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/rust-lld
libstdc++.so.6 => not found
)rust-lld: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
"x86_64-linux"
Linux 4.14.66, NixOS, 18.03.133231.01f5e794913 (Impala)
yes
no
nix-env (Nix) 2.0.4
"nixos-18.03.133231.01f5e794913, unstable-19.03pre152634.218ce4de508"
"nixpkgs"
/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs
.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin
to set-interpreter, but not running on the rustlib
bin directory, and the file in there needs a different patchelf invocation because it links libstdc++.Seconded! This affects me both when compiling WASM and RISC-V.
Oddly, it does appear as though rust-lld is being having ld linked to the nix store, but libstdc++.so.6
is still a problem.
Even more bizarrely, the IDEA IDE doesn't seem to have that problem, but instead has trouble finding the linker script.
Also hit the issue with wasm-pack
.
Found a workaround, setting LD_LIBRARY_PATH
that points to libstdc++.so.6
. Here my shell.nix
to work with wasm-pack
:
with import <nixpkgs> {};
let src = fetchFromGitHub {
owner = "mozilla";
repo = "nixpkgs-mozilla";
rev = "b9c99d043b1cb55ee8c08265223b7c35d687acb9";
sha256 = "0akyhdv5p0qiiyp6940k9bvismjqm9f8xhs0gpznjl6509dwgfxl";
};
in
with import "${src.out}/rust-overlay.nix" pkgs pkgs;
pkgs.stdenv.mkDerivation rec {
name = "dev-env";
buildInputs = with pkgs; [
#latest.rustChannels.nightly.rust
rustup
# Other packages
pkgconfig
openssl
git
nodejs-8_x
];
LD_LIBRARY_PATH="${stdenv.cc.cc.lib}/lib64:$LD_LIBRARY_PATH";
}
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
Hello, I'm a bot and I thank you in the name of the community for opening this issue.
To help our human contributors focus on the most-relevant reports, I check up on old issues to see if they're still relevant. This issue has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human.
The community would appreciate your effort in checking if the issue is still valid. If it isn't, please close it.
If the issue persists, and you'd like to remove the stale label, you simply need to leave a comment. Your comment can be as simple as "still important to me". If you'd like it to get more attention, you can ask for help by searching for maintainers and people that previously touched related code and @ mention them in a comment. You can use Git blame or GitHub's web interface on the relevant files to find them.
Lastly, you can always ask for help at our Discourse Forum or at #nixos' IRC channel.
I believe this was fixed in #91327.
Most helpful comment
Found a workaround, setting
LD_LIBRARY_PATH
that points tolibstdc++.so.6
. Here myshell.nix
to work withwasm-pack
: