Skip to content

Commit a575249

Browse files
committedJan 7, 2025
fix: generate bindings compatible with MSRV
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.
1 parent 72d65c0 commit a575249

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
 

‎nginx-sys/build/main.rs

+7
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ fn generate_binding(nginx_build_dir: PathBuf) {
8888

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

91+
// bindgen targets the latest known stable by default
92+
let rust_target: bindgen::RustTarget = env::var("CARGO_PKG_RUST_VERSION")
93+
.expect("rust-version set in Cargo.toml")
94+
.parse()
95+
.expect("rust-version is valid and supported by bindgen");
96+
9197
let bindings = bindgen::Builder::default()
9298
// Bindings will not compile on Linux without block listing this item
9399
// It is worth investigating why this is
@@ -97,6 +103,7 @@ fn generate_binding(nginx_build_dir: PathBuf) {
97103
.header("build/wrapper.h")
98104
.clang_args(clang_args)
99105
.layout_tests(false)
106+
.rust_target(rust_target)
100107
.use_core()
101108
.generate()
102109
.expect("Unable to generate bindings");

0 commit comments

Comments
 (0)
Failed to load comments.