Skip to content

RISC-V target not passed on correctly to clang #1555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
chrysn opened this issue Apr 29, 2019 · 2 comments
Open

RISC-V target not passed on correctly to clang #1555

chrysn opened this issue Apr 29, 2019 · 2 comments

Comments

@chrysn
Copy link
Contributor

chrysn commented Apr 29, 2019

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 */
@emilio
Copy link
Contributor

emilio commented May 17, 2019

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.

chrysn added a commit to chrysn-pull-requests/RIOT that referenced this issue Jan 14, 2022
This contains a workaround for
rust-lang/rust-bindgen#1555 (withouot which
bindgen would fail, with little information helping remedy the cause)
@chrysn
Copy link
Contributor Author

chrysn commented Nov 24, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants