Compiling an llvm program

I’m trying to compile a rust program ( that uses llvm-sys package. I came up with this derivation:

{pkgs ? (import <nixpkgs> {}).pkgsi686Linux}:

pkgs.mkShell (with pkgs; {

  nativeBuildInputs = [cmake pkgconfig];

  buildInputs = [

rustc and cargo are in global environment, version 1.43.

Running a cargo build with this derivation results in pages of linker error. This is the tail of error output:

          (.text._ZN4llvm25PhysicalRegisterUsageInfo16doInitializationERNS_6ModuleE+0x82): undefined reference to `operator new(unsigned long)'
          /nix/store/k657hq8xdx38k8y12fdsi8kljs76hbdz-binutils-2.31.1/bin/ld: /mnt/DATA/src/bfc/target/debug/deps/libllvm_sys-96db04a0640c5c87.rlib(RegisterUsageInfo.cpp.o):(.text._ZN4llvm15callDefaultCtorINS_25PhysicalRegisterUsageInfoEEEPNS_4PassEv[_ZN4llvm15callDefaultCtorINS_25PhysicalRegisterUsageInfoEEEPNS_4PassEv]+0x7): more undefined references to `operator new(unsigned long)' follow
          /nix/store/k657hq8xdx38k8y12fdsi8kljs76hbdz-binutils-2.31.1/bin/ld: /mnt/DATA/src/bfc/target/debug/deps/bfc-2db857cbd7f0b5b7.10s17xnpywxk4sys.rcgu.o: file class ELFCLASS64 incompatible with ELFCLASS32
          /nix/store/k657hq8xdx38k8y12fdsi8kljs76hbdz-binutils-2.31.1/bin/ld: final link failed: file in wrong format
          collect2: error: ld returned 1 exit status

How do I compile this llvm program on nixos?

Why are you using .pkgsi686Linux? Does it work without it?

on unstable, I was able to do

$ nix-shell -p cargo -p llvm_8 -p libxml2 --run "cargo build"
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s

successfully using the nixpkgs-unstable channel.

Most likely the libcxx is causing you issues?

you may also want to try setting the target, I think it’s --target=x86-linxu-gcc, probably wrong