<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=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@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:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* 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;}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.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="ZH-CN" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri",sans-serif;color:#1F497D">Fish:<o:p></o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></a></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><a name="_____replyseparator"></a><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"> afish@apple.com [mailto:afish@apple.com]
<br>
<b>Sent:</b> Thursday, June 6, 2019 11:39 AM<br>
<b>To:</b> devel@edk2.groups.io; Lu, XiaoyuX <xiaoyux.lu@intel.com><br>
<b>Cc:</b> Gao, Liming <liming.gao@intel.com>; Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J <jian.j.wang@intel.com><br>
<b>Subject:</b> Re: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-US"><br>
<br>
<o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><span lang="EN-US">On Jun 4, 2019, at 11:33 PM, Xiaoyu Lu <<a href="mailto:xiaoyux.lu@intel.com">xiaoyux.lu@intel.com</a>> wrote:<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;font-family:"Helvetica",sans-serif">Hi Liming,<br>
<br style="caret-color: rgb(0, 0, 0);font-variant-caps: normal;text-align:start;-webkit-text-stroke-width: 0px;word-spacing:0px">
<br>
</span><span lang="EN-US"><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;font-family:"Helvetica",sans-serif">-----Original Message-----<br>
From: Gao, Liming<br>
Sent: Wednesday, June 5, 2019 1:57 PM<br>
To:<span class="apple-converted-space"> </span><a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a>; Lu, XiaoyuX <<a href="mailto:xiaoyux.lu@intel.com">xiaoyux.lu@intel.com</a>><br>
Cc: Bi, Dandan <<a href="mailto:dandan.bi@intel.com">dandan.bi@intel.com</a>>; Wang, Jian J <<a href="mailto:jian.j.wang@intel.com">jian.j.wang@intel.com</a>><br>
Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix<br>
CLANG38 IA32 build problem<br>
<br>
Xiaoyu:<br>
<br>
<br>
<o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;font-family:"Helvetica",sans-serif">-----Original Message-----<br>
From: <a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a> [<a href="mailto:devel@edk2.groups.io">mailto:devel@edk2.groups.io</a>] On Behalf Of<br>
Xiaoyu Lu<br>
Sent: Wednesday, June 05, 2019 1:25 PM<br>
To: <a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a><br>
Cc: Lu, XiaoyuX <<a href="mailto:xiaoyux.lu@intel.com">xiaoyux.lu@intel.com</a>>; Bi, Dandan<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><<a href="mailto:dandan.bi@intel.com">dandan.bi@intel.com</a>>;<br>
<br>
<o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;font-family:"Helvetica",sans-serif">Wang, Jian J <<a href="mailto:jian.j.wang@intel.com">jian.j.wang@intel.com</a>><br>
Subject: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38<br>
IA32 build problem<br>
<br>
When use clang-3.8 to build the NetworkPkg, compiler optimization<br>
may use memcpy for memory copy. For example:<br>
<br>
CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_rsa.c:918: undefined<br>
reference to `memcpy'`<br>
<br>
Compiler optimization is sophisticated, but we can work around it<br>
use __attribute__((__used__)) to informs the compiler that symbol<br>
should be retained in the object file, even if it may be<br>
unreferenced.<br>
<br>
Cc: Jian J Wang <<a href="mailto:jian.j.wang@intel.com">jian.j.wang@intel.com</a>><br>
Cc: Dandan Bi <<a href="mailto:dandan.bi@intel.com">dandan.bi@intel.com</a>><br>
Signed-off-by: Xiaoyu Lu <<a href="mailto:xiaoyux.lu@intel.com">xiaoyux.lu@intel.com</a>><br>
---<br>
CryptoPkg/Library/IntrinsicLib/CopyMem.c | 13 +++++++++++++<br>
1 file changed, 13 insertions(+)<br>
<br>
diff --git a/CryptoPkg/Library/IntrinsicLib/CopyMem.c<br>
b/CryptoPkg/Library/IntrinsicLib/CopyMem.c<br>
index e29b4918d200..7faf5a34d8c1 100644<br>
--- a/CryptoPkg/Library/IntrinsicLib/CopyMem.c<br>
+++ b/CryptoPkg/Library/IntrinsicLib/CopyMem.c<br>
@@ -10,8 +10,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent<br>
#include <Base.h><br>
#include <Library/BaseMemoryLib.h><br>
<br>
+#if defined(__clang__) && !defined(__APPLE__)<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br>
So, this change is only for CLANG tool chain.<br>
<br>
<br>
<o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;font-family:"Helvetica",sans-serif">+<br>
+/* Copies bytes between buffers */<br>
+static __attribute__((__used__))<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span lang="EN-US" style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br>
What purpose for static?<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br>
Because I want __memcpy only use in this file scope.<br>
<br style="caret-color: rgb(0, 0, 0);font-variant-caps: normal;text-align:start;-webkit-text-stroke-width: 0px;word-spacing:0px">
<br>
</span><span lang="EN-US"><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;font-family:"Helvetica",sans-serif">+void * __memcpy (void *dest, const void *src, unsigned int count)<br>
+{<br>
+  return CopyMem (dest, src, (UINTN)count);<br>
+}<br>
+__attribute__((__alias__("__memcpy")))<br>
+void * memcpy (void *dest, const void *src, unsigned int count);<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span lang="EN-US" style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br>
__memcpy is IA32 Intrinsic API, memcpy is X64 Intrinsic API, right?<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br>
__memcpy isn't IA32 Intrinsic API, only memcpy is intrinsic API for both IA32 and X64.<br>
<br>
The reason I alias memcpy and use __attribute__((__used__)) is let compiler retain symbol in object file,<br>
So it can link correct.<br>
<br>
Is this correct?<br style="caret-color: rgb(0, 0, 0);font-variant-caps: normal;text-align:start;-webkit-text-stroke-width: 0px;word-spacing:0px">
<br>
</span><span lang="EN-US"><o:p></o:p></span></p>
</div>
</blockquote>
<div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US">I think this is a bug in clang that requires the __used__, we hit something like this with Xcode too. If the compiler emits the intrinsic it should tell the linker and some how that was getting missed. Thus the __used__
 is a work around. <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri",sans-serif;color:#1F497D">OK. It is for CLANG 3.8. I will check whether the latest CLANG8.0 fixes it.
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US">Thanks,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US">Andrew Fish<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span lang="EN-US"><br>
<br>
<o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt;font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;font-family:"Helvetica",sans-serif">Thanks<br>
Liming<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br style="caret-color: rgb(0, 0, 0);font-variant-caps: normal;text-align:start;-webkit-text-stroke-width: 0px;word-spacing:0px">
<br>
</span><span lang="EN-US"><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-bottom:12.0pt"><span lang="EN-US" style="font-size:9.0pt;font-family:"Helvetica",sans-serif">+<br>
+#else<br>
/* Copies bytes between buffers */<br>
void * memcpy (void *dest, const void *src, unsigned int count)<br>
{<br>
 return CopyMem (dest, src, (UINTN)count);<br>
}<br>
+#endif<br>
--<br>
2.7.4<br>
<br>
<br>
<o:p></o:p></span></p>
</blockquote>
</blockquote>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br>
<br>
</span><span lang="EN-US"><o:p></o:p></span></p>
</div>
</blockquote>
</div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
</div>
</body>
</html>

<div width="1" style="color:white;clear:both">_._,_._,_</div>
<hr>
Groups.io Links:<p>

You receive all messages sent to this group.


<p>

<a target="_blank" href="https://edk2.groups.io/g/devel/message/41975">View/Reply Online (#41975)</a> |


  


|


  
    <a target="_blank" href="https://groups.io/mt/31934411/1813853">Mute This Topic</a>
  

| <a href="https://edk2.groups.io/g/devel/post">New Topic</a><br>



<br>

<a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> |
<a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |

<a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>

 [edk2-devel-archive@redhat.com]<br>
<div width="1" style="color:white;clear:both">_._,_._,_</div>