From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from ma1-aaemail-dr-lapp01.apple.com (ma1-aaemail-dr-lapp01.apple.com [17.171.2.60]) by mx.groups.io with SMTP id smtpd.web11.4504.1595472550183549482 for ; Wed, 22 Jul 2020 19:49:11 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@apple.com header.s=20180706 header.b=sJ/nIG0r; spf=pass (domain: apple.com, ip: 17.171.2.60, mailfrom: afish@apple.com) Received: from pps.filterd (ma1-aaemail-dr-lapp01.apple.com [127.0.0.1]) by ma1-aaemail-dr-lapp01.apple.com (8.16.0.42/8.16.0.42) with SMTP id 06N2lUwG001672; Wed, 22 Jul 2020 19:49:05 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apple.com; h=from : message-id : content-type : mime-version : subject : date : in-reply-to : cc : to : references; s=20180706; bh=ckoT40Gx3sg0fawRXvRFa0TeEP9X1rsjZg5mBAfcw4g=; b=sJ/nIG0rVFY9NimMKxm6ol7DSYnUizR1Y6nD0ONFV9KbHlV10gTLj3qF1VQu7r7vtcKK iicOTmPA4JxGA4xD4aKjmuJDT3G1n8wDhwxKAbnt+gux68x2q0kMwj1yvJfzSs0LfXUT pK7ICrEzN7IiWUcU7k2ltLzX6QlPgpyHZAuEzcVQ/sIYR58Rygr8fNJ5ec4JFlOUT80s KidqascsBFNFXpaI/z6LPLgh8O8NtsSIXcKOZI/BwkNAtulOiPUDb9D3l2xAClA9zm+y L/c4Shr7JlaR3HCfUK7U0+aWBVxB7Wa8ZR3/arNIpWbBDfFKPn1h/SWOy7e5956kL7/+ tg== Received: from rn-mailsvcp-mta-lapp01.rno.apple.com (rn-mailsvcp-mta-lapp01.rno.apple.com [10.225.203.149]) by ma1-aaemail-dr-lapp01.apple.com with ESMTP id 32byr3f0g2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Wed, 22 Jul 2020 19:49:05 -0700 Received: from rn-mailsvcp-mmp-lapp03.rno.apple.com (rn-mailsvcp-mmp-lapp03.rno.apple.com [17.179.253.16]) by rn-mailsvcp-mta-lapp01.rno.apple.com (Oracle Communications Messaging Server 8.1.0.5.20200312 64bit (built Mar 12 2020)) with ESMTPS id <0QDW00RI8IHSFX80@rn-mailsvcp-mta-lapp01.rno.apple.com>; Wed, 22 Jul 2020 19:49:04 -0700 (PDT) Received: from process_milters-daemon.rn-mailsvcp-mmp-lapp03.rno.apple.com by rn-mailsvcp-mmp-lapp03.rno.apple.com (Oracle Communications Messaging Server 8.1.0.5.20200312 64bit (built Mar 12 2020)) id <0QDW00M00GJQY100@rn-mailsvcp-mmp-lapp03.rno.apple.com>; Wed, 22 Jul 2020 19:49:04 -0700 (PDT) X-Va-A: X-Va-T-CD: e0acb9dc03d22e4581b62f3d752335f3 X-Va-E-CD: e15f0577c23e4745d279058b627e3e75 X-Va-R-CD: 80568e25e4cf3e056de2b659785160ff X-Va-CD: 0 X-Va-ID: 14030693-6f89-407e-969d-87bf7decda14 X-V-A: X-V-T-CD: e0acb9dc03d22e4581b62f3d752335f3 X-V-E-CD: e15f0577c23e4745d279058b627e3e75 X-V-R-CD: 80568e25e4cf3e056de2b659785160ff X-V-CD: 0 X-V-ID: dd880302-bb98-4e29-be81-bc82931e02a9 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-22_17:2020-07-22,2020-07-22 signatures=0 Received: from [17.235.23.115] (unknown [17.235.23.115]) by rn-mailsvcp-mmp-lapp03.rno.apple.com (Oracle Communications Messaging Server 8.1.0.5.20200312 64bit (built Mar 12 2020)) with ESMTPSA id <0QDW0105SIHPS300@rn-mailsvcp-mmp-lapp03.rno.apple.com>; Wed, 22 Jul 2020 19:49:03 -0700 (PDT) From: "Andrew Fish" Message-id: MIME-version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [edk2-devel] [PATCH V2 1/2] BaseTools: Add gcc flag to warn on void* pointer arithmetic Date: Wed, 22 Jul 2020 19:49:01 -0700 In-reply-to: Cc: "leif@nuviainc.com" , PierreGondois , "Gao, Liming" , "tomas@nuviainc.com" To: edk2-devel-groups-io , bob.c.feng@intel.com References: <20200707083522.138944-1-pierre.gondois@arm.com> <20200707083522.138944-2-pierre.gondois@arm.com> <20200722180534.GG1337@vanye> X-Mailer: Apple Mail (2.3608.80.23.2.2) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-22_17:2020-07-22,2020-07-22 signatures=0 Content-type: multipart/alternative; boundary="Apple-Mail=_DF66BD51-62C1-4979-B5A9-02D2BB674863" --Apple-Mail=_DF66BD51-62C1-4979-B5A9-02D2BB674863 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Bob, It also looks like clang could use this flag as the default seems to be to= follow the GCC behavior. Thanks, Andrew Fish > On Jul 22, 2020, at 6:56 PM, Bob Feng wrote: >=20 > Hi Leif >=20 > I agree to revert that patch for now and I sent a revert patch for revie= w. After resolving the build break issue for ARM/AARCH64 platforms in edk2-= platforms, and make sure there is no platform build break with this patch, = we will push it again. >=20 > Thanks, > Bob=20 >=20 > -----Original Message----- > From: devel@edk2.groups.io > On Behalf Of Leif Lindholm > Sent: Thursday, July 23, 2020 2:06 AM > To: devel@edk2.groups.io ; Feng, Bob C > > Cc: PierreGondois >; Gao, Liming >; tomas= @nuviainc.com > Subject: Re: [edk2-devel] [PATCH V2 1/2] BaseTools: Add gcc flag to warn= on void* pointer arithmetic >=20 > Hi Bob, >=20 > This patch also breaks about half of the ARM/AARCH64 platforms in edk2-p= latforms. I agree it should go in at a later stage, but for now, can we ple= ase revert it? >=20 > Regards, >=20 > Leif >=20 > On Mon, Jul 20, 2020 at 04:10:27 +0000, Bob Feng wrote: >> Reviewed-by: Bob Feng >>=20 >>=20 >> -----Original Message----- >> From: PierreGondois >> Sent: Tuesday, July 7, 2020 4:35 PM >> To: devel@edk2.groups.io >> Cc: Pierre Gondois ; Feng, Bob C=20 >> ; Gao, Liming ;=20 >> tomas.pilar@arm.com; nd@arm.com >> Subject: [PATCH V2 1/2] BaseTools: Add gcc flag to warn on void*=20 >> pointer arithmetic >>=20 >> From: Pierre Gondois >>=20 >> By default, gcc allows void* pointer arithmetic. >> This is a GCC extension. >> However: >> - the C reference manual states that void* >> pointer "cannot be operands of addition >> or subtraction operators". Cf s5.3.1 >> "Generic Pointers"; >> - Visual studio compiler treat such operation as >> an error. >>=20 >> To prevent such pointer arithmetic, the "-Wpointer-arith" >> flag should be set for all GCC versions. >>=20 >> The "-Wpointer-arith" allows to: >> "Warn about anything that depends on the "size of" >> a function type or of void. GNU C assigns these >> types a size of 1, for convenience in calculations >> with void * pointers and pointers to functions." >>=20 >> This flag is available since GCC2.95.3 which came out in 2001. >>=20 >> Signed-off-by: Pierre Gondois >> --- >>=20 >> The changes can be seen at:=20 >> https://github.com/PierreARM/edk2/commits/831_Add_gcc_flag_warning_v2 >>=20 >> Notes: >> v1: >> - Add "-Wpointer-arith" gcc flag. [Pierre] >> v2: >> - Only add the flag for ARM and AARCH64. [Tomas] >>=20 >> BaseTools/Conf/tools_def.template | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >>=20 >> diff --git a/BaseTools/Conf/tools_def.template=20 >> b/BaseTools/Conf/tools_def.template >> index=20 >> 8aeb8a2a6417e41c5660cda5066f52adc8cc3089..397b011ba38f97f81f314f8641ac >> 8bb95d5a2197 100755 >> --- a/BaseTools/Conf/tools_def.template >> +++ b/BaseTools/Conf/tools_def.template >> @@ -1,7 +1,7 @@ >> # >> # Copyright (c) 2006 - 2018, Intel Corporation. All rights=20 >> reserved.
# Portions copyright (c) 2008 - 2009, Apple Inc. All=20 >> rights reserved.
-# Portions copyright (c) 2011 - 2019, ARM Ltd.= =20 >> All rights reserved.
>> +# Portions copyright (c) 2011 - 2020, ARM Ltd. All rights=20 >> +reserved.
>> # Copyright (c) 2015, Hewlett-Packard Development Company, L.P.
#= (C) Copyright 2020, Hewlett Packard Enterprise Development LP
# Cop= yright (c) Microsoft Corporation >> @@ -1921,9 +1921,9 @@ NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG =3D --add-gnu-= debuglink=3D$(DEBUG_DIR)/$(MODULE_N >> DEFINE GCC_ALL_CC_FLAGS =3D -g -Os -fshort-wchar -fno-builti= n -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -include AutoGen.h -= fno-common >> DEFINE GCC_IA32_CC_FLAGS =3D DEF(GCC_ALL_CC_FLAGS) -m32 -mali= gn-double -freorder-blocks -freorder-blocks-and-partition -O2 -mno-stack-ar= g-probe >> DEFINE GCC_X64_CC_FLAGS =3D DEF(GCC_ALL_CC_FLAGS) -mno-red-z= one -Wno-address -mno-stack-arg-probe >> -DEFINE GCC_ARM_CC_FLAGS =3D DEF(GCC_ALL_CC_FLAGS) -mlittle-= endian -mabi=3Daapcs -fno-short-enums -funsigned-char -ffunction-sections -= fdata-sections -fomit-frame-pointer -Wno-address -mthumb -mfloat-abi=3Dsoft= -fno-pic -fno-pie >> +DEFINE GCC_ARM_CC_FLAGS =3D DEF(GCC_ALL_CC_FLAGS) -Wpointer= -arith -mlittle-endian -mabi=3Daapcs -fno-short-enums -funsigned-char -ffun= ction-sections -fdata-sections -fomit-frame-pointer -Wno-address -mthumb -m= float-abi=3Dsoft -fno-pic -fno-pie >> DEFINE GCC_ARM_CC_XIPFLAGS =3D -mno-unaligned-access >> -DEFINE GCC_AARCH64_CC_FLAGS =3D DEF(GCC_ALL_CC_FLAGS) -mlittle-= endian -fno-short-enums -fverbose-asm -funsigned-char -ffunction-sections = -fdata-sections -Wno-address -fno-asynchronous-unwind-tables -fno-unwind-ta= bles -fno-pic -fno-pie -ffixed-x18 >> +DEFINE GCC_AARCH64_CC_FLAGS =3D DEF(GCC_ALL_CC_FLAGS) -Wpointer= -arith -mlittle-endian -fno-short-enums -fverbose-asm -funsigned-char -ffun= ction-sections -fdata-sections -Wno-address -fno-asynchronous-unwind-tables= -fno-unwind-tables -fno-pic -fno-pie -ffixed-x18 >> DEFINE GCC_AARCH64_CC_XIPFLAGS =3D -mstrict-align -mgeneral-regs-on= ly >> DEFINE GCC_DLINK_FLAGS_COMMON =3D -nostdlib --pie >> DEFINE GCC_DLINK2_FLAGS_COMMON =3D -Wl,--script=3D$(EDK_TOOLS_PATH)= /Scripts/GccBase.lds >> -- >> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' >>=20 >>=20 >>=20 >>=20 >=20 >=20 >=20 >=20 >=20 --Apple-Mail=_DF66BD51-62C1-4979-B5A9-02D2BB674863 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii Bob,
It also looks like clang could use this = flag as the default seems to be to follow the GCC behavior.

Thanks,
Andrew Fish

On Jul 22, 2020= , at 6:56 PM, Bob Feng <bob.c.feng@intel.com> wrote:

Hi Leif

I agree to revert t= hat patch for now and I sent a revert patch for review. After resolving the= build break issue for ARM/AARCH64 platforms in edk2-platforms, and make su= re there is no platform build break with this patch, we will push it again.=

Thanks,
Bob 

--= ---Original Message-----
From: devel@edk2.groups.io = ;<devel@edk2.groups.io> On Behalf= Of Leif Lindholm
Sen= t: Thursday, July 23, 2020 2:06 AM
To: = devel@edk2.groups.io; Feng, Bob C <bob.c.feng@intel.com>
Cc: PierreGondois <pierre.gondoi= s@arm.com>; Gao, Liming <liming.gao@inte= l.com>; tomas@nuviainc.com
<= span style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size:= 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; = letter-spacing: normal; text-align: start; text-indent: 0px; text-transform= : none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: = 0px; text-decoration: none; float: none; display: inline !important;" class= = =3D"">Subject: Re: [edk2-devel] [PATCH V2 1/2] BaseTools: Add gcc flag to = warn on void* pointer arithmetic


Hi Bob,

Th= is patch also breaks about half of the ARM/AARCH64 platforms in edk2-platfo= rms. I agree it should go in at a later stage, but for now, can we please r= evert it?

Regards,

Leif

On Mon, Jul 20, 2020 at 04:10:27 +0000, Bob Feng wrote:
Reviewed-by: Bob Feng<= ;bob.c.feng@intel.com>


-----Original Message----= -
From: PierreGondois <
pierre.gondois@arm.com>
Sent: Tuesda= y, July 7, 2020 4:35 PM
To: devel@edk2.groups.io
Cc: Pierre Gondois= <Pierre.Gondois@ar= m.com>; Feng, Bob C 
<bob= .c.feng@intel.com>; Gao, Liming <liming.gao@intel.com>; 
tomas.pilar@arm.com; nd@arm.com
Subject: [PATCH V2 1/2] BaseTools: Add = gcc flag to warn on void* 
pointer arithmetic

From: Pierr= e Gondois <pierre.g= ondois@arm.com>

By default, gcc allows = void* pointer arithmetic.
This is a GCC extension.
However:
- the C reference manual states that void*  pointer "cannot be operands of addition
  or subtraction operators". Cf s5.3.1
 &nb= sp;"Generic Pointers";
- Visual studio compiler treat such op= eration as
  an error.

To prevent such pointer arithmetic, the "-Wpointer-arith"
fl= ag should be set for all GCC versions.

The "-W= pointer-arith"  allows to:
 "Warn about anything th= at depends on the "size of"
 a function type or of void.= GNU C assigns these
 types a size of 1, for convenience= in calculations
 with void * pointers and pointers to f= unctions."

This flag is available since GCC2.9= 5.3 which came out in 2001.

Signed-off-by: Pie= rre Gondois <pierre= .gondois@arm.com>
---

The= changes can be seen at: =
https://github.com/PierreARM/edk2/commits/= 831_Add_gcc_flag_warning_v2

Notes:
   v1:
    - Add "-= Wpointer-arith" gcc flag. [Pierre]
   v2:
    - Only add the flag for ARM and AARCH64. = [Tomas]

BaseTools/Conf/tools_def.template | 6 = +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Con= f/tools_def.template
index 
8aeb8a2a6417e41c5660cda5066f52adc8cc3089..39= 7b011ba38f97f81f314f8641ac
8bb95d5a2197 100755
= --- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/= tools_def.template
@@ -1,7 +1,7 @@
#
#  Copyright (c) 2006 - 2018, Intel Corporation. All rights 

reserved.<= BR>  #  Portions copyright (c) 2008 - 2009, Apple Inc. All 

rights reserv= ed.<BR> -#  Portions copyright (c) 2011 - 2019, ARM Ltd. 
All rights reserv= ed.<BR>
+#  Portions copyright (c) 2011 - 2020, AR= M Ltd. All rights 
+reserved.<BR>
#  Copyright (c) 2015, Hewl= ett-Packard Development Company, L.P.<BR>  #  (C) Copyright= 2020, Hewlett Packard Enterprise Development LP<BR>  #  Co= pyright (c) Microsoft Corporation
@@ -1921,9 +1921,9 @@ NOOPT= _*_*_OBJCOPY_ADDDEBUGFLAG     =3D --add-gnu-debuglink= =3D$(DEBUG_DIR)/$(MODULE_N
DEFINE GCC_ALL_CC_FLAGS  &nb= sp;         =3D -g -Os -fshort= -wchar -fno-builtin -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -i= nclude AutoGen.h -fno-common
DEFINE GCC_IA32_CC_FLAGS  &= nbsp;        =3D DEF(GCC_ALL_CC_FLA= GS) -m32 -malign-double -freorder-blocks -freorder-blocks-and-partition -O2= -mno-stack-arg-probe
DEFINE GCC_X64_CC_FLAGS   &nb= sp;        =3D DEF(GCC_ALL_CC_FLAGS= ) -mno-red-zone -Wno-address -mno-stack-arg-probe
-DEFINE GCC= _ARM_CC_FLAGS           &= nbsp;=3D DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -mabi=3Daapcs -fno-short-enu= ms -funsigned-char -ffunction-sections -fdata-sections -fomit-frame-pointer= -Wno-address -mthumb -mfloat-abi=3Dsoft -fno-pic -fno-pie
+D= EFINE GCC_ARM_CC_FLAGS         &nbs= p;  =3D DEF(GCC_ALL_CC_FLAGS) -Wpointer-arith -mlittle-endian -ma= bi=3Daapcs -fno-short-enums -funsigned-char -ffunction-sections -fdata-sect= ions -fomit-frame-pointer -Wno-address -mthumb -mfloat-abi=3Dsoft -fno-pic = -fno-pie
DEFINE GCC_ARM_CC_XIPFLAGS     &= nbsp;   =3D -mno-unaligned-access
-DEFINE GCC_= AARCH64_CC_FLAGS        =3D DEF(GCC_ALL_= CC_FLAGS) -mlittle-endian -fno-short-enums -fverbose-asm -funsigned-char &n= bsp;-ffunction-sections -fdata-sections -Wno-address -fno-asynchronous-unwi= nd-tables -fno-unwind-tables -fno-pic -fno-pie -ffixed-x18
+D= EFINE GCC_AARCH64_CC_FLAGS        =3D DE= F(GCC_ALL_CC_FLAGS) -Wpointer-arith -mlittle-endian -fno-short-enums -fverb= ose-asm -funsigned-char -ffunction-sections -fdata-sections -Wno-address -f= no-asynchronous-unwind-tables -fno-unwind-tables -fno-pic -fno-pie -ffixed-= x18
DEFINE GCC_AARCH64_CC_XIPFLAGS     = =3D -mstrict-align -mgeneral-regs-only
DEFINE GCC_DLINK_FLAG= S_COMMON      =3D -nostdlib --pie
DE= FINE GCC_DLINK2_FLAGS_COMMON     =3D -Wl,--script=3D$(E= DK_TOOLS_PATH)/Scripts/GccBase.lds
--
'Guid(CE1= 65669-3EF3-493F-B85D-6190EE5B9759)'









--Apple-Mail=_DF66BD51-62C1-4979-B5A9-02D2BB674863--