Override LLVM version when cross compiling to WASI


I am using pkgsCross.wasi32.stdenv to build a C project for WASI and it seems to work fine. However, to get a DWARF fix (as mentioned here: https://github.com/bytecodealliance/wasmtime/issues/1613) that is in LLVM 10 I have been trying to find a way to override the stdenv.

I tried this:

nix-build -A pkgsCross.wasi32.llvmPackages_10.stdenv '<nixpkgs>'

but that fails with:

configure: error: /nix/store/k89nm2jva0qmvd970f84wq2iq1iwm9bs-bash-4.4-p23/bin/bash ./config.sub wasm32-unknown-wasi failed
builder for '/nix/store/brq8dca0nzrgwj68ifxdpg69g1qqpgxx-wasm32-unknown-wasi-binutils-2.31.1.drv' failed with exit code 1

When comparing with the requisites between pkgsCross.wasi32.llvmPackages_10.stdenv and pkgsCross.wasi32.stdenv the latter seems to use the llvm-binutils instead. My question is if pkgsCross..llvmPackages_X.stdenv` is supposed to work and otherwise what would be the best way to override the LLVM version used in a WASI cross toolchain?

1 Like

Ah, saw now that I should prob override CC with pkgsCross.wasi32.buildPackages.llvmPackages_10.lldClang, however that fails to build libc+±abi with a message mentioning -lunwind (which should not be there).

Will see if I can figure out the error