diff --git a/bindgen/lib.rs b/bindgen/lib.rs index 572e1d4598..8378695499 100644 --- a/bindgen/lib.rs +++ b/bindgen/lib.rs @@ -65,6 +65,7 @@ use ir::item::Item; use options::BindgenOptions; use parse::ParseError; +use clang_sys::Version; use std::borrow::Cow; use std::collections::hash_map::Entry; use std::env; @@ -744,6 +745,17 @@ impl Bindings { ) -> Result { ensure_libclang_is_loaded(); + match clang_sys::get_library().unwrap().version() { + None => { + warn!("Could not detect a Clang version, make sure you are using libclang 9 or newer"); + } + Some(version) => { + if version < Version::V9_0 { + warn!("Detected Clang version {version:?} which is unsupported and can cause invalid code generation, use libclang 9 or newer"); + } + } + } + #[cfg(feature = "runtime")] debug!( "Generating bindings, libclang at {}", diff --git a/book/src/requirements.md b/book/src/requirements.md index b701234fad..6553b7c15c 100644 --- a/book/src/requirements.md +++ b/book/src/requirements.md @@ -7,7 +7,7 @@ This page lists the requirements for running `bindgen` and how to get them. `bindgen` leverages `libclang` to preprocess, parse, and type check C and C++ header files. -It is required to use Clang 5.0 or greater. +It is required to use Clang 9.0 or greater. ### Installing Clang