Skip to content

bindgen version must be >= 0.72.1 when LLVM >= 22 #1247

Description

@burakemir

The kernel docs specify at the moment that the min bindgen version is 0.71.1 and min LLVM is 17.0.1.

Now, LLVM 22 has changed to AST representation which required matching changes in bindgen.

Only bindgen 0.72.1 has these changes.
See the bindgen issue: rust-lang/rust-bindgen/issues/3264

If you use libclang at LLVM 22 with a bindgen < 0.72.1, then bindgen generates opaque types for many kernel structs that should have their full fields exposed. The result is build errors when rustc tries to build rust sources.

I observed this with:

  • host system Ubuntu 26.04 LTS "resolute" platform: aarch64
  • slim toolchains "Toolchains with latest LLVM version 7.1 (mainline) | LLVM 22.1.8, Rust 1.97.0"
    • with the instructions (updating PATH, LIBCLANG_PATH)
    • note this uses bindgen version 0.71.1
    • bindgen will load libclang dynamically via LIBCLANG_PATH
  • commit 1229e2e on mainline, 7.2-rc3 or something (I don't think it matters)
  • make rust.config
  • make LLVM=1 rust/

What happens: build errors, fields not found
What expected: clean build

This can be seen as an issue with the slim toolchains that combine LLVM 22 with bindgen 0.71.1 at the moment.

For my build above, everything builds fine when switching to system bindgen (0.72.1) with make LLVM=1 BINDGEN=/usr/bin/bindgen" rust/ where LIBCLANG_PATH uses the LLVM 22 libclang.

Suggested fixes:

  • Upgrade the bindgen in slim toolchains with LLVM 22 to 0.72.1.
  • Possibly updating the docs, or add a specific version check. This is a very opaque build failure.

Transparency:

  • bangings-of-head-against-the-wall was outsourced to GLM-5.1 with thinking level "low" and cost $2.93

(updated: added link to bindgen issue)

Metadata

Metadata

Assignees

No one assigned

    Labels

    • toolchainRelated to `rustc`, `bindgen`, `rustdoc`, LLVM, Clippy...

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions