Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bindgen panics with "header not found" message if Clang version is too old #3171

Open
vsbogd opened this issue Mar 13, 2025 · 0 comments
Open

Comments

@vsbogd
Copy link

vsbogd commented Mar 13, 2025

bindgen crate doesn't clearly states Clang version is too old. Build fails with <header> not found error. See iai-callgrind issue.

Steps to reproduce:

  1. On Ubuntu 18.04 install libclang-6.0-dev, remove all other libclang versions if any
  2. Follow tutorial to create a sample project
  3. Build project using cargo build

Expected result: error message about too old Clang version

Actual result: 'stddef.h' file not found error:

# cargo build
   Compiling t v0.1.0 (/root/t)
error: failed to run custom build command for `t v0.1.0 (/root/t)`

Caused by:
  process didn't exit successfully: `/root/t/target/debug/build/t-fc2313a9f8a632f7/build-script-build` (exit status: 101)
  --- stdout
  cargo:rustc-link-search=/path/to/lib
  cargo:rustc-link-lib=bz2
  cargo:rerun-if-env-changed=TARGET
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS
  cargo:rerun-if-changed=wrapper.h

  --- stderr
  /usr/include/stdio.h:33:10: fatal error: 'stddef.h' file not found

  thread 'main' panicked at build.rs:25:10:
  Unable to generate bindings: ClangDiagnostic("/usr/include/stdio.h:33:10: fatal error: 'stddef.h' file not found\n")
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Upgrading Clang to version 9 solves the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant