@@ -109,13 +109,13 @@ fn get_abi(cc: CXCallingConv) -> Option<abi::Abi> {
109
109
}
110
110
}
111
111
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 _ .
114
114
//
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 ") {
119
119
symbol. remove ( 0 ) ;
120
120
}
121
121
}
@@ -138,7 +138,7 @@ pub fn cursor_mangling(ctx: &BindgenContext,
138
138
139
139
if let Ok ( mut manglings) = cursor. cxx_manglings ( ) {
140
140
if let Some ( mut m) = manglings. pop ( ) {
141
- macos_mangling ( & mut m) ;
141
+ mangling_hack_if_needed ( ctx , & mut m) ;
142
142
return Some ( m) ;
143
143
}
144
144
}
@@ -148,7 +148,7 @@ pub fn cursor_mangling(ctx: &BindgenContext,
148
148
return None ;
149
149
}
150
150
151
- macos_mangling ( & mut mangling) ;
151
+ mangling_hack_if_needed ( ctx , & mut mangling) ;
152
152
153
153
if cursor. kind ( ) == clang_sys:: CXCursor_Destructor {
154
154
// With old (3.8-) libclang versions, and the Itanium ABI, clang returns
0 commit comments