Getting `llvm-config --bindir` to point a joint binary folder of LLVM

Hi all,

I’m trying to build https://github.com/AFLplusplus/AFLplusplus with lto support; however while it builds it uses llvm-config --bindir to find the directory of the binaries, and expects to find ld.lld and clang here. The problem is that the binaries in nixos is not in the same folder. I have been trying different things, with very little success. My current build script looks like this:

{ fetchFromGitHub, makeWrapper, clang12Stdenv, llvmPackages_12, python3, automake, autoconf, which }:
clang12Stdenv.mkDerivation rec {
  pname = "aflplusplus";
  version = "4.02c";
  src = fetchFromGitHub {
    owner = "AFLplusplus";
    repo = "AFLplusplus";
    rev = version;
    sha256 = "sha256-H0H2vJFKYEj+UFfoLzMkxu/ScCmpx40IYYNpcm42IRM=";
  };
  nativeBuildInputs = [
    which
    makeWrapper
    llvmPackages_12.llvm
    llvmPackages_12.bintools
    automake
    autoconf
  ];
  buildInputs = [
    (python3.withPackages (p: with p; [ setuptools ]))
  ];
  makeFlags = [ "PREFIX=$(out)" "STATIC=1" ];
  buildPhase = ''
    # set -x 
    # llvm-config --bindir 
    # which ld.lld
    # which clang
    # to investigate the problem 
    make all
  '';

  postInstall = '' 
    patchShebangs $out/bin
  '';
}

Which results in that the LTO version is not built, because it fails some checks:

GNUmakefile.llvm:126: we have trouble finding clang - llvm-config is not helping us
GNUmakefile.llvm:141: we have trouble finding clang++ - llvm-config is not helping us
GNUmakefile.llvm:224: ld.lld not found, cannot enable LTO mode

Reading the file we see that it tries to lookup ld.lld in the LLVM_BINDIR

Which it tries to find using llvm-config:

Any help would be greatly appreciated!

Since you’ve already found where it tries to set the paths, why not fix those lines with a patchPhase?

Thanks, I tried that shortly after posting this, but the LLVM_BINDIR is also passed directly to the tool later, I’m assuming to give it access to “all” the LLVM tools.

Hosted by Flying Circus.