Nixpkgs: rustup not patchelfing all its downloaded binaries

Created on 26 Sep 2018  路  7Comments  路  Source: NixOS/nixpkgs

Issue description

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.

Steps to reproduce

  1. Install rustup:
    nix-shell -iA rustup
  2. Use rustup to install a toolchain, nightly for example:
    rustup toolchain install nightly-x86_64-unknown-linux-gnu
  3. Observe the missing library:
    ldd ~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/rust-lld
    (Interesting part of output is: libstdc++.so.6 => not found)
  4. (Optional): add WASM target to rustup, try to cross-compile something, get a loquacious error that ends with rust-lld: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory

Technical details

  • system: "x86_64-linux"
  • host os: Linux 4.14.66, NixOS, 18.03.133231.01f5e794913 (Impala)
  • multi-user?: yes
  • sandbox: no
  • version: nix-env (Nix) 2.0.4
  • channels(root): "nixos-18.03.133231.01f5e794913, unstable-19.03pre152634.218ce4de508"
  • channels(kaz): "nixpkgs"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs
stale

Most helpful comment

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";
}

All 7 comments

30941 patched rustup to patchelf its downloads; it's patching everything installed to .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:

https://discourse.nixos.org/t/updates-to-my-nur-repo/6270/1

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

teto picture teto  路  3Comments

grahamc picture grahamc  路  3Comments

chris-martin picture chris-martin  路  3Comments

sid-kap picture sid-kap  路  3Comments

copumpkin picture copumpkin  路  3Comments