nixpkgs-esp-dev icon indicating copy to clipboard operation
nixpkgs-esp-dev copied to clipboard

Cannot execute esp-clang/bin/clang since the dynamic loader or dynamic library is missing

Open oddlama opened this issue 4 months ago • 0 comments

It looks like $IDF_PATH/esp-clang/bin/clang is not patchelf-ed or missing a dynamic lib that is missing in the build sandbox. I was only able to get it to work in devshells on systems that use nix-ld as otherwise the dynamic loader or one of the required libs is missing.

The esp-clang tool is required when compiling esp-idf-sys (the rust crate). I've made a minimal example to reproduce this by executing the binary in a sandboxed mkDerivation:

test.nix

let
  nixpkgs-esp-dev = builtins.fetchGit {
    url = "https://github.com/mirrexagon/nixpkgs-esp-dev.git";
    rev = "52a23afb15a1643a3dbeeb963097945a3f35b0fb";
  };

  pkgs = import <nixpkgs> { overlays = [ (import "${nixpkgs-esp-dev}/overlay.nix") ]; };
in
pkgs.stdenv.mkDerivation {
  pname = "esp-project";
  version = "1.0.0";

  buildInputs = [ pkgs.esp-idf-full ];

  dontUseCmakeConfigure = true;
  dontUseNinjaBuild = true;
  dontUseNinjaInstall = true;
  dontUseNinjaCheck = true;

  # Just an empty folder
  src = pkgs.writeTextDir "dummy" "";

  buildPhase = ''
    $IDF_PATH/esp-clang/bin/clang
  '';
}

output of nix-build test.nix

building '/nix/store/1h9mmlvkd3qwc65rbn3ka5f8f6xvbmc6-esp-project-1.0.0.drv'...
Running phase: unpackPhase
unpacking source archive /nix/store/mwbx2w30l0pb7v60fsyzxsxyvy60yfmi-dummy
source root is dummy
Running phase: patchPhase
Running phase: updateAutotoolsGnuConfigScriptsPhase
Running phase: configurePhase
no configure script, doing nothing
Running phase: buildPhase
/nix/store/nbrif411qgsj1h5r7rlgxxm140aj58dz-stdenv-linux/setup: line 1768: /nix/store/jxpii7sp9i6m9r3k1xxjq6v4kqzk576v-esp-idf-v5.5/esp-clang/bin/clang: No such file or directory

In case anyone is unfamiliar, the no such file or directory is unfortunately a super bad error message - it actually refers to one of the dynamic libraries or the loader itself not being found, not to the executable. Running ldd /nix/store/jxpii7sp9i6m9r3k1xxjq6v4kqzk576v-esp-idf-v5.5/esp-clang/bin/clang shows:

	linux-vdso.so.1 (0x00007f1d1fd7b000)
	libpthread.so.0 => /nix/store/lmn7lwydprqibdkghw7wgcn21yhllz13-glibc-2.40-66/lib/libpthread.so.0 (0x00007f1d1896d000)
	libdl.so.2 => /nix/store/lmn7lwydprqibdkghw7wgcn21yhllz13-glibc-2.40-66/lib/libdl.so.2 (0x00007f1d18968000)
	libz.so.1 => not found
	libstdc++.so.6 => not found
	libm.so.6 => /nix/store/lmn7lwydprqibdkghw7wgcn21yhllz13-glibc-2.40-66/lib/libm.so.6 (0x00007f1d18880000)
	libgcc_s.so.1 => /nix/store/n9mggs3wskqv3vqd4xn8hbq2yzcf2z1d-xgcc-14.3.0-libgcc/lib/libgcc_s.so.1 (0x00007f1d18850000)
	libc.so.6 => /nix/store/lmn7lwydprqibdkghw7wgcn21yhllz13-glibc-2.40-66/lib/libc.so.6 (0x00007f1d18647000)
	/lib64/ld-linux-x86-64.so.2 => /nix/store/lmn7lwydprqibdkghw7wgcn21yhllz13-glibc-2.40-66/lib64/ld-linux-x86-64.so.2 (0x00007f1d1fd7d000)

Not sure which one is missing in the build sandbox, this output is from my normal shell.

oddlama avatar Aug 23 '25 10:08 oddlama