Skip to content

autoPatchelfHook fails badly with stdenvNoCC #137982

@nomeata

Description

@nomeata

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions