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

From: Mingcong Bai

Date: Tue Dec 23 2025 - 07:18:17 EST


Hi Asuna,

在 2025/12/4 15:54, Asuna Yang 写道:
From: Asuna Yang <spriteovo@xxxxxxxxx>

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@xxxxxxxxxx>
Signed-off-by: Asuna Yang <SpriteOvO@xxxxxxxxx>

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