[PATCH v6 4/4] RISC-V: handle extension configs for bindgen, re-enable gcc + rust builds

Nathan Chancellor nathan at kernel.org
Thu Jan 29 15:25:35 PST 2026


On Thu, Jan 29, 2026 at 01:49:56PM +0000, Charalampos Mitrodimas wrote:
> I'm under the impression that the `!RUST ||` guard here doesn't
> actually prevent the `$(bindgen-backend-option,...)` call from being
> executed. `$(...)` shell expansions should happen during the textual
> substitution phase, before symbol dependency evaluation occurs, check
> documentation at kconfig-macro-language.rst lines 228-229.
> 
> I did this test:
>   $ cat /tmp/fake_bindgen
>     #!/bin/bash
>     echo "[BINDGEN INVOKED] $(date '+%H:%M:%S') args: $@" >> /tmp/bindgen_calls.log
>     # Call real bindgen
>     exec /home/charmitro/.cargo/bin/bindgen "$@"
> 
>   $ make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- BINDGEN=/tmp/fake_bindgen defconfig
>     HOSTCC  scripts/basic/fixdep
>     ...
>   *** Default configuration is based on 'defconfig'
>   #
>   # configuration written to .config
>   #
> 
>   $ linux git:(master) rg CONFIG_RUST .config
>   ...
>   283:# CONFIG_RUST is not set
>   ...
> 
>   $ cat /tmp/bindgen_calls.log
>   [BINDGEN INVOKED] 15:44:44 args: --version workaround-for-0.69.0
>   [BINDGEN INVOKED] 15:44:44 args: ./scripts/rust_is_available_bindgen_libclang.h
>   [BINDGEN INVOKED] 15:44:44 args: --version workaround-for-0.69.0
>   [BINDGEN INVOKED] 15:44:44 args: /dev/null -- -x c --target=riscv64-linux-gnu -mabi=lp64 -march=rv64imv
>   [BINDGEN INVOKED] 15:44:44 args: /dev/null -- -x c --target=riscv64-linux-gnu -mabi=ilp32 -march=rv32imv
>   [BINDGEN INVOKED] 15:44:44 args: /dev/null -- -x c --target=riscv64-linux-gnu -mabi=lp64 -march=rv64ima_zabha
>   [BINDGEN INVOKED] 15:44:44 args: /dev/null -- -x c --target=riscv64-linux-gnu -mabi=ilp32 -march=rv32ima_zabha
>   [BINDGEN INVOKED] 15:44:45 args: /dev/null -- -x c --target=riscv64-linux-gnu -mabi=lp64 -march=rv64ima_zacas
>   [BINDGEN INVOKED] 15:44:45 args: /dev/null -- -x c --target=riscv64-linux-gnu -mabi=ilp32 -march=rv32ima_zacas
>   [BINDGEN INVOKED] 15:44:45 args: /dev/null -- -x c --target=riscv64-linux-gnu -mabi=lp64 -march=rv64ima_zbb
>   [BINDGEN INVOKED] 15:44:45 args: /dev/null -- -x c --target=riscv64-linux-gnu -mabi=ilp32 -march=rv32ima_zbb
>   [BINDGEN INVOKED] 15:44:45 args: /dev/null -- -x c --target=riscv64-linux-gnu -mabi=lp64 -march=rv64ima_zba
>   [BINDGEN INVOKED] 15:44:45 args: /dev/null -- -x c --target=riscv64-linux-gnu -mabi=ilp32 -march=rv32ima_zba
>   [BINDGEN INVOKED] 15:44:45 args: /dev/null -- -x c --target=riscv64-linux-gnu -mabi=lp64 -march=rv64ima_zbc
>   [BINDGEN INVOKED] 15:44:46 args: /dev/null -- -x c --target=riscv64-linux-gnu -mabi=ilp32 -march=rv32ima_zbc
>   [BINDGEN INVOKED] 15:44:46 args: /dev/null -- -x c --target=riscv64-linux-gnu -mabi=lp64 -march=rv64ima_zbkb
>   [BINDGEN INVOKED] 15:44:46 args: /dev/null -- -x c --target=riscv64-linux-gnu -mabi=ilp32 -march=rv32ima_zbkb
>   [BINDGEN INVOKED] 15:44:46 args: /dev/null -- -x c --target=riscv64-linux-gnu -mabi=lp64 -march=rv64ima_zicsr_zifencei
>   [BINDGEN INVOKED] 15:44:46 args: /dev/null -- -x c --target=riscv64-linux-gnu -mabi=ilp32 -march=rv32ima_zicsr_zifencei
> 
> So, CONFIG_RUST not set, yet bindgen was invoked. Not sure if that is
> intentional though.

While I have only recently adopted Kconfig, the section you pointed to
in kconfig-macro-language.rst makes it seem like this is expected. I
read that to mean all shell commands are going to be evaluated and
effectively turned into "y" and "n" before dependencies are evaluated.
You can test this with something like:

if RUST

config RUST_FOOBAR
    def_bool $(bindgen-backend-option,-obviously-not-supported)

endif

added in init/Kconfig and running your fake bindgen.

While this is obviously a little wasteful, I suspect this drastically
simplifies the shell commands part of Kconfig for no change in runtime
behavior.  The way that the dependency is currently written ensures that
either the result of bindgen-backend-option matters for the sake of
saying an extension is fully supported by the toolchain (when Rust is
enabled) or it does not matter (because Rust is not enabled).

Cheers,
Nathan



More information about the linux-riscv mailing list