RISC-V target not passed on correctly to clang
Bindgen fails with hard-to-debug erros (see example) when invoked cargo's target riscv32imac-unknown-none-elf. I can pass a --target=riscv32 flag explicitly passed in via a CFLAG -- but the code for that is described as only a workaround for a long-closed clang issue.
The platform passed in as TARGET from cargo is riscv32imac-unknown-none-elf in those cases, but needs to be passed to clang as riscv32-unknown-none-elf (or riscv32).
I'm not sure whether bindgen is the right place to fix the mismatch between riscv32imac and riscv32, but the workaround I have to use seems to indicate that the TARGET used from cargo is not exactly the value --target needs.
Minimal example (would expect the output of the lower command for the higher command too)
$ touch null.h
$ TARGET=riscv32imac-unknown-none-elf bindgen ./null.h
thread 'main' panicked at 'libclang error; possible causes include:
- Invalid flag syntax
- Unrecognized flags
- Invalid flag arguments
- File I/O errors
If you encounter an error missing from this list, please file an issue or a PR!', src/libcore/option.rs:1036:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.
$ TARGET=riscv32imac-unknown-none-elf bindgen ./null.h -- --target=riscv32-unknown-none-elf
/* automatically generated by rust-bindgen */
Sorry for the lag here. We should probably add the default target detection and such to the libclang search as well (that is, to make it happen sooner).
I think that should fix it.
I just stumbled over the workaround again, and saw that other issues have referenced this now as well.
Is there any update to how this could be achieved, or do you have pointers to where to best fix it?