public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v1] MdePkg: Use __builtin_offset with CLANGPDB toolchain
@ 2019-11-28  5:56 Alex James
  2019-11-28 13:16 ` [edk2-devel] " Philippe Mathieu-Daudé
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Alex James @ 2019-11-28  5:56 UTC (permalink / raw)
  To: devel; +Cc: Michael D Kinney, Liming Gao

CLANGPDB does not define __GNUC__, but it does define __clang__. Check
for the __clang__ preprocessor definition to use __builtin_offsetof to
implement the OFFSET_OF macro.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Alex James <theracermaster@gmail.com>
---
 MdePkg/Include/Base.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
index 4680e64136..e0bcd0ae67 100644
--- a/MdePkg/Include/Base.h
+++ b/MdePkg/Include/Base.h
@@ -781,11 +781,9 @@ typedef UINTN  *BASE_LIST;
   @return  Offset, in bytes, of field.
 
 **/
-#ifdef __GNUC__
-#if __GNUC__ >= 4
+#if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)
 #define OFFSET_OF(TYPE, Field) ((UINTN) __builtin_offsetof(TYPE, Field))
 #endif
-#endif
 
 #ifndef OFFSET_OF
 #define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field))
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [edk2-devel] [PATCH v1] MdePkg: Use __builtin_offset with CLANGPDB toolchain
  2019-11-28  5:56 [PATCH v1] MdePkg: Use __builtin_offset with CLANGPDB toolchain Alex James
@ 2019-11-28 13:16 ` Philippe Mathieu-Daudé
  2019-11-29  0:23 ` Liming Gao
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-11-28 13:16 UTC (permalink / raw)
  To: devel, theracermaster; +Cc: Michael D Kinney, Liming Gao

On 11/28/19 6:56 AM, Alex James via Groups.Io wrote:
> CLANGPDB does not define __GNUC__, but it does define __clang__. Check
> for the __clang__ preprocessor definition to use __builtin_offsetof to
> implement the OFFSET_OF macro.
> 
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Signed-off-by: Alex James <theracermaster@gmail.com>
> ---
>   MdePkg/Include/Base.h | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
> index 4680e64136..e0bcd0ae67 100644
> --- a/MdePkg/Include/Base.h
> +++ b/MdePkg/Include/Base.h
> @@ -781,11 +781,9 @@ typedef UINTN  *BASE_LIST;
>     @return  Offset, in bytes, of field.
>   
>   **/
> -#ifdef __GNUC__
> -#if __GNUC__ >= 4
> +#if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)
>   #define OFFSET_OF(TYPE, Field) ((UINTN) __builtin_offsetof(TYPE, Field))
>   #endif
> -#endif
>   
>   #ifndef OFFSET_OF
>   #define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field))
> 

Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1] MdePkg: Use __builtin_offset with CLANGPDB toolchain
  2019-11-28  5:56 [PATCH v1] MdePkg: Use __builtin_offset with CLANGPDB toolchain Alex James
  2019-11-28 13:16 ` [edk2-devel] " Philippe Mathieu-Daudé
@ 2019-11-29  0:23 ` Liming Gao
  2019-11-29  6:11 ` Liming Gao
       [not found] ` <15DB8D5B995A93E2.20368@groups.io>
  3 siblings, 0 replies; 7+ messages in thread
From: Liming Gao @ 2019-11-29  0:23 UTC (permalink / raw)
  To: Alex James, devel@edk2.groups.io; +Cc: Kinney, Michael D, Gao, Liming

Alex:
  Do you find the real issue without this fix? Or is this change just an enhancement? 

  As you know, now we are in hard code freeze phase. Only functional bug is allowed. 

Thanks
Liming
>-----Original Message-----
>From: Alex James [mailto:theracermaster@gmail.com]
>Sent: Thursday, November 28, 2019 1:57 PM
>To: devel@edk2.groups.io
>Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming
><liming.gao@intel.com>
>Subject: [PATCH v1] MdePkg: Use __builtin_offset with CLANGPDB toolchain
>
>CLANGPDB does not define __GNUC__, but it does define __clang__. Check
>for the __clang__ preprocessor definition to use __builtin_offsetof to
>implement the OFFSET_OF macro.
>
>Cc: Michael D Kinney <michael.d.kinney@intel.com>
>Cc: Liming Gao <liming.gao@intel.com>
>Signed-off-by: Alex James <theracermaster@gmail.com>
>---
> MdePkg/Include/Base.h | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
>diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
>index 4680e64136..e0bcd0ae67 100644
>--- a/MdePkg/Include/Base.h
>+++ b/MdePkg/Include/Base.h
>@@ -781,11 +781,9 @@ typedef UINTN  *BASE_LIST;
>   @return  Offset, in bytes, of field.
>
>
>
> **/
>
>-#ifdef __GNUC__
>
>-#if __GNUC__ >= 4
>
>+#if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)
>
> #define OFFSET_OF(TYPE, Field) ((UINTN) __builtin_offsetof(TYPE, Field))
>
> #endif
>
>-#endif
>
>
>
> #ifndef OFFSET_OF
>
> #define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field))
>
>--
>2.24.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1] MdePkg: Use __builtin_offset with CLANGPDB toolchain
  2019-11-28  5:56 [PATCH v1] MdePkg: Use __builtin_offset with CLANGPDB toolchain Alex James
  2019-11-28 13:16 ` [edk2-devel] " Philippe Mathieu-Daudé
  2019-11-29  0:23 ` Liming Gao
@ 2019-11-29  6:11 ` Liming Gao
       [not found] ` <15DB8D5B995A93E2.20368@groups.io>
  3 siblings, 0 replies; 7+ messages in thread
From: Liming Gao @ 2019-11-29  6:11 UTC (permalink / raw)
  To: Alex James, devel@edk2.groups.io; +Cc: Kinney, Michael D

BZ https://bugzilla.tianocore.org/show_bug.cgi?id=2393 is submitted to record this issue. 

This is the corner issue when STATIC_ASSERT and OFFSET_OF are used together. So, I think we can fix it after stable tag 201911.

Thanks
Liming
>-----Original Message-----
>From: Alex James [mailto:theracermaster@gmail.com]
>Sent: Thursday, November 28, 2019 1:57 PM
>To: devel@edk2.groups.io
>Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming
><liming.gao@intel.com>
>Subject: [PATCH v1] MdePkg: Use __builtin_offset with CLANGPDB toolchain
>
>CLANGPDB does not define __GNUC__, but it does define __clang__. Check
>for the __clang__ preprocessor definition to use __builtin_offsetof to
>implement the OFFSET_OF macro.
>
>Cc: Michael D Kinney <michael.d.kinney@intel.com>
>Cc: Liming Gao <liming.gao@intel.com>
>Signed-off-by: Alex James <theracermaster@gmail.com>
>---
> MdePkg/Include/Base.h | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
>diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
>index 4680e64136..e0bcd0ae67 100644
>--- a/MdePkg/Include/Base.h
>+++ b/MdePkg/Include/Base.h
>@@ -781,11 +781,9 @@ typedef UINTN  *BASE_LIST;
>   @return  Offset, in bytes, of field.
>
>
>
> **/
>
>-#ifdef __GNUC__
>
>-#if __GNUC__ >= 4
>
>+#if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)
>
> #define OFFSET_OF(TYPE, Field) ((UINTN) __builtin_offsetof(TYPE, Field))
>
> #endif
>
>-#endif
>
>
>
> #ifndef OFFSET_OF
>
> #define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field))
>
>--
>2.24.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [edk2-devel] [PATCH v1] MdePkg: Use __builtin_offset with CLANGPDB toolchain
       [not found] ` <15DB8D5B995A93E2.20368@groups.io>
@ 2019-12-10  0:50   ` Liming Gao
       [not found]   ` <15DEDC2D7232490F.29160@groups.io>
  1 sibling, 0 replies; 7+ messages in thread
From: Liming Gao @ 2019-12-10  0:50 UTC (permalink / raw)
  To: devel@edk2.groups.io, Gao, Liming, Alex James
  Cc: Kinney, Michael D, Liu, Zhiguang

Alex:
  The change is good. Can you show what test has been done?

Thanks
Liming
>-----Original Message-----
>From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
>Liming Gao
>Sent: Friday, November 29, 2019 2:12 PM
>To: Alex James <theracermaster@gmail.com>; devel@edk2.groups.io
>Cc: Kinney, Michael D <michael.d.kinney@intel.com>
>Subject: Re: [edk2-devel] [PATCH v1] MdePkg: Use __builtin_offset with
>CLANGPDB toolchain
>
>BZ https://bugzilla.tianocore.org/show_bug.cgi?id=2393 is submitted to
>record this issue.
>
>This is the corner issue when STATIC_ASSERT and OFFSET_OF are used
>together. So, I think we can fix it after stable tag 201911.
>
>Thanks
>Liming
>>-----Original Message-----
>>From: Alex James [mailto:theracermaster@gmail.com]
>>Sent: Thursday, November 28, 2019 1:57 PM
>>To: devel@edk2.groups.io
>>Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming
>><liming.gao@intel.com>
>>Subject: [PATCH v1] MdePkg: Use __builtin_offset with CLANGPDB toolchain
>>
>>CLANGPDB does not define __GNUC__, but it does define __clang__. Check
>>for the __clang__ preprocessor definition to use __builtin_offsetof to
>>implement the OFFSET_OF macro.
>>
>>Cc: Michael D Kinney <michael.d.kinney@intel.com>
>>Cc: Liming Gao <liming.gao@intel.com>
>>Signed-off-by: Alex James <theracermaster@gmail.com>
>>---
>> MdePkg/Include/Base.h | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>
>>diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
>>index 4680e64136..e0bcd0ae67 100644
>>--- a/MdePkg/Include/Base.h
>>+++ b/MdePkg/Include/Base.h
>>@@ -781,11 +781,9 @@ typedef UINTN  *BASE_LIST;
>>   @return  Offset, in bytes, of field.
>>
>>
>>
>> **/
>>
>>-#ifdef __GNUC__
>>
>>-#if __GNUC__ >= 4
>>
>>+#if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)
>>
>> #define OFFSET_OF(TYPE, Field) ((UINTN) __builtin_offsetof(TYPE, Field))
>>
>> #endif
>>
>>-#endif
>>
>>
>>
>> #ifndef OFFSET_OF
>>
>> #define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field))
>>
>>--
>>2.24.0
>
>
>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [edk2-devel] [PATCH v1] MdePkg: Use __builtin_offset with CLANGPDB toolchain
       [not found]   ` <15DEDC2D7232490F.29160@groups.io>
@ 2019-12-18  2:06     ` Liming Gao
       [not found]     ` <15E15503EA811A55.14752@groups.io>
  1 sibling, 0 replies; 7+ messages in thread
From: Liming Gao @ 2019-12-18  2:06 UTC (permalink / raw)
  To: devel@edk2.groups.io, Gao, Liming, Alex James
  Cc: Kinney, Michael D, Liu, Zhiguang

Alex has verified this change on OVMF boot to shell. I have no other comment for it. Reviewed-by: Liming Gao <liming.gao@intel.com>

Thanks
Liming
>-----Original Message-----
>From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
>Liming Gao
>Sent: Tuesday, December 10, 2019 8:50 AM
>To: devel@edk2.groups.io; Gao, Liming <liming.gao@intel.com>; Alex James
><theracermaster@gmail.com>
>Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liu, Zhiguang
><zhiguang.liu@intel.com>
>Subject: Re: [edk2-devel] [PATCH v1] MdePkg: Use __builtin_offset with
>CLANGPDB toolchain
>
>Alex:
>  The change is good. Can you show what test has been done?
>
>Thanks
>Liming
>>-----Original Message-----
>>From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
>>Liming Gao
>>Sent: Friday, November 29, 2019 2:12 PM
>>To: Alex James <theracermaster@gmail.com>; devel@edk2.groups.io
>>Cc: Kinney, Michael D <michael.d.kinney@intel.com>
>>Subject: Re: [edk2-devel] [PATCH v1] MdePkg: Use __builtin_offset with
>>CLANGPDB toolchain
>>
>>BZ https://bugzilla.tianocore.org/show_bug.cgi?id=2393 is submitted to
>>record this issue.
>>
>>This is the corner issue when STATIC_ASSERT and OFFSET_OF are used
>>together. So, I think we can fix it after stable tag 201911.
>>
>>Thanks
>>Liming
>>>-----Original Message-----
>>>From: Alex James [mailto:theracermaster@gmail.com]
>>>Sent: Thursday, November 28, 2019 1:57 PM
>>>To: devel@edk2.groups.io
>>>Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming
>>><liming.gao@intel.com>
>>>Subject: [PATCH v1] MdePkg: Use __builtin_offset with CLANGPDB
>toolchain
>>>
>>>CLANGPDB does not define __GNUC__, but it does define __clang__.
>Check
>>>for the __clang__ preprocessor definition to use __builtin_offsetof to
>>>implement the OFFSET_OF macro.
>>>
>>>Cc: Michael D Kinney <michael.d.kinney@intel.com>
>>>Cc: Liming Gao <liming.gao@intel.com>
>>>Signed-off-by: Alex James <theracermaster@gmail.com>
>>>---
>>> MdePkg/Include/Base.h | 4 +---
>>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>>
>>>diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
>>>index 4680e64136..e0bcd0ae67 100644
>>>--- a/MdePkg/Include/Base.h
>>>+++ b/MdePkg/Include/Base.h
>>>@@ -781,11 +781,9 @@ typedef UINTN  *BASE_LIST;
>>>   @return  Offset, in bytes, of field.
>>>
>>>
>>>
>>> **/
>>>
>>>-#ifdef __GNUC__
>>>
>>>-#if __GNUC__ >= 4
>>>
>>>+#if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)
>>>
>>> #define OFFSET_OF(TYPE, Field) ((UINTN) __builtin_offsetof(TYPE, Field))
>>>
>>> #endif
>>>
>>>-#endif
>>>
>>>
>>>
>>> #ifndef OFFSET_OF
>>>
>>> #define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field))
>>>
>>>--
>>>2.24.0
>>
>>
>>
>
>
>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [edk2-devel] [PATCH v1] MdePkg: Use __builtin_offset with CLANGPDB toolchain
       [not found]     ` <15E15503EA811A55.14752@groups.io>
@ 2019-12-20  6:10       ` Liming Gao
  0 siblings, 0 replies; 7+ messages in thread
From: Liming Gao @ 2019-12-20  6:10 UTC (permalink / raw)
  To: devel@edk2.groups.io, Gao, Liming, Alex James
  Cc: Kinney, Michael D, Liu, Zhiguang

merge@796b380ca7d263ca504b82fe5317a78d3546d537

>-----Original Message-----
>From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
>Liming Gao
>Sent: Wednesday, December 18, 2019 10:07 AM
>To: devel@edk2.groups.io; Gao, Liming <liming.gao@intel.com>; Alex James
><theracermaster@gmail.com>
>Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liu, Zhiguang
><zhiguang.liu@intel.com>
>Subject: Re: [edk2-devel] [PATCH v1] MdePkg: Use __builtin_offset with
>CLANGPDB toolchain
>
>Alex has verified this change on OVMF boot to shell. I have no other comment
>for it. Reviewed-by: Liming Gao <liming.gao@intel.com>
>
>Thanks
>Liming
>>-----Original Message-----
>>From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
>>Liming Gao
>>Sent: Tuesday, December 10, 2019 8:50 AM
>>To: devel@edk2.groups.io; Gao, Liming <liming.gao@intel.com>; Alex James
>><theracermaster@gmail.com>
>>Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liu, Zhiguang
>><zhiguang.liu@intel.com>
>>Subject: Re: [edk2-devel] [PATCH v1] MdePkg: Use __builtin_offset with
>>CLANGPDB toolchain
>>
>>Alex:
>>  The change is good. Can you show what test has been done?
>>
>>Thanks
>>Liming
>>>-----Original Message-----
>>>From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
>>>Liming Gao
>>>Sent: Friday, November 29, 2019 2:12 PM
>>>To: Alex James <theracermaster@gmail.com>; devel@edk2.groups.io
>>>Cc: Kinney, Michael D <michael.d.kinney@intel.com>
>>>Subject: Re: [edk2-devel] [PATCH v1] MdePkg: Use __builtin_offset with
>>>CLANGPDB toolchain
>>>
>>>BZ https://bugzilla.tianocore.org/show_bug.cgi?id=2393 is submitted to
>>>record this issue.
>>>
>>>This is the corner issue when STATIC_ASSERT and OFFSET_OF are used
>>>together. So, I think we can fix it after stable tag 201911.
>>>
>>>Thanks
>>>Liming
>>>>-----Original Message-----
>>>>From: Alex James [mailto:theracermaster@gmail.com]
>>>>Sent: Thursday, November 28, 2019 1:57 PM
>>>>To: devel@edk2.groups.io
>>>>Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming
>>>><liming.gao@intel.com>
>>>>Subject: [PATCH v1] MdePkg: Use __builtin_offset with CLANGPDB
>>toolchain
>>>>
>>>>CLANGPDB does not define __GNUC__, but it does define __clang__.
>>Check
>>>>for the __clang__ preprocessor definition to use __builtin_offsetof to
>>>>implement the OFFSET_OF macro.
>>>>
>>>>Cc: Michael D Kinney <michael.d.kinney@intel.com>
>>>>Cc: Liming Gao <liming.gao@intel.com>
>>>>Signed-off-by: Alex James <theracermaster@gmail.com>
>>>>---
>>>> MdePkg/Include/Base.h | 4 +---
>>>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>>>
>>>>diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
>>>>index 4680e64136..e0bcd0ae67 100644
>>>>--- a/MdePkg/Include/Base.h
>>>>+++ b/MdePkg/Include/Base.h
>>>>@@ -781,11 +781,9 @@ typedef UINTN  *BASE_LIST;
>>>>   @return  Offset, in bytes, of field.
>>>>
>>>>
>>>>
>>>> **/
>>>>
>>>>-#ifdef __GNUC__
>>>>
>>>>-#if __GNUC__ >= 4
>>>>
>>>>+#if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)
>>>>
>>>> #define OFFSET_OF(TYPE, Field) ((UINTN) __builtin_offsetof(TYPE, Field))
>>>>
>>>> #endif
>>>>
>>>>-#endif
>>>>
>>>>
>>>>
>>>> #ifndef OFFSET_OF
>>>>
>>>> #define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field))
>>>>
>>>>--
>>>>2.24.0
>>>
>>>
>>>
>>
>>
>>
>
>
>


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-12-20  6:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-28  5:56 [PATCH v1] MdePkg: Use __builtin_offset with CLANGPDB toolchain Alex James
2019-11-28 13:16 ` [edk2-devel] " Philippe Mathieu-Daudé
2019-11-29  0:23 ` Liming Gao
2019-11-29  6:11 ` Liming Gao
     [not found] ` <15DB8D5B995A93E2.20368@groups.io>
2019-12-10  0:50   ` [edk2-devel] " Liming Gao
     [not found]   ` <15DEDC2D7232490F.29160@groups.io>
2019-12-18  2:06     ` Liming Gao
     [not found]     ` <15E15503EA811A55.14752@groups.io>
2019-12-20  6:10       ` Liming Gao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox