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

Vivian Wang wangruikang at iscas.ac.cn
Tue Dec 23 04:46:51 PST 2025


On 12/23/25 20:09, Mingcong Bai wrote:
> 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). 

Looks like the rust/ subdir is conditional on CONFIG_RUST, so the
original rust/Makefile didn't have this problem.

Fixing this should be as simple as moving the check into rust/Makefile
instead.

Vivian "dramforever" Wang




More information about the linux-riscv mailing list