Skip to content

Commit 41f372d

Browse files
committed
ir: Use the mangling hack in win32 too.
Fixes rust-lang#593 Fixes rust-lang#728
1 parent 5444bab commit 41f372d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/ir/function.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ fn get_abi(cc: CXCallingConv) -> Option<abi::Abi> {
109109
}
110110
}
111111

112-
// Mac os needs __ for mangled symbols but rust will automatically prepend the extra _.
113-
// We need to make sure that we don't include __ because rust will turn into ___.
112+
// Mac os and Win32 need __ for mangled symbols but rust will automatically
113+
// prepend the extra _.
114114
//
115-
// TODO(emilio): This is wrong when the target system is not the host
116-
// system. See https://github.com/servo/rust-bindgen/issues/593
117-
fn macos_mangling(symbol: &mut String) {
118-
if cfg!(target_os = "macos") && symbol.starts_with("_") {
115+
// We need to make sure that we don't include __ because rust will turn into
116+
// ___.
117+
fn mangling_hack_if_needed(ctx: &BindgenContext, symbol: &mut String) {
118+
if ctx.target().contains("macos") || ctx.target().contains("win32") {
119119
symbol.remove(0);
120120
}
121121
}
@@ -138,7 +138,7 @@ pub fn cursor_mangling(ctx: &BindgenContext,
138138

139139
if let Ok(mut manglings) = cursor.cxx_manglings() {
140140
if let Some(mut m) = manglings.pop() {
141-
macos_mangling(&mut m);
141+
mangling_hack_if_needed(ctx, &mut m);
142142
return Some(m);
143143
}
144144
}
@@ -148,7 +148,7 @@ pub fn cursor_mangling(ctx: &BindgenContext,
148148
return None;
149149
}
150150

151-
macos_mangling(&mut mangling);
151+
mangling_hack_if_needed(ctx, &mut mangling);
152152

153153
if cursor.kind() == clang_sys::CXCursor_Destructor {
154154
// With old (3.8-) libclang versions, and the Itanium ABI, clang returns

0 commit comments

Comments
 (0)