[PATCH v5 2/4] rust: generate a fatal error if BINDGEN_TARGET is undefined

Mingcong Bai jeffbai at aosc.io
Tue Dec 23 04:09:30 PST 2025


Hi Asuna,

在 2025/12/4 15:54, Asuna Yang 写道:
> From: Asuna Yang <spriteovo at gmail.com>
> 
> Generate a friendly fatal error if the target triplet is undefined for
> bindgen, rather than having the compiler generate obscure error messages
> during the build stage.
> 
> This piece of code is copied from `scripts/Makefile.clang`.
> 
> Before this commit, error messages might look like:
> 
> error: unknown argument: '-mno-riscv-attribute'
> error: unsupported argument 'medany' to option '-mcmodel=' for target
> 'unknown'
> error: unsupported option '-march=' for target ''
> error: unsupported option '-mno-save-restore' for target ''
> error: unknown target triple 'unknown'
> panicked at bindgen/ir/context.rs:562:15:
> libclang error; possible causes include:
> - Invalid flag syntax
> - Unrecognized flags
> - Invalid flag arguments
> - File I/O errors
> - Host vs. target architecture mismatch
> 
> Acked-by: Miguel Ojeda <ojeda at kernel.org>
> Signed-off-by: Asuna Yang <SpriteOvO at gmail.com>

Unfortunately, this broke build for MIPS and PowerPC, neither of which 
has support for Rust. I also feel as though it might be pointless to ask 
all architecture to define BINDGEN_TARGET, especially when such a target 
specification may not even exist upstream (in Rust or even in LLVM).

As shown in the first patch, the original Makefile did not require this 
definition either (please do enlighten me).

Best Regards,
Mingcong Bai



More information about the linux-riscv mailing list