Help building `rusqlite` for `wasm32-unknown-unknown` with `crane`

I’m using crane to try and build a Rust project that targets wasm32-unknown-unknown and depends on rusqlite.

I was originally depending on a branch from a fork of rusqlite which was targeting wasi and ran into unknown target CPU 'apple-a13' and valid target CPU values are: mvp, bleeding-edge, generic.

Full details on that can be found here

I managed to get past that by setting TARGET_CC = "${}cc";. That at least allowed the project to build (I later encountered some problems at runtime due to the target mismatch) but I’m not sure if that was the right thing to do.

I then discovered this pull request and tried to depend on that because I actually need to target wasm32-unknown-unknown and not wasi. I’m now encountering errors of the nature unknown type name 'u_int' and unknown type name 'u_char'; did you mean 'char'?.

Full details on that can be found here.

I assume I need to provide the correct version of something but this is outside of my experience and I’m quite lost as to where to start.

CARGO_CFG_TARGET_FEATURE = Some("llvm14-builtins-abi") now appears in the output so that may be a clue as to what’s missing or what’s going wrong.

I’ve set up a standalone repo which demonstrates all this at the link below.

Thanks in advance.