package/rust-bindgen: add runtime host-clang dependency

According to the official requirements, bindgen needs libclang to
parse C/C++ headers. libclang is loaded at runtime by bindgen, which
is why we didn't notice any build issue. However, using bindgen on a
simple header file blows up:

thread 'main' panicked at bindgen/lib.rs:616:27:
Unable to find libclang: "couldn't find any valid shared libraries matching: ['libclang.so', 'libclang-*.so', 'libclang.so.*', 'libclang-*.so.*'], s
et the `LIBCLANG_PATH` environment variable to a path where one of these files can be found (invalid: [])"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

So far, bindgen was only used by mesa3d, and it turns out that mesa3d
also depends on clang, which pulls in host-clang, so the problem was
not visible. However, as we're about to use bindgen for other
things (namely Rust support in Linux), this issue needs to be fixed.

See:

  https://rust-lang.github.io/rust-bindgen/requirements.html

Signed-off-by: El Mehdi YOUNES <elmehdi.younes@smile.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
El Mehdi YOUNES
2025-08-08 15:31:08 +02:00
committed by Thomas Petazzoni
parent 2f218b1c29
commit 34ed3bbf0a

View File

@@ -9,6 +9,11 @@ RUST_BINDGEN_SITE = $(call github,rust-lang,rust-bindgen,v$(RUST_BINDGEN_VERSION
RUST_BINDGEN_LICENSE = BSD-3-clause
RUST_BINDGEN_LICENSE_FILES = LICENSE
# This is actually a runtime dependency (bindgen loads libclang at
# runtime), but as it's a host package, we have no other option but to
# handle it as a build dependency.
HOST_RUST_BINDGEN_DEPENDENCIES = host-clang
# The Cargo.toml at the root directory is a "virtual manifest".
# Since we only want to build and install bindgen use the Cargo.toml
# from the bindgen-cli subdirectory.