[llvm] r207926 - X86: repair export compatibility with MinGW/cygwin

Saleem Abdulrasool compnerd at compnerd.org
Tue May 6 22:49:21 PDT 2014


On Tue, May 6, 2014 at 11:14 AM, Reid Kleckner <rnk at google.com> wrote:

> Is there a binutils bug for this?  It's fine if they close wontfix, but at
> least then we'd have some record of communication about this issue.
>

I spoke with Kai Tietz about this over IRC.  It seems that they agree that
this is broken (I think that this can even result in incorrect exports in
contrived cases), but he maintained that the compatibility was important.
 I can file a bug if you like.


> On Sat, May 3, 2014 at 5:03 PM, Saleem Abdulrasool <compnerd at compnerd.org>wrote:
>
>> Author: compnerd
>> Date: Sat May  3 19:03:48 2014
>> New Revision: 207926
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=207926&view=rev
>> Log:
>> X86: repair export compatibility with MinGW/cygwin
>>
>> Both MinGW and cygwin (i686) construct export directives without the
>> global
>> leader prefix.  This is mostly due to the fact that they use GNU ld which
>> does
>> not correctly handle the export directive.  This apparently has been been
>> broken
>> for a while.  However, this was recently reported as being broken by
>> mingwandroid and diorcety of the msys2 project.
>>
>> Remove the global leader prefix if targeting MinGW or cygwin, otherwise,
>> retain
>> the global leader prefix.  Add an explicit test for cygwin's behaviour of
>> export
>> directives.
>>
>> Modified:
>>     llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
>>     llvm/trunk/test/CodeGen/X86/dllexport.ll
>>
>> Modified: llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp?rev=207926&r1=207925&r2=207926&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp (original)
>> +++ llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp Sat May  3 19:03:48 2014
>> @@ -553,13 +553,18 @@ emitNonLazySymbolPointer(MCStreamer &Out
>>  void X86AsmPrinter::GenerateExportDirective(const MCSymbol *Sym, bool
>> IsData) {
>>    SmallString<128> Directive;
>>    raw_svector_ostream OS(Directive);
>> +  StringRef Name = Sym->getName();
>>
>>    if (Subtarget->isTargetKnownWindowsMSVC())
>>      OS << " /EXPORT:";
>>    else
>>      OS << " -export:";
>>
>> -  OS << Sym->getName();
>> +  if ((Subtarget->isTargetWindowsGNU() ||
>> Subtarget->isTargetWindowsCygwin()) &&
>> +      (Name[0] == getDataLayout().getGlobalPrefix()))
>> +    Name = Name.drop_front();
>> +
>> +  OS << Name;
>>
>>    if (IsData) {
>>      if (Subtarget->isTargetKnownWindowsMSVC())
>>
>> Modified: llvm/trunk/test/CodeGen/X86/dllexport.ll
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/dllexport.ll?rev=207926&r1=207925&r2=207926&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/test/CodeGen/X86/dllexport.ll (original)
>> +++ llvm/trunk/test/CodeGen/X86/dllexport.ll Sat May  3 19:03:48 2014
>> @@ -1,5 +1,9 @@
>> -; RUN: llc -mtriple i386-pc-win32 < %s | FileCheck -check-prefix=CHECK
>> -check-prefix=WIN32 %s
>> -; RUN: llc -mtriple i386-pc-mingw32 < %s | FileCheck -check-prefix=CHECK
>> -check-prefix=MINGW %s
>> +; RUN: llc -mtriple i386-pc-win32 < %s \
>> +; RUN:    | FileCheck -check-prefix CHECK -check-prefix CHECK-CL %s
>> +; RUN: llc -mtriple i386-pc-mingw32 < %s \
>> +; RUN:    | FileCheck -check-prefix CHECK -check-prefix CHECK-GCC %s
>> +; RUN: llc -mtriple i686-pc-cygwin %s -o - \
>> +; RUN:    | FileCheck -check-prefix CHECK -check-prefix CHECK-GCC %s
>>
>>  ; CHECK: .text
>>
>> @@ -89,37 +93,38 @@ define weak_odr dllexport void @weak1()
>>
>>
>>  ; CHECK: .section .drectve
>> -; WIN32: /EXPORT:_Var1,DATA
>> -; WIN32: /EXPORT:_Var2,DATA
>> -; WIN32: /EXPORT:_Var3,DATA
>> -; WIN32: /EXPORT:_WeakVar1,DATA
>> -; WIN32: /EXPORT:_WeakVar2,DATA
>> -; WIN32: /EXPORT:_f1
>> -; WIN32: /EXPORT:_f2
>> -; WIN32: /EXPORT:_stdfun at 0
>> -; WIN32: /EXPORT:@fastfun at 0
>> -; WIN32: /EXPORT:_thisfun
>> -; WIN32: /EXPORT:_lnk1
>> -; WIN32: /EXPORT:_lnk2
>> -; WIN32: /EXPORT:_weak1
>> -; WIN32: /EXPORT:_alias
>> -; WIN32: /EXPORT:_alias2
>> -; WIN32: /EXPORT:_alias3
>> -; WIN32: /EXPORT:_weak_alias
>> -; MINGW: -export:_Var1,data
>> -; MINGW: -export:_Var2,data
>> -; MINGW: -export:_Var3,data
>> -; MINGW: -export:_WeakVar1,data
>> -; MINGW: -export:_WeakVar2,data
>> -; MINGW: -export:_f1
>> -; MINGW: -export:_f2
>> -; MINGW: -export:_stdfun at 0
>> -; MINGW: -export:@fastfun at 0
>> -; MINGW: -export:_thisfun
>> -; MINGW: -export:_lnk1
>> -; MINGW: -export:_lnk2
>> -; MINGW: -export:_weak1
>> -; MINGW: -export:_alias
>> -; MINGW: -export:_alias2
>> -; MINGW: -export:_alias3
>> -; MINGW: -export:_weak_alias
>> +; CHECK-CL: /EXPORT:_Var1,DATA
>> +; CHECK-CL: /EXPORT:_Var2,DATA
>> +; CHECK-CL: /EXPORT:_Var3,DATA
>> +; CHECK-CL: /EXPORT:_WeakVar1,DATA
>> +; CHECK-CL: /EXPORT:_WeakVar2,DATA
>> +; CHECK-CL: /EXPORT:_f1
>> +; CHECK-CL: /EXPORT:_f2
>> +; CHECK-CL: /EXPORT:_stdfun at 0
>> +; CHECK-CL: /EXPORT:@fastfun at 0
>> +; CHECK-CL: /EXPORT:_thisfun
>> +; CHECK-CL: /EXPORT:_lnk1
>> +; CHECK-CL: /EXPORT:_lnk2
>> +; CHECK-CL: /EXPORT:_weak1
>> +; CHECK-CL: /EXPORT:_alias
>> +; CHECK-CL: /EXPORT:_alias2
>> +; CHECK-CL: /EXPORT:_alias3
>> +; CHECK-CL: /EXPORT:_weak_alias
>> +; CHECK-GCC: -export:Var1,data
>> +; CHECK-GCC: -export:Var2,data
>> +; CHECK-GCC: -export:Var3,data
>> +; CHECK-GCC: -export:WeakVar1,data
>> +; CHECK-GCC: -export:WeakVar2,data
>> +; CHECK-GCC: -export:f1
>> +; CHECK-GCC: -export:f2
>> +; CHECK-GCC: -export:stdfun at 0
>> +; CHECK-GCC: -export:@fastfun at 0
>> +; CHECK-GCC: -export:thisfun
>> +; CHECK-GCC: -export:lnk1
>> +; CHECK-GCC: -export:lnk2
>> +; CHECK-GCC: -export:weak1
>> +; CHECK-GCC: -export:alias
>> +; CHECK-GCC: -export:alias2
>> +; CHECK-GCC: -export:alias3
>> +; CHECK-GCC: -export:weak_alias
>> +
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>
>


-- 
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140506/d5a50a37/attachment.html>


More information about the llvm-commits mailing list