Skip bindgen 0.70's layout tests before Rust 1.77

This commit is contained in:
Jordan Rose 2024-10-22 15:47:21 -07:00 committed by Rushil Mehra
parent bb373e5550
commit 3044e9ba98
3 changed files with 7 additions and 1 deletions

View File

@ -49,3 +49,4 @@ openssl-macros = "0.1.1"
tower = "0.4" tower = "0.4"
tower-layer = "0.3" tower-layer = "0.3"
tower-service = "0.3" tower-service = "0.3"
autocfg = "1.3.0"

View File

@ -77,6 +77,7 @@ pq-experimental = []
underscore-wildcards = [] underscore-wildcards = []
[build-dependencies] [build-dependencies]
autocfg = { workspace = true }
bindgen = { workspace = true } bindgen = { workspace = true }
cmake = { workspace = true } cmake = { workspace = true }
fs_extra = { workspace = true } fs_extra = { workspace = true }

View File

@ -687,6 +687,10 @@ fn main() {
} }
}); });
// bindgen 0.70 replaced the run-time layout tests with compile-time ones,
// but they depend on std::mem::offset_of, stabilized in 1.77.
let supports_layout_tests = autocfg::new().probe_rustc_version(1, 77);
let mut builder = bindgen::Builder::default() let mut builder = bindgen::Builder::default()
.rust_target(bindgen::RustTarget::Stable_1_68) // bindgen MSRV is 1.70, so this is enough .rust_target(bindgen::RustTarget::Stable_1_68) // bindgen MSRV is 1.70, so this is enough
.derive_copy(true) .derive_copy(true)
@ -701,7 +705,7 @@ fn main() {
.generate_comments(true) .generate_comments(true)
.fit_macro_constants(false) .fit_macro_constants(false)
.size_t_is_usize(true) .size_t_is_usize(true)
.layout_tests(true) .layout_tests(supports_layout_tests)
.prepend_enum_name(true) .prepend_enum_name(true)
.blocklist_type("max_align_t") // Not supported by bindgen on all targets, not used by BoringSSL .blocklist_type("max_align_t") // Not supported by bindgen on all targets, not used by BoringSSL
.clang_args(get_extra_clang_args_for_bindgen(&config)) .clang_args(get_extra_clang_args_for_bindgen(&config))