Skip to content

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

@vsbogd

Description

@vsbogd

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions