Skip to content

Commit

Permalink
fix: generate bindings compatible with MSRV
Browse files Browse the repository at this point in the history
It appears that bindgen generates the code for the latest known stable
by default, and the output has changed in 0.71 when targeting 1.82+ due
to introduction of `unsafe extern` blocks.
Restore the compilation with MSRV by passing explicit RustTarget to
bindgen.
  • Loading branch information
bavshin-f5 committed Jan 7, 2025
1 parent 72d65c0 commit a575249
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions nginx-sys/build/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ fn generate_binding(nginx_build_dir: PathBuf) {

print_cargo_metadata(&includes).expect("cargo dependency metadata");

// bindgen targets the latest known stable by default
let rust_target: bindgen::RustTarget = env::var("CARGO_PKG_RUST_VERSION")
.expect("rust-version set in Cargo.toml")
.parse()
.expect("rust-version is valid and supported by bindgen");

let bindings = bindgen::Builder::default()
// Bindings will not compile on Linux without block listing this item
// It is worth investigating why this is
Expand All @@ -97,6 +103,7 @@ fn generate_binding(nginx_build_dir: PathBuf) {
.header("build/wrapper.h")
.clang_args(clang_args)
.layout_tests(false)
.rust_target(rust_target)
.use_core()
.generate()
.expect("Unable to generate bindings");
Expand Down

0 comments on commit a575249

Please sign in to comment.