@@ -109,13 +109,16 @@ 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
+ // NB: win64 also contains the substring "win32" in the target triple, so
119
+ // we need to actually check for i686...
120
+ if ctx. target ( ) . contains ( "macos" ) ||
121
+ ( ctx. target ( ) . contains ( "i686" ) && ctx. target ( ) . contains ( "windows" ) ) {
119
122
symbol. remove ( 0 ) ;
120
123
}
121
124
}
@@ -138,7 +141,7 @@ pub fn cursor_mangling(ctx: &BindgenContext,
138
141
139
142
if let Ok ( mut manglings) = cursor. cxx_manglings ( ) {
140
143
if let Some ( mut m) = manglings. pop ( ) {
141
- macos_mangling ( & mut m) ;
144
+ mangling_hack_if_needed ( ctx , & mut m) ;
142
145
return Some ( m) ;
143
146
}
144
147
}
@@ -148,7 +151,7 @@ pub fn cursor_mangling(ctx: &BindgenContext,
148
151
return None ;
149
152
}
150
153
151
- macos_mangling ( & mut mangling) ;
154
+ mangling_hack_if_needed ( ctx , & mut mangling) ;
152
155
153
156
if cursor. kind ( ) == clang_sys:: CXCursor_Destructor {
154
157
// With old (3.8-) libclang versions, and the Itanium ABI, clang returns
0 commit comments