@@ -331,7 +331,7 @@ fn generate_bindings(
331
331
. wrap_err_with ( || format ! ( "bindgen failed for pg{major_version}" ) ) ?;
332
332
333
333
let oids = extract_oids ( & bindgen_output) ;
334
- let rewritten_items = rewrite_items ( & bindgen_output, & oids)
334
+ let rewritten_items = rewrite_items ( bindgen_output, & oids)
335
335
. wrap_err_with ( || format ! ( "failed to rewrite items for pg{major_version}" ) ) ?;
336
336
let oids = format_builtin_oid_impl ( oids) ;
337
337
@@ -438,9 +438,10 @@ fn write_rs_file(
438
438
/// Given a token stream representing a file, apply a series of transformations to munge
439
439
/// the bindgen generated code with some postgres specific enhancements
440
440
fn rewrite_items (
441
- file : & syn:: File ,
441
+ mut file : syn:: File ,
442
442
oids : & BTreeMap < syn:: Ident , Box < syn:: Expr > > ,
443
443
) -> eyre:: Result < proc_macro2:: TokenStream > {
444
+ rewrite_abi ( & mut file) ;
444
445
let items_vec = rewrite_oid_consts ( & file. items , oids) ;
445
446
let mut items = apply_pg_guard ( & items_vec) ?;
446
447
let pgnode_impls = impl_pg_node ( & items_vec) ?;
@@ -829,7 +830,6 @@ fn run_bindgen(
829
830
. wrap_static_fns ( enable_cshim)
830
831
. wrap_static_fns_path ( out_path. join ( "pgrx-cshim-static" ) )
831
832
. wrap_static_fns_suffix ( "__pgrx_cshim" )
832
- . override_abi ( bindgen:: Abi :: CUnwind , ".*" )
833
833
. generate ( )
834
834
. wrap_err_with ( || format ! ( "Unable to generate bindings for pg{major_version}" ) ) ?;
835
835
let mut binding_str = bindings. to_string ( ) ;
@@ -1176,6 +1176,23 @@ fn apply_pg_guard(items: &Vec<syn::Item>) -> eyre::Result<proc_macro2::TokenStre
1176
1176
Ok ( out)
1177
1177
}
1178
1178
1179
+ fn rewrite_abi ( file : & mut syn:: File ) {
1180
+ use proc_macro2:: Span ;
1181
+ use syn:: visit_mut:: VisitMut ;
1182
+ use syn:: LitStr ;
1183
+ pub struct Visitor { }
1184
+ impl VisitMut for Visitor {
1185
+ fn visit_abi_mut ( & mut self , abi : & mut syn:: Abi ) {
1186
+ if let Some ( name) = & mut abi. name {
1187
+ if name. value ( ) == "C" {
1188
+ * name = LitStr :: new ( "C-unwind" , Span :: call_site ( ) ) ;
1189
+ }
1190
+ }
1191
+ }
1192
+ }
1193
+ Visitor { } . visit_file_mut ( file) ;
1194
+ }
1195
+
1179
1196
fn rust_fmt ( path : & Path ) -> eyre:: Result < ( ) > {
1180
1197
// We shouldn't hit this path in a case where we care about it, but... just
1181
1198
// in case we probably should respect RUSTFMT.
0 commit comments