@@ -164,7 +164,7 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> {
164
164
. iter ( )
165
165
. map ( |import : & DllImport | {
166
166
if self . config . sess . target . arch == "x86" {
167
- LlvmArchiveBuilder :: i686_decorated_name ( import) . into_string ( ) . unwrap ( )
167
+ LlvmArchiveBuilder :: i686_decorated_name ( import, true ) . into_string ( ) . unwrap ( )
168
168
} else {
169
169
import. name . to_string ( )
170
170
}
@@ -320,13 +320,17 @@ impl<'a> LlvmArchiveBuilder<'a> {
320
320
}
321
321
}
322
322
323
- fn i686_decorated_name ( import : & DllImport ) -> CString {
323
+ fn i686_decorated_name ( import : & DllImport , mingw : bool ) -> CString {
324
324
let name = import. name ;
325
+ // MinGW doesn't want `_` prefix for `.def` file
326
+ let prefix = if mingw { "" } else { "_" } ;
325
327
// We verified during construction that `name` does not contain any NULL characters, so the
326
328
// conversion to CString is guaranteed to succeed.
327
329
CString :: new ( match import. calling_convention {
328
- DllCallingConvention :: C => format ! ( "_{}" , name) ,
329
- DllCallingConvention :: Stdcall ( arg_list_size) => format ! ( "_{}@{}" , name, arg_list_size) ,
330
+ DllCallingConvention :: C => format ! ( "{}{}" , prefix, name) ,
331
+ DllCallingConvention :: Stdcall ( arg_list_size) => {
332
+ format ! ( "{}{}@{}" , prefix, name, arg_list_size)
333
+ }
330
334
DllCallingConvention :: Fastcall ( arg_list_size) => format ! ( "@{}@{}" , name, arg_list_size) ,
331
335
DllCallingConvention :: Vectorcall ( arg_list_size) => {
332
336
format ! ( "{}@@{}" , name, arg_list_size)
0 commit comments