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

autoPatchelfHook fails badly with stdenvNoCC #137982

Closed
nomeata opened this issue Sep 15, 2021 · 5 comments
Closed

autoPatchelfHook fails badly with stdenvNoCC #137982

nomeata opened this issue Sep 15, 2021 · 5 comments
Labels
0.kind: bug Something is broken

Comments

@nomeata
Copy link
Contributor

nomeata commented Sep 15, 2021

I was trying to use autoPatchelfHook like this:

{ rev    ? "4c2e7becf1c942553dadd6527996d25dbf5a7136"
, sha256 ? "10dzi5xizgm9b3p5k963h5mmp0045nkcsabqyarpr7mj151f6jpm"
, pkgs   ? import (builtins.fetchTarball {
    url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
    inherit sha256; }) {
    config.allowUnfree = true;
    config.allowBroken = false;
  }
}:

rec {

dfx = pkgs.stdenvNoCC.mkDerivation rec {
  pname = "dfx";
  version = "0.8.1";

  src = fetchTarball {
    url = "https://sdk.dfinity.org/downloads/dfx/${version}/x86_64-linux/dfx-${version}.tar.gz";
    sha256 = "1ifc7n9kl4rzvhfs9xbbaj9wsnhw0wzlnyjswcgl38mljvkxxvw2";
  };

  nativeBuildInputs = [
    pkgs.autoPatchelfHook
  ];

  phases = [ "unpackPhase" "installPhase" "fixupPhase" ];

  installPhase = ''
    mkdir -p $out/bin
    cp -v dfx $out/bin/
  '';
};

shell = pkgs.mkShell {
  buildInputs = [ dfx ];
};

}

but it failed in a not nice way:

automatically fixing dependencies for ELF files
/nix/store/a16wkyq2b2h9x70m37s5v7xq0nr774md-auto-patchelf-hook/nix-support/setup-hook: line 220: -l: command not found
builder for '/nix/store/qwa62iq2932rd1p6wljld60v0g2rn8mh-dfx-0.8.1.drv' failed with exit code 127

Looking at the setup hook it seems that readelf is missing. Changing stdenvNoCC to stdenv fixed it.

I guess autoPatchelfHook should either pull in the tools it needs, or they definitely need to be picked up from the current build environment, maybe that situation can be detected and a helpful error message produced? @DavHau maybe?

@nomeata nomeata added the 0.kind: bug Something is broken label Sep 15, 2021
@DavHau
Copy link
Member

DavHau commented Sep 15, 2021

Thanks, I just tested and even after adding binutils which contains readelf, it fails on another line.
autoPatchelfHook seem to depend on CC. It fails on the last line here

autoPatchelfFile() {
    local dep rpath="" toPatch="$1"

    local interpreter
    interpreter="$(< "$NIX_CC/nix-support/dynamic-linker")"

@symphorien
Copy link
Member

cc @impl maybe

@impl
Copy link
Member

impl commented Sep 17, 2021

I added another small commit (3729409) to #137886 that I believe should fix this. @DavHau @nomeata feel free to give it a try and see if it works for you.

@impl
Copy link
Member

impl commented Oct 7, 2021

@nomeata, this change has hit unstable since a few days ago. When you get a moment, could you verify that what you tried originally is now working? Thanks!

@nomeata
Copy link
Contributor Author

nomeata commented Oct 8, 2021

Yup, seems to work, thanks!

@nomeata nomeata closed this as completed Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

No branches or pull requests

4 participants