<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Book Antiqua";
        panose-1:2 4 6 2 5 3 5 3 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        mso-fareast-language:EN-US;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Book Antiqua","serif";
        color:#1F497D;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-priority:99;
        mso-style-link:"Plain Text";
        font-family:"Courier New";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-IE link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'>Hi Saleem,<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'>It’s not really a big problem.  In the past I have had to merge my changes with the ongoing CLang changes to allow the ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>__attribute__((dllexport))</span><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'>’ to be permitted on objects for the SHAVE target.  My approach was a little bit cheeky because I just tweaked/hacked the source to allow it for SHAVE too and all went well.  But the changes in v3.8 from v3.7 are more semantically constrained and tighter bound to Windows and this approach no longer works.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'>The error I get is simply (I’m not using ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>__declspec</span><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'>’ syntax, just the GCC attribute syntax):<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>error: unknown attribute 'dllexport' ignored [-Werror,-Wunknown-attributes]<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'>And I can fix this easily enough.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'>But since the ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>dllexport</span><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'>’ semantics are mostly what I want, it seems like a better idea to reuse it if possible than to add my own ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>iatexport</span><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'>’ attribute that more or less does what ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>dllexport</span><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'>’ already does.  So rather than going in and making another set of ad-hoc changes to re-enable it for our target, I thought I would ask cfe-dev first to see if there was a better strategy before I “fix” it again only to find that v3.9 breaks my ad-hoc solution again, and v3.10 sometime farther down the road.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'>In response to Rafael Espindola’s questions:<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:36.0pt'>What file format do you use? ELF?<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText style='margin-left:36.0pt'>I can see the point of dllimport (telling the compiler something is known to be external, even in a non -fPIC build), but how is dllexport different from a default symbol?<o:p></o:p></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'>Yes, our target produces ELF files ultimately, though the compiler does not have an integrated assembler.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'>What I do with the attribute at code-generation is mostly treat it as an ordinary symbol, but I supplement their definitions with a set of data structures that when linked creates an IAT or Indirect Address Table that can be inspected at run-time.  This is useful because the code running on the SHAVE cores is usually managed by an executive running on the Sparc Leon cores, and the dynamic lookup makes the programming model a lot simpler.  The additional semantic checks and constraints that CLang places on ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>dllexport</span><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'>’ are also very valuable, as they make many incompatible or ill-advised use-cases become compile-time errors and warnings.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'>In summary, the CLang front-end semantics are very appropriate to my requirements, and my LLVM back-end emits normal symbols, but supplemented with the auxiliary IAT data structures.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'>It would be neat if I could “borrow” the existing ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>dllexport</span><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'>’ implementation for the most part, but in a structured well defined manner.  I have had this working since LLVM v3.3, but each time I update to a new version I have to rework my adaptations, and going forward it would be good to have this better integrated using CLang best-practices rather than the ad-hoc I have used to date.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'>Thanks,<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'>            MartinO<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif"'> Saleem Abdulrasool [mailto:compnerd@compnerd.org] <br><b>Sent:</b> 30 May 2016 21:22<br><b>To:</b> Martin J. O'Riordan<br><b>Cc:</b> Clang Dev<br><b>Subject:</b> Re: [cfe-dev] Re-using 'dllexport' for non-Windows targets<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Sorry for the top post, on a mobile device.<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>What exactly is broken with the attribute application?<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><p class=MsoNormal>Is the issue with using the __declspec spelling?  If so, -fdeclspec should allow that to come through.  I believe that we treat the attribute the same irrespective of the spelling.<o:p></o:p></p><div><div><p class=MsoNormal><o:p> </o:p></p></div></div><div><p class=MsoNormal>On Monday, May 30, 2016, Martin J. O'Riordan via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<o:p></o:p></p><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm'><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-family:"Book Antiqua","serif"'>For our SHAVE target I have re-used ‘</span><span style='font-family:"Courier New"'>__attribute__((dllexport))</span><span style='font-family:"Book Antiqua","serif"'>’ to allow me to create indirect address tables for symbols with this annotation.</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-family:"Book Antiqua","serif"'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-family:"Book Antiqua","serif"'>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 ‘</span><span style='font-family:"Courier New";color:black'>dllexport</span><span style='font-family:"Book Antiqua","serif"'>’ 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.</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-family:"Book Antiqua","serif"'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-family:"Book Antiqua","serif"'>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.</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-family:"Book Antiqua","serif"'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-family:"Book Antiqua","serif"'>Thanks in advance,</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-family:"Book Antiqua","serif"'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-family:"Book Antiqua","serif"'>            MartinO</span><o:p></o:p></p><div style='border:none;border-bottom:solid windowtext 1.5pt;padding:0cm 0cm 1.0pt 0cm'><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"'> </span><o:p></o:p></p></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"'>Martin J. O’Riordan                Email:  <a href="javascript:_e(%7B%7D,'cvml','Martin.ORiordan@movidius.com');" target="_blank">Martin.ORiordan@movidius.com</a></span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"'>Compiler Development               Web:    <a href="http://www.movidius.com/" target="_blank">www.movidius.com</a></span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"'>Movidius Ltd.                      Skype:  moviMartinO</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"'>1st Floor,  O’Connell Bridge House,  d’Olier Street,  Dublin 2, Ireland</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p></div></div></blockquote></div><p class=MsoNormal><br><br>-- <br>Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org<o:p></o:p></p></div></body></html>