From 173592caed0fd67bf327a0cdd3d44bd3aa5f9f29 Mon Sep 17 00:00:00 2001 From: Yarvin Date: Fri, 7 Nov 2025 13:26:17 +0100 Subject: [PATCH] Blocklist generating bindings for `max_align_t` type. - blocklist max_align_t from binding generation - update bindgen. ---- Bindgen can generate wrong size checks for types defined as `__attribute__((aligned(__alignof__(struct {...}))))`, which is how clang defines max_align_t: https://clang.llvm.org/doxygen/____stddef__max__align__t_8h_source.html. Size checks seems to be fine on all the targets but `wasm32-unknown-emscripten`, disallowing web builds. We don't use `max_align_t` anywhere, so blacklisting it until upstream fixes the problem seems to be the most sane solution. (also why nothing supports git-notes?) --- Cargo.toml | 2 +- godot-bindings/src/header_gen.rs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e93fac674..144c736ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ serde_json = "1" # Related to tooling/build setup. # * regex: not used for unicode parsing -> features unicode-bool + unicode-gencat are enabled instead of unicode-perl. # 'unicode-gencat' needed for \d, see https://docs.rs/regex/latest/regex/#unicode-features. -bindgen = { version = "0.71", default-features = false, features = ["runtime"] } +bindgen = { version = "0.72.1", default-features = false, features = ["runtime"] } libc = "0.2.172" regex = { version = "1.11", default-features = false, features = ["std", "unicode-bool", "unicode-gencat"] } which = "7" diff --git a/godot-bindings/src/header_gen.rs b/godot-bindings/src/header_gen.rs index c6fc2d9a6..d999d383e 100644 --- a/godot-bindings/src/header_gen.rs +++ b/godot-bindings/src/header_gen.rs @@ -26,7 +26,13 @@ pub(crate) fn generate_rust_binding(in_h_path: &Path, out_rs_path: &Path) { let builder = bindgen::Builder::default() .header(c_header_path) .parse_callbacks(Box::new(cargo_cfg)) - .prepend_enum_name(false); + .prepend_enum_name(false) + // Bindgen can generate wrong size checks for types defined as `__attribute__((aligned(__alignof__(struct {...}))))`, + // which is how clang defines max_align_t: https://clang.llvm.org/doxygen/____stddef__max__align__t_8h_source.html. + // Size checks seems to be fine on all the targets but `wasm32-unknown-emscripten`, disallowing web builds. + // We don't use `max_align_t` anywhere, so blacklisting it until upstream fixes the problem seems to be the most sane solution. + // See: https://github.com/rust-lang/rust-bindgen/issues/3295. + .blocklist_type("max_align_t"); std::fs::create_dir_all( out_rs_path