* [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem
@ 2019-06-05 5:24 Xiaoyu Lu
2019-06-05 5:56 ` [edk2-devel] " Liming Gao
0 siblings, 1 reply; 11+ messages in thread
From: Xiaoyu Lu @ 2019-06-05 5:24 UTC (permalink / raw)
To: devel; +Cc: Xiaoyu Lu, Dandan Bi, Jian J Wang
When use clang-3.8 to build the NetworkPkg, compiler optimization
may use memcpy for memory copy. For example:
CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_rsa.c:918: undefined
reference to `memcpy'`
Compiler optimization is sophisticated, but we can work around it
use __attribute__((__used__)) to informs the compiler that symbol
should be retained in the object file, even if it may be
unreferenced.
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Signed-off-by: Xiaoyu Lu <xiaoyux.lu@intel.com>
---
CryptoPkg/Library/IntrinsicLib/CopyMem.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/CryptoPkg/Library/IntrinsicLib/CopyMem.c b/CryptoPkg/Library/IntrinsicLib/CopyMem.c
index e29b4918d200..7faf5a34d8c1 100644
--- a/CryptoPkg/Library/IntrinsicLib/CopyMem.c
+++ b/CryptoPkg/Library/IntrinsicLib/CopyMem.c
@@ -10,8 +10,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Base.h>
#include <Library/BaseMemoryLib.h>
+#if defined(__clang__) && !defined(__APPLE__)
+
+/* Copies bytes between buffers */
+static __attribute__((__used__))
+void * __memcpy (void *dest, const void *src, unsigned int count)
+{
+ return CopyMem (dest, src, (UINTN)count);
+}
+__attribute__((__alias__("__memcpy")))
+void * memcpy (void *dest, const void *src, unsigned int count);
+
+#else
/* Copies bytes between buffers */
void * memcpy (void *dest, const void *src, unsigned int count)
{
return CopyMem (dest, src, (UINTN)count);
}
+#endif
--
2.7.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem
2019-06-05 5:24 [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem Xiaoyu Lu
@ 2019-06-05 5:56 ` Liming Gao
2019-06-05 6:33 ` Xiaoyu Lu
0 siblings, 1 reply; 11+ messages in thread
From: Liming Gao @ 2019-06-05 5:56 UTC (permalink / raw)
To: devel@edk2.groups.io, Lu, XiaoyuX; +Cc: Bi, Dandan, Wang, Jian J
Xiaoyu:
>-----Original Message-----
>From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
>Xiaoyu Lu
>Sent: Wednesday, June 05, 2019 1:25 PM
>To: devel@edk2.groups.io
>Cc: Lu, XiaoyuX <xiaoyux.lu@intel.com>; Bi, Dandan <dandan.bi@intel.com>;
>Wang, Jian J <jian.j.wang@intel.com>
>Subject: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38
>IA32 build problem
>
>When use clang-3.8 to build the NetworkPkg, compiler optimization
>may use memcpy for memory copy. For example:
>
> CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_rsa.c:918: undefined
> reference to `memcpy'`
>
>Compiler optimization is sophisticated, but we can work around it
>use __attribute__((__used__)) to informs the compiler that symbol
>should be retained in the object file, even if it may be
>unreferenced.
>
>Cc: Jian J Wang <jian.j.wang@intel.com>
>Cc: Dandan Bi <dandan.bi@intel.com>
>Signed-off-by: Xiaoyu Lu <xiaoyux.lu@intel.com>
>---
> CryptoPkg/Library/IntrinsicLib/CopyMem.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
>diff --git a/CryptoPkg/Library/IntrinsicLib/CopyMem.c
>b/CryptoPkg/Library/IntrinsicLib/CopyMem.c
>index e29b4918d200..7faf5a34d8c1 100644
>--- a/CryptoPkg/Library/IntrinsicLib/CopyMem.c
>+++ b/CryptoPkg/Library/IntrinsicLib/CopyMem.c
>@@ -10,8 +10,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> #include <Base.h>
> #include <Library/BaseMemoryLib.h>
>
>+#if defined(__clang__) && !defined(__APPLE__)
So, this change is only for CLANG tool chain.
>+
>+/* Copies bytes between buffers */
>+static __attribute__((__used__))
What purpose for static?
>+void * __memcpy (void *dest, const void *src, unsigned int count)
>+{
>+ return CopyMem (dest, src, (UINTN)count);
>+}
>+__attribute__((__alias__("__memcpy")))
>+void * memcpy (void *dest, const void *src, unsigned int count);
__memcpy is IA32 Intrinsic API, memcpy is X64 Intrinsic API, right?
Thanks
Liming
>+
>+#else
> /* Copies bytes between buffers */
> void * memcpy (void *dest, const void *src, unsigned int count)
> {
> return CopyMem (dest, src, (UINTN)count);
> }
>+#endif
>--
>2.7.4
>
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem
2019-06-05 5:56 ` [edk2-devel] " Liming Gao
@ 2019-06-05 6:33 ` Xiaoyu Lu
2019-06-05 7:28 ` Liming Gao
2019-06-06 3:38 ` Andrew Fish
0 siblings, 2 replies; 11+ messages in thread
From: Xiaoyu Lu @ 2019-06-05 6:33 UTC (permalink / raw)
To: Gao, Liming, devel@edk2.groups.io; +Cc: Bi, Dandan, Wang, Jian J
Hi Liming,
> -----Original Message-----
> From: Gao, Liming
> Sent: Wednesday, June 5, 2019 1:57 PM
> To: devel@edk2.groups.io; Lu, XiaoyuX <xiaoyux.lu@intel.com>
> Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J <jian.j.wang@intel.com>
> Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> CLANG38 IA32 build problem
>
> Xiaoyu:
>
> >-----Original Message-----
> >From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> >Xiaoyu Lu
> >Sent: Wednesday, June 05, 2019 1:25 PM
> >To: devel@edk2.groups.io
> >Cc: Lu, XiaoyuX <xiaoyux.lu@intel.com>; Bi, Dandan
> <dandan.bi@intel.com>;
> >Wang, Jian J <jian.j.wang@intel.com>
> >Subject: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38
> >IA32 build problem
> >
> >When use clang-3.8 to build the NetworkPkg, compiler optimization
> >may use memcpy for memory copy. For example:
> >
> > CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_rsa.c:918: undefined
> > reference to `memcpy'`
> >
> >Compiler optimization is sophisticated, but we can work around it
> >use __attribute__((__used__)) to informs the compiler that symbol
> >should be retained in the object file, even if it may be
> >unreferenced.
> >
> >Cc: Jian J Wang <jian.j.wang@intel.com>
> >Cc: Dandan Bi <dandan.bi@intel.com>
> >Signed-off-by: Xiaoyu Lu <xiaoyux.lu@intel.com>
> >---
> > CryptoPkg/Library/IntrinsicLib/CopyMem.c | 13 +++++++++++++
> > 1 file changed, 13 insertions(+)
> >
> >diff --git a/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> >b/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> >index e29b4918d200..7faf5a34d8c1 100644
> >--- a/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> >+++ b/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> >@@ -10,8 +10,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> > #include <Base.h>
> > #include <Library/BaseMemoryLib.h>
> >
> >+#if defined(__clang__) && !defined(__APPLE__)
>
> So, this change is only for CLANG tool chain.
>
> >+
> >+/* Copies bytes between buffers */
> >+static __attribute__((__used__))
>
> What purpose for static?
>
Because I want __memcpy only use in this file scope.
> >+void * __memcpy (void *dest, const void *src, unsigned int count)
> >+{
> >+ return CopyMem (dest, src, (UINTN)count);
> >+}
> >+__attribute__((__alias__("__memcpy")))
> >+void * memcpy (void *dest, const void *src, unsigned int count);
>
> __memcpy is IA32 Intrinsic API, memcpy is X64 Intrinsic API, right?
>
__memcpy isn't IA32 Intrinsic API, only memcpy is intrinsic API for both IA32 and X64.
The reason I alias memcpy and use __attribute__((__used__)) is let compiler retain symbol in object file,
So it can link correct.
Is this correct?
> Thanks
> Liming
> >+
> >+#else
> > /* Copies bytes between buffers */
> > void * memcpy (void *dest, const void *src, unsigned int count)
> > {
> > return CopyMem (dest, src, (UINTN)count);
> > }
> >+#endif
> >--
> >2.7.4
> >
> >
> >
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem
2019-06-05 6:33 ` Xiaoyu Lu
@ 2019-06-05 7:28 ` Liming Gao
2019-06-05 7:34 ` Xiaoyu Lu
2019-06-06 3:38 ` Andrew Fish
1 sibling, 1 reply; 11+ messages in thread
From: Liming Gao @ 2019-06-05 7:28 UTC (permalink / raw)
To: Lu, XiaoyuX, devel@edk2.groups.io; +Cc: Bi, Dandan, Wang, Jian J
Xiaoyu:
> -----Original Message-----
> From: Lu, XiaoyuX
> Sent: Wednesday, June 5, 2019 2:34 PM
> To: Gao, Liming <liming.gao@intel.com>; devel@edk2.groups.io
> Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J <jian.j.wang@intel.com>
> Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem
>
> Hi Liming,
>
> > -----Original Message-----
> > From: Gao, Liming
> > Sent: Wednesday, June 5, 2019 1:57 PM
> > To: devel@edk2.groups.io; Lu, XiaoyuX <xiaoyux.lu@intel.com>
> > Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J <jian.j.wang@intel.com>
> > Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> > CLANG38 IA32 build problem
> >
> > Xiaoyu:
> >
> > >-----Original Message-----
> > >From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> > >Xiaoyu Lu
> > >Sent: Wednesday, June 05, 2019 1:25 PM
> > >To: devel@edk2.groups.io
> > >Cc: Lu, XiaoyuX <xiaoyux.lu@intel.com>; Bi, Dandan
> > <dandan.bi@intel.com>;
> > >Wang, Jian J <jian.j.wang@intel.com>
> > >Subject: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38
> > >IA32 build problem
> > >
> > >When use clang-3.8 to build the NetworkPkg, compiler optimization
> > >may use memcpy for memory copy. For example:
> > >
> > > CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_rsa.c:918: undefined
> > > reference to `memcpy'`
> > >
> > >Compiler optimization is sophisticated, but we can work around it
> > >use __attribute__((__used__)) to informs the compiler that symbol
> > >should be retained in the object file, even if it may be
> > >unreferenced.
> > >
> > >Cc: Jian J Wang <jian.j.wang@intel.com>
> > >Cc: Dandan Bi <dandan.bi@intel.com>
> > >Signed-off-by: Xiaoyu Lu <xiaoyux.lu@intel.com>
> > >---
> > > CryptoPkg/Library/IntrinsicLib/CopyMem.c | 13 +++++++++++++
> > > 1 file changed, 13 insertions(+)
> > >
> > >diff --git a/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > >b/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > >index e29b4918d200..7faf5a34d8c1 100644
> > >--- a/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > >+++ b/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > >@@ -10,8 +10,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> > > #include <Base.h>
> > > #include <Library/BaseMemoryLib.h>
> > >
> > >+#if defined(__clang__) && !defined(__APPLE__)
> >
> > So, this change is only for CLANG tool chain.
> >
> > >+
> > >+/* Copies bytes between buffers */
> > >+static __attribute__((__used__))
> >
> > What purpose for static?
> >
>
> Because I want __memcpy only use in this file scope.
>
> > >+void * __memcpy (void *dest, const void *src, unsigned int count)
> > >+{
> > >+ return CopyMem (dest, src, (UINTN)count);
> > >+}
> > >+__attribute__((__alias__("__memcpy")))
> > >+void * memcpy (void *dest, const void *src, unsigned int count);
> >
> > __memcpy is IA32 Intrinsic API, memcpy is X64 Intrinsic API, right?
> >
>
> __memcpy isn't IA32 Intrinsic API, only memcpy is intrinsic API for both IA32 and X64.
>
> The reason I alias memcpy and use __attribute__((__used__)) is let compiler retain symbol in object file,
> So it can link correct.
>
> Is this correct?
>
Make sense. What test have been done by you? Build pass and Boot pass?
> > Thanks
> > Liming
>
> > >+
> > >+#else
> > > /* Copies bytes between buffers */
> > > void * memcpy (void *dest, const void *src, unsigned int count)
> > > {
> > > return CopyMem (dest, src, (UINTN)count);
> > > }
> > >+#endif
> > >--
> > >2.7.4
> > >
> > >
> > >
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem
2019-06-05 7:28 ` Liming Gao
@ 2019-06-05 7:34 ` Xiaoyu Lu
2019-06-05 7:37 ` Liming Gao
0 siblings, 1 reply; 11+ messages in thread
From: Xiaoyu Lu @ 2019-06-05 7:34 UTC (permalink / raw)
To: Gao, Liming, devel@edk2.groups.io; +Cc: Bi, Dandan, Wang, Jian J
Liming,
> -----Original Message-----
> From: Gao, Liming
> Sent: Wednesday, June 5, 2019 3:28 PM
> To: Lu, XiaoyuX <xiaoyux.lu@intel.com>; devel@edk2.groups.io
> Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J <jian.j.wang@intel.com>
> Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> CLANG38 IA32 build problem
>
> Xiaoyu:
>
> > -----Original Message-----
> > From: Lu, XiaoyuX
> > Sent: Wednesday, June 5, 2019 2:34 PM
> > To: Gao, Liming <liming.gao@intel.com>; devel@edk2.groups.io
> > Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J
> <jian.j.wang@intel.com>
> > Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> CLANG38 IA32 build problem
> >
> > Hi Liming,
> >
> > > -----Original Message-----
> > > From: Gao, Liming
> > > Sent: Wednesday, June 5, 2019 1:57 PM
> > > To: devel@edk2.groups.io; Lu, XiaoyuX <xiaoyux.lu@intel.com>
> > > Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J
> <jian.j.wang@intel.com>
> > > Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> > > CLANG38 IA32 build problem
> > >
> > > Xiaoyu:
> > >
> > > >-----Original Message-----
> > > >From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf
> Of
> > > >Xiaoyu Lu
> > > >Sent: Wednesday, June 05, 2019 1:25 PM
> > > >To: devel@edk2.groups.io
> > > >Cc: Lu, XiaoyuX <xiaoyux.lu@intel.com>; Bi, Dandan
> > > <dandan.bi@intel.com>;
> > > >Wang, Jian J <jian.j.wang@intel.com>
> > > >Subject: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> CLANG38
> > > >IA32 build problem
> > > >
> > > >When use clang-3.8 to build the NetworkPkg, compiler optimization
> > > >may use memcpy for memory copy. For example:
> > > >
> > > > CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_rsa.c:918: undefined
> > > > reference to `memcpy'`
> > > >
> > > >Compiler optimization is sophisticated, but we can work around it
> > > >use __attribute__((__used__)) to informs the compiler that symbol
> > > >should be retained in the object file, even if it may be
> > > >unreferenced.
> > > >
> > > >Cc: Jian J Wang <jian.j.wang@intel.com>
> > > >Cc: Dandan Bi <dandan.bi@intel.com>
> > > >Signed-off-by: Xiaoyu Lu <xiaoyux.lu@intel.com>
> > > >---
> > > > CryptoPkg/Library/IntrinsicLib/CopyMem.c | 13 +++++++++++++
> > > > 1 file changed, 13 insertions(+)
> > > >
> > > >diff --git a/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > > >b/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > > >index e29b4918d200..7faf5a34d8c1 100644
> > > >--- a/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > > >+++ b/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > > >@@ -10,8 +10,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> > > > #include <Base.h>
> > > > #include <Library/BaseMemoryLib.h>
> > > >
> > > >+#if defined(__clang__) && !defined(__APPLE__)
> > >
> > > So, this change is only for CLANG tool chain.
> > >
> > > >+
> > > >+/* Copies bytes between buffers */
> > > >+static __attribute__((__used__))
> > >
> > > What purpose for static?
> > >
> >
> > Because I want __memcpy only use in this file scope.
> >
> > > >+void * __memcpy (void *dest, const void *src, unsigned int count)
> > > >+{
> > > >+ return CopyMem (dest, src, (UINTN)count);
> > > >+}
> > > >+__attribute__((__alias__("__memcpy")))
> > > >+void * memcpy (void *dest, const void *src, unsigned int count);
> > >
> > > __memcpy is IA32 Intrinsic API, memcpy is X64 Intrinsic API, right?
> > >
> >
> > __memcpy isn't IA32 Intrinsic API, only memcpy is intrinsic API for both
> IA32 and X64.
> >
> > The reason I alias memcpy and use __attribute__((__used__)) is let
> compiler retain symbol in object file,
> > So it can link correct.
> >
> > Is this correct?
> >
>
> Make sense. What test have been done by you? Build pass and Boot pass?
>
Build pass and BaseCryptLib functions test pass.
I don't test http boot.
Thanks,
Xiaoyu
> > > Thanks
> > > Liming
> >
> > > >+
> > > >+#else
> > > > /* Copies bytes between buffers */
> > > > void * memcpy (void *dest, const void *src, unsigned int count)
> > > > {
> > > > return CopyMem (dest, src, (UINTN)count);
> > > > }
> > > >+#endif
> > > >--
> > > >2.7.4
> > > >
> > > >
> > > >
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem
2019-06-05 7:34 ` Xiaoyu Lu
@ 2019-06-05 7:37 ` Liming Gao
2019-06-05 7:50 ` Xiaoyu Lu
0 siblings, 1 reply; 11+ messages in thread
From: Liming Gao @ 2019-06-05 7:37 UTC (permalink / raw)
To: Lu, XiaoyuX, devel@edk2.groups.io; +Cc: Bi, Dandan, Wang, Jian J
Do you cover IA32 & X64 arch both, and verify Ovmf boot?
> -----Original Message-----
> From: Lu, XiaoyuX
> Sent: Wednesday, June 5, 2019 3:35 PM
> To: Gao, Liming <liming.gao@intel.com>; devel@edk2.groups.io
> Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J <jian.j.wang@intel.com>
> Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem
>
> Liming,
>
> > -----Original Message-----
> > From: Gao, Liming
> > Sent: Wednesday, June 5, 2019 3:28 PM
> > To: Lu, XiaoyuX <xiaoyux.lu@intel.com>; devel@edk2.groups.io
> > Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J <jian.j.wang@intel.com>
> > Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> > CLANG38 IA32 build problem
> >
> > Xiaoyu:
> >
> > > -----Original Message-----
> > > From: Lu, XiaoyuX
> > > Sent: Wednesday, June 5, 2019 2:34 PM
> > > To: Gao, Liming <liming.gao@intel.com>; devel@edk2.groups.io
> > > Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J
> > <jian.j.wang@intel.com>
> > > Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> > CLANG38 IA32 build problem
> > >
> > > Hi Liming,
> > >
> > > > -----Original Message-----
> > > > From: Gao, Liming
> > > > Sent: Wednesday, June 5, 2019 1:57 PM
> > > > To: devel@edk2.groups.io; Lu, XiaoyuX <xiaoyux.lu@intel.com>
> > > > Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J
> > <jian.j.wang@intel.com>
> > > > Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> > > > CLANG38 IA32 build problem
> > > >
> > > > Xiaoyu:
> > > >
> > > > >-----Original Message-----
> > > > >From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf
> > Of
> > > > >Xiaoyu Lu
> > > > >Sent: Wednesday, June 05, 2019 1:25 PM
> > > > >To: devel@edk2.groups.io
> > > > >Cc: Lu, XiaoyuX <xiaoyux.lu@intel.com>; Bi, Dandan
> > > > <dandan.bi@intel.com>;
> > > > >Wang, Jian J <jian.j.wang@intel.com>
> > > > >Subject: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> > CLANG38
> > > > >IA32 build problem
> > > > >
> > > > >When use clang-3.8 to build the NetworkPkg, compiler optimization
> > > > >may use memcpy for memory copy. For example:
> > > > >
> > > > > CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_rsa.c:918: undefined
> > > > > reference to `memcpy'`
> > > > >
> > > > >Compiler optimization is sophisticated, but we can work around it
> > > > >use __attribute__((__used__)) to informs the compiler that symbol
> > > > >should be retained in the object file, even if it may be
> > > > >unreferenced.
> > > > >
> > > > >Cc: Jian J Wang <jian.j.wang@intel.com>
> > > > >Cc: Dandan Bi <dandan.bi@intel.com>
> > > > >Signed-off-by: Xiaoyu Lu <xiaoyux.lu@intel.com>
> > > > >---
> > > > > CryptoPkg/Library/IntrinsicLib/CopyMem.c | 13 +++++++++++++
> > > > > 1 file changed, 13 insertions(+)
> > > > >
> > > > >diff --git a/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > > > >b/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > > > >index e29b4918d200..7faf5a34d8c1 100644
> > > > >--- a/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > > > >+++ b/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > > > >@@ -10,8 +10,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> > > > > #include <Base.h>
> > > > > #include <Library/BaseMemoryLib.h>
> > > > >
> > > > >+#if defined(__clang__) && !defined(__APPLE__)
> > > >
> > > > So, this change is only for CLANG tool chain.
> > > >
> > > > >+
> > > > >+/* Copies bytes between buffers */
> > > > >+static __attribute__((__used__))
> > > >
> > > > What purpose for static?
> > > >
> > >
> > > Because I want __memcpy only use in this file scope.
> > >
> > > > >+void * __memcpy (void *dest, const void *src, unsigned int count)
> > > > >+{
> > > > >+ return CopyMem (dest, src, (UINTN)count);
> > > > >+}
> > > > >+__attribute__((__alias__("__memcpy")))
> > > > >+void * memcpy (void *dest, const void *src, unsigned int count);
> > > >
> > > > __memcpy is IA32 Intrinsic API, memcpy is X64 Intrinsic API, right?
> > > >
> > >
> > > __memcpy isn't IA32 Intrinsic API, only memcpy is intrinsic API for both
> > IA32 and X64.
> > >
> > > The reason I alias memcpy and use __attribute__((__used__)) is let
> > compiler retain symbol in object file,
> > > So it can link correct.
> > >
> > > Is this correct?
> > >
> >
> > Make sense. What test have been done by you? Build pass and Boot pass?
> >
>
> Build pass and BaseCryptLib functions test pass.
> I don't test http boot.
>
> Thanks,
> Xiaoyu
>
> > > > Thanks
> > > > Liming
> > >
> > > > >+
> > > > >+#else
> > > > > /* Copies bytes between buffers */
> > > > > void * memcpy (void *dest, const void *src, unsigned int count)
> > > > > {
> > > > > return CopyMem (dest, src, (UINTN)count);
> > > > > }
> > > > >+#endif
> > > > >--
> > > > >2.7.4
> > > > >
> > > > >
> > > > >
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem
2019-06-05 7:37 ` Liming Gao
@ 2019-06-05 7:50 ` Xiaoyu Lu
2019-06-05 7:56 ` Liming Gao
[not found] ` <15A53E5388BBDBAF.17041@groups.io>
0 siblings, 2 replies; 11+ messages in thread
From: Xiaoyu Lu @ 2019-06-05 7:50 UTC (permalink / raw)
To: Gao, Liming, devel@edk2.groups.io; +Cc: Bi, Dandan, Wang, Jian J
Yes I verify them.
build -p OvmfPkg/OvmfPkgX64.dsc -a X64 -t CLANG38
and
build -p OvmfPkg/OvmfPkgIA32.dsc -a IA32 -t CLANG38
with qemu-system-x86_64
> -----Original Message-----
> From: Gao, Liming
> Sent: Wednesday, June 5, 2019 3:37 PM
> To: Lu, XiaoyuX <xiaoyux.lu@intel.com>; devel@edk2.groups.io
> Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J <jian.j.wang@intel.com>
> Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> CLANG38 IA32 build problem
>
> Do you cover IA32 & X64 arch both, and verify Ovmf boot?
>
> > -----Original Message-----
> > From: Lu, XiaoyuX
> > Sent: Wednesday, June 5, 2019 3:35 PM
> > To: Gao, Liming <liming.gao@intel.com>; devel@edk2.groups.io
> > Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J
> <jian.j.wang@intel.com>
> > Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> CLANG38 IA32 build problem
> >
> > Liming,
> >
> > > -----Original Message-----
> > > From: Gao, Liming
> > > Sent: Wednesday, June 5, 2019 3:28 PM
> > > To: Lu, XiaoyuX <xiaoyux.lu@intel.com>; devel@edk2.groups.io
> > > Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J
> <jian.j.wang@intel.com>
> > > Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> > > CLANG38 IA32 build problem
> > >
> > > Xiaoyu:
> > >
> > > > -----Original Message-----
> > > > From: Lu, XiaoyuX
> > > > Sent: Wednesday, June 5, 2019 2:34 PM
> > > > To: Gao, Liming <liming.gao@intel.com>; devel@edk2.groups.io
> > > > Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J
> > > <jian.j.wang@intel.com>
> > > > Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> > > CLANG38 IA32 build problem
> > > >
> > > > Hi Liming,
> > > >
> > > > > -----Original Message-----
> > > > > From: Gao, Liming
> > > > > Sent: Wednesday, June 5, 2019 1:57 PM
> > > > > To: devel@edk2.groups.io; Lu, XiaoyuX <xiaoyux.lu@intel.com>
> > > > > Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J
> > > <jian.j.wang@intel.com>
> > > > > Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> > > > > CLANG38 IA32 build problem
> > > > >
> > > > > Xiaoyu:
> > > > >
> > > > > >-----Original Message-----
> > > > > >From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On
> Behalf
> > > Of
> > > > > >Xiaoyu Lu
> > > > > >Sent: Wednesday, June 05, 2019 1:25 PM
> > > > > >To: devel@edk2.groups.io
> > > > > >Cc: Lu, XiaoyuX <xiaoyux.lu@intel.com>; Bi, Dandan
> > > > > <dandan.bi@intel.com>;
> > > > > >Wang, Jian J <jian.j.wang@intel.com>
> > > > > >Subject: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> > > CLANG38
> > > > > >IA32 build problem
> > > > > >
> > > > > >When use clang-3.8 to build the NetworkPkg, compiler optimization
> > > > > >may use memcpy for memory copy. For example:
> > > > > >
> > > > > > CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_rsa.c:918: undefined
> > > > > > reference to `memcpy'`
> > > > > >
> > > > > >Compiler optimization is sophisticated, but we can work around it
> > > > > >use __attribute__((__used__)) to informs the compiler that symbol
> > > > > >should be retained in the object file, even if it may be
> > > > > >unreferenced.
> > > > > >
> > > > > >Cc: Jian J Wang <jian.j.wang@intel.com>
> > > > > >Cc: Dandan Bi <dandan.bi@intel.com>
> > > > > >Signed-off-by: Xiaoyu Lu <xiaoyux.lu@intel.com>
> > > > > >---
> > > > > > CryptoPkg/Library/IntrinsicLib/CopyMem.c | 13 +++++++++++++
> > > > > > 1 file changed, 13 insertions(+)
> > > > > >
> > > > > >diff --git a/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > > > > >b/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > > > > >index e29b4918d200..7faf5a34d8c1 100644
> > > > > >--- a/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > > > > >+++ b/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > > > > >@@ -10,8 +10,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> > > > > > #include <Base.h>
> > > > > > #include <Library/BaseMemoryLib.h>
> > > > > >
> > > > > >+#if defined(__clang__) && !defined(__APPLE__)
> > > > >
> > > > > So, this change is only for CLANG tool chain.
> > > > >
> > > > > >+
> > > > > >+/* Copies bytes between buffers */
> > > > > >+static __attribute__((__used__))
> > > > >
> > > > > What purpose for static?
> > > > >
> > > >
> > > > Because I want __memcpy only use in this file scope.
> > > >
> > > > > >+void * __memcpy (void *dest, const void *src, unsigned int count)
> > > > > >+{
> > > > > >+ return CopyMem (dest, src, (UINTN)count);
> > > > > >+}
> > > > > >+__attribute__((__alias__("__memcpy")))
> > > > > >+void * memcpy (void *dest, const void *src, unsigned int count);
> > > > >
> > > > > __memcpy is IA32 Intrinsic API, memcpy is X64 Intrinsic API, right?
> > > > >
> > > >
> > > > __memcpy isn't IA32 Intrinsic API, only memcpy is intrinsic API for
> both
> > > IA32 and X64.
> > > >
> > > > The reason I alias memcpy and use __attribute__((__used__)) is let
> > > compiler retain symbol in object file,
> > > > So it can link correct.
> > > >
> > > > Is this correct?
> > > >
> > >
> > > Make sense. What test have been done by you? Build pass and Boot
> pass?
> > >
> >
> > Build pass and BaseCryptLib functions test pass.
> > I don't test http boot.
> >
> > Thanks,
> > Xiaoyu
> >
> > > > > Thanks
> > > > > Liming
> > > >
> > > > > >+
> > > > > >+#else
> > > > > > /* Copies bytes between buffers */
> > > > > > void * memcpy (void *dest, const void *src, unsigned int count)
> > > > > > {
> > > > > > return CopyMem (dest, src, (UINTN)count);
> > > > > > }
> > > > > >+#endif
> > > > > >--
> > > > > >2.7.4
> > > > > >
> > > > > >
> > > > > >
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem
2019-06-05 7:50 ` Xiaoyu Lu
@ 2019-06-05 7:56 ` Liming Gao
[not found] ` <15A53E5388BBDBAF.17041@groups.io>
1 sibling, 0 replies; 11+ messages in thread
From: Liming Gao @ 2019-06-05 7:56 UTC (permalink / raw)
To: Lu, XiaoyuX, devel@edk2.groups.io; +Cc: Bi, Dandan, Wang, Jian J
That good enough. Reviewed-by: Liming Gao <liming.gao@intel.com>
Thanks
Liming
> -----Original Message-----
> From: Lu, XiaoyuX
> Sent: Wednesday, June 5, 2019 3:51 PM
> To: Gao, Liming <liming.gao@intel.com>; devel@edk2.groups.io
> Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J <jian.j.wang@intel.com>
> Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem
>
> Yes I verify them.
>
> build -p OvmfPkg/OvmfPkgX64.dsc -a X64 -t CLANG38
> and
> build -p OvmfPkg/OvmfPkgIA32.dsc -a IA32 -t CLANG38
>
> with qemu-system-x86_64
>
> > -----Original Message-----
> > From: Gao, Liming
> > Sent: Wednesday, June 5, 2019 3:37 PM
> > To: Lu, XiaoyuX <xiaoyux.lu@intel.com>; devel@edk2.groups.io
> > Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J <jian.j.wang@intel.com>
> > Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> > CLANG38 IA32 build problem
> >
> > Do you cover IA32 & X64 arch both, and verify Ovmf boot?
> >
> > > -----Original Message-----
> > > From: Lu, XiaoyuX
> > > Sent: Wednesday, June 5, 2019 3:35 PM
> > > To: Gao, Liming <liming.gao@intel.com>; devel@edk2.groups.io
> > > Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J
> > <jian.j.wang@intel.com>
> > > Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> > CLANG38 IA32 build problem
> > >
> > > Liming,
> > >
> > > > -----Original Message-----
> > > > From: Gao, Liming
> > > > Sent: Wednesday, June 5, 2019 3:28 PM
> > > > To: Lu, XiaoyuX <xiaoyux.lu@intel.com>; devel@edk2.groups.io
> > > > Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J
> > <jian.j.wang@intel.com>
> > > > Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> > > > CLANG38 IA32 build problem
> > > >
> > > > Xiaoyu:
> > > >
> > > > > -----Original Message-----
> > > > > From: Lu, XiaoyuX
> > > > > Sent: Wednesday, June 5, 2019 2:34 PM
> > > > > To: Gao, Liming <liming.gao@intel.com>; devel@edk2.groups.io
> > > > > Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J
> > > > <jian.j.wang@intel.com>
> > > > > Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> > > > CLANG38 IA32 build problem
> > > > >
> > > > > Hi Liming,
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Gao, Liming
> > > > > > Sent: Wednesday, June 5, 2019 1:57 PM
> > > > > > To: devel@edk2.groups.io; Lu, XiaoyuX <xiaoyux.lu@intel.com>
> > > > > > Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J
> > > > <jian.j.wang@intel.com>
> > > > > > Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> > > > > > CLANG38 IA32 build problem
> > > > > >
> > > > > > Xiaoyu:
> > > > > >
> > > > > > >-----Original Message-----
> > > > > > >From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On
> > Behalf
> > > > Of
> > > > > > >Xiaoyu Lu
> > > > > > >Sent: Wednesday, June 05, 2019 1:25 PM
> > > > > > >To: devel@edk2.groups.io
> > > > > > >Cc: Lu, XiaoyuX <xiaoyux.lu@intel.com>; Bi, Dandan
> > > > > > <dandan.bi@intel.com>;
> > > > > > >Wang, Jian J <jian.j.wang@intel.com>
> > > > > > >Subject: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> > > > CLANG38
> > > > > > >IA32 build problem
> > > > > > >
> > > > > > >When use clang-3.8 to build the NetworkPkg, compiler optimization
> > > > > > >may use memcpy for memory copy. For example:
> > > > > > >
> > > > > > > CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_rsa.c:918: undefined
> > > > > > > reference to `memcpy'`
> > > > > > >
> > > > > > >Compiler optimization is sophisticated, but we can work around it
> > > > > > >use __attribute__((__used__)) to informs the compiler that symbol
> > > > > > >should be retained in the object file, even if it may be
> > > > > > >unreferenced.
> > > > > > >
> > > > > > >Cc: Jian J Wang <jian.j.wang@intel.com>
> > > > > > >Cc: Dandan Bi <dandan.bi@intel.com>
> > > > > > >Signed-off-by: Xiaoyu Lu <xiaoyux.lu@intel.com>
> > > > > > >---
> > > > > > > CryptoPkg/Library/IntrinsicLib/CopyMem.c | 13 +++++++++++++
> > > > > > > 1 file changed, 13 insertions(+)
> > > > > > >
> > > > > > >diff --git a/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > > > > > >b/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > > > > > >index e29b4918d200..7faf5a34d8c1 100644
> > > > > > >--- a/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > > > > > >+++ b/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > > > > > >@@ -10,8 +10,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> > > > > > > #include <Base.h>
> > > > > > > #include <Library/BaseMemoryLib.h>
> > > > > > >
> > > > > > >+#if defined(__clang__) && !defined(__APPLE__)
> > > > > >
> > > > > > So, this change is only for CLANG tool chain.
> > > > > >
> > > > > > >+
> > > > > > >+/* Copies bytes between buffers */
> > > > > > >+static __attribute__((__used__))
> > > > > >
> > > > > > What purpose for static?
> > > > > >
> > > > >
> > > > > Because I want __memcpy only use in this file scope.
> > > > >
> > > > > > >+void * __memcpy (void *dest, const void *src, unsigned int count)
> > > > > > >+{
> > > > > > >+ return CopyMem (dest, src, (UINTN)count);
> > > > > > >+}
> > > > > > >+__attribute__((__alias__("__memcpy")))
> > > > > > >+void * memcpy (void *dest, const void *src, unsigned int count);
> > > > > >
> > > > > > __memcpy is IA32 Intrinsic API, memcpy is X64 Intrinsic API, right?
> > > > > >
> > > > >
> > > > > __memcpy isn't IA32 Intrinsic API, only memcpy is intrinsic API for
> > both
> > > > IA32 and X64.
> > > > >
> > > > > The reason I alias memcpy and use __attribute__((__used__)) is let
> > > > compiler retain symbol in object file,
> > > > > So it can link correct.
> > > > >
> > > > > Is this correct?
> > > > >
> > > >
> > > > Make sense. What test have been done by you? Build pass and Boot
> > pass?
> > > >
> > >
> > > Build pass and BaseCryptLib functions test pass.
> > > I don't test http boot.
> > >
> > > Thanks,
> > > Xiaoyu
> > >
> > > > > > Thanks
> > > > > > Liming
> > > > >
> > > > > > >+
> > > > > > >+#else
> > > > > > > /* Copies bytes between buffers */
> > > > > > > void * memcpy (void *dest, const void *src, unsigned int count)
> > > > > > > {
> > > > > > > return CopyMem (dest, src, (UINTN)count);
> > > > > > > }
> > > > > > >+#endif
> > > > > > >--
> > > > > > >2.7.4
> > > > > > >
> > > > > > >
> > > > > > >
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem
[not found] ` <15A53E5388BBDBAF.17041@groups.io>
@ 2019-06-06 3:23 ` Liming Gao
0 siblings, 0 replies; 11+ messages in thread
From: Liming Gao @ 2019-06-06 3:23 UTC (permalink / raw)
To: devel@edk2.groups.io, Gao, Liming, Lu, XiaoyuX; +Cc: Bi, Dandan, Wang, Jian J
Push @98d8f194e5a646b25b3390825c92949a76689d75
> -----Original Message-----
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Liming Gao
> Sent: Wednesday, June 5, 2019 3:56 PM
> To: Lu, XiaoyuX <xiaoyux.lu@intel.com>; devel@edk2.groups.io
> Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J <jian.j.wang@intel.com>
> Subject: Re: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem
>
> That good enough. Reviewed-by: Liming Gao <liming.gao@intel.com>
>
> Thanks
> Liming
> > -----Original Message-----
> > From: Lu, XiaoyuX
> > Sent: Wednesday, June 5, 2019 3:51 PM
> > To: Gao, Liming <liming.gao@intel.com>; devel@edk2.groups.io
> > Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J <jian.j.wang@intel.com>
> > Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem
> >
> > Yes I verify them.
> >
> > build -p OvmfPkg/OvmfPkgX64.dsc -a X64 -t CLANG38
> > and
> > build -p OvmfPkg/OvmfPkgIA32.dsc -a IA32 -t CLANG38
> >
> > with qemu-system-x86_64
> >
> > > -----Original Message-----
> > > From: Gao, Liming
> > > Sent: Wednesday, June 5, 2019 3:37 PM
> > > To: Lu, XiaoyuX <xiaoyux.lu@intel.com>; devel@edk2.groups.io
> > > Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J <jian.j.wang@intel.com>
> > > Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> > > CLANG38 IA32 build problem
> > >
> > > Do you cover IA32 & X64 arch both, and verify Ovmf boot?
> > >
> > > > -----Original Message-----
> > > > From: Lu, XiaoyuX
> > > > Sent: Wednesday, June 5, 2019 3:35 PM
> > > > To: Gao, Liming <liming.gao@intel.com>; devel@edk2.groups.io
> > > > Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J
> > > <jian.j.wang@intel.com>
> > > > Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> > > CLANG38 IA32 build problem
> > > >
> > > > Liming,
> > > >
> > > > > -----Original Message-----
> > > > > From: Gao, Liming
> > > > > Sent: Wednesday, June 5, 2019 3:28 PM
> > > > > To: Lu, XiaoyuX <xiaoyux.lu@intel.com>; devel@edk2.groups.io
> > > > > Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J
> > > <jian.j.wang@intel.com>
> > > > > Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> > > > > CLANG38 IA32 build problem
> > > > >
> > > > > Xiaoyu:
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Lu, XiaoyuX
> > > > > > Sent: Wednesday, June 5, 2019 2:34 PM
> > > > > > To: Gao, Liming <liming.gao@intel.com>; devel@edk2.groups.io
> > > > > > Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J
> > > > > <jian.j.wang@intel.com>
> > > > > > Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> > > > > CLANG38 IA32 build problem
> > > > > >
> > > > > > Hi Liming,
> > > > > >
> > > > > > > -----Original Message-----
> > > > > > > From: Gao, Liming
> > > > > > > Sent: Wednesday, June 5, 2019 1:57 PM
> > > > > > > To: devel@edk2.groups.io; Lu, XiaoyuX <xiaoyux.lu@intel.com>
> > > > > > > Cc: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J
> > > > > <jian.j.wang@intel.com>
> > > > > > > Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> > > > > > > CLANG38 IA32 build problem
> > > > > > >
> > > > > > > Xiaoyu:
> > > > > > >
> > > > > > > >-----Original Message-----
> > > > > > > >From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On
> > > Behalf
> > > > > Of
> > > > > > > >Xiaoyu Lu
> > > > > > > >Sent: Wednesday, June 05, 2019 1:25 PM
> > > > > > > >To: devel@edk2.groups.io
> > > > > > > >Cc: Lu, XiaoyuX <xiaoyux.lu@intel.com>; Bi, Dandan
> > > > > > > <dandan.bi@intel.com>;
> > > > > > > >Wang, Jian J <jian.j.wang@intel.com>
> > > > > > > >Subject: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
> > > > > CLANG38
> > > > > > > >IA32 build problem
> > > > > > > >
> > > > > > > >When use clang-3.8 to build the NetworkPkg, compiler optimization
> > > > > > > >may use memcpy for memory copy. For example:
> > > > > > > >
> > > > > > > > CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_rsa.c:918: undefined
> > > > > > > > reference to `memcpy'`
> > > > > > > >
> > > > > > > >Compiler optimization is sophisticated, but we can work around it
> > > > > > > >use __attribute__((__used__)) to informs the compiler that symbol
> > > > > > > >should be retained in the object file, even if it may be
> > > > > > > >unreferenced.
> > > > > > > >
> > > > > > > >Cc: Jian J Wang <jian.j.wang@intel.com>
> > > > > > > >Cc: Dandan Bi <dandan.bi@intel.com>
> > > > > > > >Signed-off-by: Xiaoyu Lu <xiaoyux.lu@intel.com>
> > > > > > > >---
> > > > > > > > CryptoPkg/Library/IntrinsicLib/CopyMem.c | 13 +++++++++++++
> > > > > > > > 1 file changed, 13 insertions(+)
> > > > > > > >
> > > > > > > >diff --git a/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > > > > > > >b/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > > > > > > >index e29b4918d200..7faf5a34d8c1 100644
> > > > > > > >--- a/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > > > > > > >+++ b/CryptoPkg/Library/IntrinsicLib/CopyMem.c
> > > > > > > >@@ -10,8 +10,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> > > > > > > > #include <Base.h>
> > > > > > > > #include <Library/BaseMemoryLib.h>
> > > > > > > >
> > > > > > > >+#if defined(__clang__) && !defined(__APPLE__)
> > > > > > >
> > > > > > > So, this change is only for CLANG tool chain.
> > > > > > >
> > > > > > > >+
> > > > > > > >+/* Copies bytes between buffers */
> > > > > > > >+static __attribute__((__used__))
> > > > > > >
> > > > > > > What purpose for static?
> > > > > > >
> > > > > >
> > > > > > Because I want __memcpy only use in this file scope.
> > > > > >
> > > > > > > >+void * __memcpy (void *dest, const void *src, unsigned int count)
> > > > > > > >+{
> > > > > > > >+ return CopyMem (dest, src, (UINTN)count);
> > > > > > > >+}
> > > > > > > >+__attribute__((__alias__("__memcpy")))
> > > > > > > >+void * memcpy (void *dest, const void *src, unsigned int count);
> > > > > > >
> > > > > > > __memcpy is IA32 Intrinsic API, memcpy is X64 Intrinsic API, right?
> > > > > > >
> > > > > >
> > > > > > __memcpy isn't IA32 Intrinsic API, only memcpy is intrinsic API for
> > > both
> > > > > IA32 and X64.
> > > > > >
> > > > > > The reason I alias memcpy and use __attribute__((__used__)) is let
> > > > > compiler retain symbol in object file,
> > > > > > So it can link correct.
> > > > > >
> > > > > > Is this correct?
> > > > > >
> > > > >
> > > > > Make sense. What test have been done by you? Build pass and Boot
> > > pass?
> > > > >
> > > >
> > > > Build pass and BaseCryptLib functions test pass.
> > > > I don't test http boot.
> > > >
> > > > Thanks,
> > > > Xiaoyu
> > > >
> > > > > > > Thanks
> > > > > > > Liming
> > > > > >
> > > > > > > >+
> > > > > > > >+#else
> > > > > > > > /* Copies bytes between buffers */
> > > > > > > > void * memcpy (void *dest, const void *src, unsigned int count)
> > > > > > > > {
> > > > > > > > return CopyMem (dest, src, (UINTN)count);
> > > > > > > > }
> > > > > > > >+#endif
> > > > > > > >--
> > > > > > > >2.7.4
> > > > > > > >
> > > > > > > >
> > > > > > > >
>
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem
2019-06-05 6:33 ` Xiaoyu Lu
2019-06-05 7:28 ` Liming Gao
@ 2019-06-06 3:38 ` Andrew Fish
2019-06-06 3:50 ` Liming Gao
1 sibling, 1 reply; 11+ messages in thread
From: Andrew Fish @ 2019-06-06 3:38 UTC (permalink / raw)
To: devel, xiaoyux.lu; +Cc: Gao, Liming, Bi, Dandan, Wang, Jian J
[-- Attachment #1: Type: text/plain, Size: 3463 bytes --]
> On Jun 4, 2019, at 11:33 PM, Xiaoyu Lu <xiaoyux.lu@intel.com> wrote:
>
> Hi Liming,
>
>> -----Original Message-----
>> From: Gao, Liming
>> Sent: Wednesday, June 5, 2019 1:57 PM
>> To: devel@edk2.groups.io <mailto:devel@edk2.groups.io>; Lu, XiaoyuX <xiaoyux.lu@intel.com <mailto:xiaoyux.lu@intel.com>>
>> Cc: Bi, Dandan <dandan.bi@intel.com <mailto:dandan.bi@intel.com>>; Wang, Jian J <jian.j.wang@intel.com <mailto:jian.j.wang@intel.com>>
>> Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
>> CLANG38 IA32 build problem
>>
>> Xiaoyu:
>>
>>> -----Original Message-----
>>> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
>>> Xiaoyu Lu
>>> Sent: Wednesday, June 05, 2019 1:25 PM
>>> To: devel@edk2.groups.io
>>> Cc: Lu, XiaoyuX <xiaoyux.lu@intel.com>; Bi, Dandan
>> <dandan.bi@intel.com>;
>>> Wang, Jian J <jian.j.wang@intel.com>
>>> Subject: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38
>>> IA32 build problem
>>>
>>> When use clang-3.8 to build the NetworkPkg, compiler optimization
>>> may use memcpy for memory copy. For example:
>>>
>>> CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_rsa.c:918: undefined
>>> reference to `memcpy'`
>>>
>>> Compiler optimization is sophisticated, but we can work around it
>>> use __attribute__((__used__)) to informs the compiler that symbol
>>> should be retained in the object file, even if it may be
>>> unreferenced.
>>>
>>> Cc: Jian J Wang <jian.j.wang@intel.com>
>>> Cc: Dandan Bi <dandan.bi@intel.com>
>>> Signed-off-by: Xiaoyu Lu <xiaoyux.lu@intel.com>
>>> ---
>>> CryptoPkg/Library/IntrinsicLib/CopyMem.c | 13 +++++++++++++
>>> 1 file changed, 13 insertions(+)
>>>
>>> diff --git a/CryptoPkg/Library/IntrinsicLib/CopyMem.c
>>> b/CryptoPkg/Library/IntrinsicLib/CopyMem.c
>>> index e29b4918d200..7faf5a34d8c1 100644
>>> --- a/CryptoPkg/Library/IntrinsicLib/CopyMem.c
>>> +++ b/CryptoPkg/Library/IntrinsicLib/CopyMem.c
>>> @@ -10,8 +10,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
>>> #include <Base.h>
>>> #include <Library/BaseMemoryLib.h>
>>>
>>> +#if defined(__clang__) && !defined(__APPLE__)
>>
>> So, this change is only for CLANG tool chain.
>>
>>> +
>>> +/* Copies bytes between buffers */
>>> +static __attribute__((__used__))
>>
>> What purpose for static?
>>
>
> Because I want __memcpy only use in this file scope.
>
>>> +void * __memcpy (void *dest, const void *src, unsigned int count)
>>> +{
>>> + return CopyMem (dest, src, (UINTN)count);
>>> +}
>>> +__attribute__((__alias__("__memcpy")))
>>> +void * memcpy (void *dest, const void *src, unsigned int count);
>>
>> __memcpy is IA32 Intrinsic API, memcpy is X64 Intrinsic API, right?
>>
>
> __memcpy isn't IA32 Intrinsic API, only memcpy is intrinsic API for both IA32 and X64.
>
> The reason I alias memcpy and use __attribute__((__used__)) is let compiler retain symbol in object file,
> So it can link correct.
>
> Is this correct?
>
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.
Thanks,
Andrew Fish
>> Thanks
>> Liming
>
>>> +
>>> +#else
>>> /* Copies bytes between buffers */
>>> void * memcpy (void *dest, const void *src, unsigned int count)
>>> {
>>> return CopyMem (dest, src, (UINTN)count);
>>> }
>>> +#endif
>>> --
>>> 2.7.4
>>>
>>>
>>>
>
>
>
[-- Attachment #2: Type: text/html, Size: 15270 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem
2019-06-06 3:38 ` Andrew Fish
@ 2019-06-06 3:50 ` Liming Gao
0 siblings, 0 replies; 11+ messages in thread
From: Liming Gao @ 2019-06-06 3:50 UTC (permalink / raw)
To: afish@apple.com, devel@edk2.groups.io, Lu, XiaoyuX
Cc: Bi, Dandan, Wang, Jian J
[-- Attachment #1: Type: text/plain, Size: 3944 bytes --]
Fish:
From: afish@apple.com [mailto:afish@apple.com]
Sent: Thursday, June 6, 2019 11:39 AM
To: devel@edk2.groups.io; Lu, XiaoyuX <xiaoyux.lu@intel.com>
Cc: Gao, Liming <liming.gao@intel.com>; Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J <jian.j.wang@intel.com>
Subject: Re: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem
On Jun 4, 2019, at 11:33 PM, Xiaoyu Lu <xiaoyux.lu@intel.com<mailto:xiaoyux.lu@intel.com>> wrote:
Hi Liming,
-----Original Message-----
From: Gao, Liming
Sent: Wednesday, June 5, 2019 1:57 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Lu, XiaoyuX <xiaoyux.lu@intel.com<mailto:xiaoyux.lu@intel.com>>
Cc: Bi, Dandan <dandan.bi@intel.com<mailto:dandan.bi@intel.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>
Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
CLANG38 IA32 build problem
Xiaoyu:
-----Original Message-----
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> [mailto:devel@edk2.groups.io] On Behalf Of
Xiaoyu Lu
Sent: Wednesday, June 05, 2019 1:25 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>
Cc: Lu, XiaoyuX <xiaoyux.lu@intel.com<mailto:xiaoyux.lu@intel.com>>; Bi, Dandan
<dandan.bi@intel.com<mailto:dandan.bi@intel.com>>;
Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>
Subject: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38
IA32 build problem
When use clang-3.8 to build the NetworkPkg, compiler optimization
may use memcpy for memory copy. For example:
CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_rsa.c:918: undefined
reference to `memcpy'`
Compiler optimization is sophisticated, but we can work around it
use __attribute__((__used__)) to informs the compiler that symbol
should be retained in the object file, even if it may be
unreferenced.
Cc: Jian J Wang <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>
Cc: Dandan Bi <dandan.bi@intel.com<mailto:dandan.bi@intel.com>>
Signed-off-by: Xiaoyu Lu <xiaoyux.lu@intel.com<mailto:xiaoyux.lu@intel.com>>
---
CryptoPkg/Library/IntrinsicLib/CopyMem.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/CryptoPkg/Library/IntrinsicLib/CopyMem.c
b/CryptoPkg/Library/IntrinsicLib/CopyMem.c
index e29b4918d200..7faf5a34d8c1 100644
--- a/CryptoPkg/Library/IntrinsicLib/CopyMem.c
+++ b/CryptoPkg/Library/IntrinsicLib/CopyMem.c
@@ -10,8 +10,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Base.h>
#include <Library/BaseMemoryLib.h>
+#if defined(__clang__) && !defined(__APPLE__)
So, this change is only for CLANG tool chain.
+
+/* Copies bytes between buffers */
+static __attribute__((__used__))
What purpose for static?
Because I want __memcpy only use in this file scope.
+void * __memcpy (void *dest, const void *src, unsigned int count)
+{
+ return CopyMem (dest, src, (UINTN)count);
+}
+__attribute__((__alias__("__memcpy")))
+void * memcpy (void *dest, const void *src, unsigned int count);
__memcpy is IA32 Intrinsic API, memcpy is X64 Intrinsic API, right?
__memcpy isn't IA32 Intrinsic API, only memcpy is intrinsic API for both IA32 and X64.
The reason I alias memcpy and use __attribute__((__used__)) is let compiler retain symbol in object file,
So it can link correct.
Is this correct?
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.
OK. It is for CLANG 3.8. I will check whether the latest CLANG8.0 fixes it.
Thanks,
Andrew Fish
Thanks
Liming
+
+#else
/* Copies bytes between buffers */
void * memcpy (void *dest, const void *src, unsigned int count)
{
return CopyMem (dest, src, (UINTN)count);
}
+#endif
--
2.7.4
[-- Attachment #2: Type: text/html, Size: 12668 bytes --]
^ permalink raw reply related [flat|nested] 11+ messages in thread
end of thread, other threads:[~2019-06-06 3:50 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-05 5:24 [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem Xiaoyu Lu
2019-06-05 5:56 ` [edk2-devel] " Liming Gao
2019-06-05 6:33 ` Xiaoyu Lu
2019-06-05 7:28 ` Liming Gao
2019-06-05 7:34 ` Xiaoyu Lu
2019-06-05 7:37 ` Liming Gao
2019-06-05 7:50 ` Xiaoyu Lu
2019-06-05 7:56 ` Liming Gao
[not found] ` <15A53E5388BBDBAF.17041@groups.io>
2019-06-06 3:23 ` Liming Gao
2019-06-06 3:38 ` Andrew Fish
2019-06-06 3:50 ` Liming Gao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox