Skip to content

Commit

Permalink
Auto merge of #776 - snipsco:fix/ios-mangling, r=emilio
Browse files Browse the repository at this point in the history
Fix iOS mangling

Hi,
We had a regression on a project that target iOS while upgrading bindgen from `0.25.3` to `0.25.4`.

After a long investigation it appeared that iOS need also a mangling hack. I managed to make a patch and successfully test it.

Thanks a lot for all your work.
Cheers
  • Loading branch information
bors-servo authored Jun 23, 2017
2 parents 313d792 + 8885365 commit 3106b30
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ir/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,15 @@ impl<'ctx> BindgenContext<'ctx> {
effective_target = Some(HOST_TARGET.to_owned());
}

// Mac os and Win32 need __ for mangled symbols but rust will automatically
// Mac os, iOS and Win32 need __ for mangled symbols but rust will automatically
// prepend the extra _.
//
// We need to make sure that we don't include __ because rust will turn into
// ___.
let effective_target = effective_target.unwrap();
let needs_mangling_hack =
effective_target.contains("darwin") ||
effective_target.contains("ios") ||
effective_target == "i686-pc-win32";

let root_module = Self::build_root_module(ItemId(0));
Expand Down
9 changes: 9 additions & 0 deletions tests/expectations/tests/mangling-ios.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* automatically generated by rust-bindgen */


#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


extern "C" {
pub fn foo();
}
3 changes: 3 additions & 0 deletions tests/headers/mangling-ios.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// bindgen-flags: -- --target=x86_64-apple-ios

void foo();

0 comments on commit 3106b30

Please sign in to comment.