Skip to content

Commit 458182b

Browse files
Kriskras99pvdrz
authored andcommitted
Require libclang 9.0 or newer
Adds a check for the loaded libclang version and logs a warning if the version is unsupported. Will not print a warning if libclang is statically linked.
1 parent 3c09db0 commit 458182b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

bindgen/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,18 @@ impl Bindings {
744744
) -> Result<Bindings, BindgenError> {
745745
ensure_libclang_is_loaded();
746746

747+
#[cfg(feature = "runtime")]
748+
match clang_sys::get_library().unwrap().version() {
749+
None => {
750+
warn!("Could not detect a Clang version, make sure you are using libclang 9 or newer");
751+
}
752+
Some(version) => {
753+
if version < clang_sys::Version::V9_0 {
754+
warn!("Detected Clang version {version:?} which is unsupported and can cause invalid code generation, use libclang 9 or newer");
755+
}
756+
}
757+
}
758+
747759
#[cfg(feature = "runtime")]
748760
debug!(
749761
"Generating bindings, libclang at {}",

book/src/requirements.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This page lists the requirements for running `bindgen` and how to get them.
77
`bindgen` leverages `libclang` to preprocess, parse, and type check C and C++
88
header files.
99

10-
It is required to use Clang 5.0 or greater.
10+
It is required to use Clang 9.0 or greater.
1111

1212
### Installing Clang
1313

0 commit comments

Comments
 (0)