[cfe-dev] Re-using 'dllexport' for non-Windows targets

Martin J. O'Riordan via cfe-dev cfe-dev at lists.llvm.org
Sat Jun 4 03:10:04 PDT 2016


Sorry for the delay responding.  Yes, this is what I had done in the past, but removing this means that the attribute is enabled for all targets.  We build clang/llvm for the SHAVE target, plus the X86 and Sparc.  The X86 is useful to verify that we haven’t broken anything with our changes for SHAVE, and the Sparc target is simply an experiment to see what code generation looks like for our Leon cores compared to the GCC code generation which we use for our Sparc Leon cores.

 

Of course, it is not really a problem allowing ‘dllexport’ on other platforms, I think it will get ignored in the back-ends anyway; but I was really wondering if there was a more elegant approach.

 

One technique I think might work is to replace:

 

def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> {

with:

def DLLExport : InheritableAttr, TargetSpecificAttr<EnableDllExport> {

 

and then making the predicate ‘EnableDllExport’ be ‘TargetWindows’ OR ‘TargetSHAVE’; thus enabling it only where it is intended.

 

Thanks again,

 

            MartinO

 

From: Reid Kleckner [mailto:rnk at google.com] 
Sent: 31 May 2016 17:29
To: Martin J. O'Riordan <martin.oriordan at movidius.com>
Cc: Clang Dev <cfe-dev at lists.llvm.org>
Subject: Re: [cfe-dev] Re-using 'dllexport' for non-Windows targets

 

It should just work if you remove the Windows-only restriction in Attr.td:

 

def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> {

  let Spellings = [Declspec<"dllexport">, GCC<"dllexport">];

  let Subjects = SubjectList<[Function, Var, CXXRecord]>;

  let Documentation = [Undocumented];

}

 

def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> {

  let Spellings = [Declspec<"dllimport">, GCC<"dllimport">];

  let Subjects = SubjectList<[Function, Var, CXXRecord]>;

  let Documentation = [Undocumented];

}

 

I know Sony does this, so it can't require too much patching.

 

On Mon, May 30, 2016 at 6:38 AM, Martin J. O'Riordan via cfe-dev <cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org> > wrote:

For our SHAVE target I have re-used ‘__attribute__((dllexport))’ to allow me to create indirect address tables for symbols with this annotation.

 

However, with almost every release of LLVM and CLang my implementation is broken and I have to rework my implementation.  For the most part, the existing ‘dllexport’ attribute does everything I require and makes more sense for me to pass it through CLang/LLVM until it reaches our back-end where it emits the IAT support rather than adding my own new attribute.

 

This got broken again with v3.8 and this time the controls are more strict on Windows supporting targets.  I thought that before I go in an make another set of changes to re-enable this with our target, that I would ask first if there anybody has any advice or recommendation for how to “borrow” this attribute for non-Windows targets?  The problem is principally CLang rather than LLVM, so I would like to find a good and future-proof way of adapting CLang to enable this attribute on my target.

 

Thanks in advance,

 

            MartinO

 

Martin J. O’Riordan                Email:  Martin.ORiordan at movidius.com <mailto:Martin.ORiordan at movidius.com> 

Compiler Development               Web:    www.movidius.com <http://www.movidius.com/> 

Movidius Ltd.                      Skype:  moviMartinO

1st Floor,  O’Connell Bridge House,  d’Olier Street,  Dublin 2, Ireland

 


_______________________________________________
cfe-dev mailing list
cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org> 
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160604/c5f7666b/attachment.html>


More information about the cfe-dev mailing list