Skip to content

Commit

Permalink
Require libclang 9.0 or newer
Browse files Browse the repository at this point in the history
Adds a check for the loaded libclang version and logs a warning
if the version is unsupported.
  • Loading branch information
Kriskras99 authored and emilio committed Sep 18, 2024
1 parent f518815 commit 60da548
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions bindgen/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -744,6 +745,17 @@ impl Bindings {
) -> Result<Bindings, BindgenError> {
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 {}",
Expand Down
2 changes: 1 addition & 1 deletion book/src/requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 60da548

Please sign in to comment.