From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by mx.groups.io with SMTP id smtpd.web11.8673.1595496789544819646 for ; Thu, 23 Jul 2020 02:33:09 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=BYgOMJ/j; spf=pass (domain: nuviainc.com, ip: 209.85.221.65, mailfrom: leif@nuviainc.com) Received: by mail-wr1-f65.google.com with SMTP id f2so4469791wrp.7 for ; Thu, 23 Jul 2020 02:33:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=E2nf453hnLcPAbeHdYCp/k8L0RWnNiR/qwKhzGzH7a4=; b=BYgOMJ/j51ULzIpDbOv4kpskfX1k0M5sfECoaW+g0d5kig+C6Ed6dDtlgWoKmJJt2g 2xf19Rn/VGsQurQjK9RQrbMpw1HZ6JturGi0n5xVHB/SzOxHJsW0/JATtiPqFUBAKj0t AHyvqipKCP4r0wH27v452O/FqpG4gVJv/ELbQHdBZA2VLpRenjsccfQvb3ciii824Te5 vlRwAE+Qn1/g87CH6zYIgyOfINH/NEKeIfCgtihKLOgkJqCf3W5onSq9lxmL4poT+VMF bodNCDnFzqSLnSx8FHBvYnhR99aaEOuiF7EzcJNjysEXhRJGANbj7Z7JUiDSMV3z3/iI xP1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=E2nf453hnLcPAbeHdYCp/k8L0RWnNiR/qwKhzGzH7a4=; b=uaHIdyj8dS1pNoz+rCkRA2+2fNW0T+bF2eNqOjS2HaC1u1YwUN9vRwDYWcoA7osrCz H1ixX/dDUoBpyhgGUzjCOMGAEGWcG/KLMWMfTUj7W8sYu+vxQrWqraiuaJVtmNckY6FW xmIlL7l00bkEDRj2ETTzpHV0Sgwi+VQ6duHJllkzOsXhwb5KtrOTvfhOoyW97Ce7BXWX iUkgskask6/EisLno24yDoxggdzwJWdjP6DM1WvK9UNKYGCzH7dNmf2T49p4cdCexVCU MHALRndWXkrbU4L8f52rDvV5HQRljlif18NlTkSs0KUYmuQCOehVsfXCpLmrZ5x0Kn2R jaCg== X-Gm-Message-State: AOAM530LPWHiGiDdxS7kp6az1AHrxnYR86hOBoSL6FA0ELbpQ7quM4SH FjqyFaiQ8A8eefchDGz3tDXphUK7kyhrJMqSavsOhzzbYrL7ISwrf1DVkUpBovVbzIzq3/uEVS+ R2Nudkmv2wAZv/MmFQjnroYEzm8lj0+OYNN7ES34h03WZCDkXJdt/zE+cmqhCVwystg== X-Google-Smtp-Source: ABdhPJyLmqU2UAAElbydJ8LE5HDlzbjG9mY5IQ4vOw18NNfvU+Brjs0pfIMRrfQ2LvJG1CJJdlXLCg== X-Received: by 2002:adf:e704:: with SMTP id c4mr3518311wrm.81.1595496787804; Thu, 23 Jul 2020 02:33:07 -0700 (PDT) Return-Path: Received: from vanye ([2001:470:1f09:12f0:b26e:bfff:fea9:f1b8]) by smtp.gmail.com with ESMTPSA id t7sm3013535wmg.41.2020.07.23.02.33.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2020 02:33:07 -0700 (PDT) Date: Thu, 23 Jul 2020 10:33:05 +0100 From: "Leif Lindholm" To: devel@edk2.groups.io, afish@apple.com Cc: bob.c.feng@intel.com, PierreGondois , "Gao, Liming" , "tomas@nuviainc.com" Subject: Re: [edk2-devel] [PATCH V2 1/2] BaseTools: Add gcc flag to warn on void* pointer arithmetic Message-ID: <20200723093305.GJ1337@vanye> References: <20200707083522.138944-1-pierre.gondois@arm.com> <20200707083522.138944-2-pierre.gondois@arm.com> <20200722180534.GG1337@vanye> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi Andrew, Agreed. I also think this should be applied across all architectures, not just ARM/AARCH64. Since Visual Studio has never been been able to compile the affected code, I expect impact to Ia32/X64 to be minimal. Regards, Leif On Wed, Jul 22, 2020 at 19:49:01 -0700, Andrew Fish via groups.io wrote: > 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: > > > > Hi Leif > > > > I agree to revert that 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 sure there is no platform build break with this patch, we will push it again. > > > > Thanks, > > Bob > > > > -----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 > > > > Hi Bob, > > > > This patch also breaks about half of the ARM/AARCH64 platforms in edk2-platforms. I agree it should go in at a later stage, but for now, can we please revert it? > > > > Regards, > > > > Leif > > > > On Mon, Jul 20, 2020 at 04:10:27 +0000, Bob Feng wrote: > >> Reviewed-by: Bob Feng > >> > >> > >> -----Original Message----- > >> From: PierreGondois > >> Sent: Tuesday, July 7, 2020 4:35 PM > >> To: devel@edk2.groups.io > >> Cc: Pierre Gondois ; Feng, Bob C > >> ; Gao, Liming ; > >> tomas.pilar@arm.com; nd@arm.com > >> Subject: [PATCH V2 1/2] BaseTools: Add gcc flag to warn on void* > >> pointer arithmetic > >> > >> From: Pierre Gondois > >> > >> 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. > >> > >> To prevent such pointer arithmetic, the "-Wpointer-arith" > >> flag should be set for all GCC versions. > >> > >> 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." > >> > >> This flag is available since GCC2.95.3 which came out in 2001. > >> > >> Signed-off-by: Pierre Gondois > >> --- > >> > >> 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/Conf/tools_def.template > >> index > >> 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 > >> reserved.
# Portions copyright (c) 2008 - 2009, Apple Inc. All > >> rights reserved.
-# Portions copyright (c) 2011 - 2019, ARM Ltd. > >> All rights reserved.
> >> +# Portions copyright (c) 2011 - 2020, ARM Ltd. All rights > >> +reserved.
> >> # Copyright (c) 2015, Hewlett-Packard Development Company, L.P.
# (C) Copyright 2020, Hewlett Packard Enterprise Development LP
# Copyright (c) Microsoft Corporation > >> @@ -1921,9 +1921,9 @@ NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG = --add-gnu-debuglink=$(DEBUG_DIR)/$(MODULE_N > >> DEFINE GCC_ALL_CC_FLAGS = -g -Os -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -include AutoGen.h -fno-common > >> DEFINE GCC_IA32_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -m32 -malign-double -freorder-blocks -freorder-blocks-and-partition -O2 -mno-stack-arg-probe > >> DEFINE GCC_X64_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -mno-red-zone -Wno-address -mno-stack-arg-probe > >> -DEFINE GCC_ARM_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -mabi=aapcs -fno-short-enums -funsigned-char -ffunction-sections -fdata-sections -fomit-frame-pointer -Wno-address -mthumb -mfloat-abi=soft -fno-pic -fno-pie > >> +DEFINE GCC_ARM_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -Wpointer-arith -mlittle-endian -mabi=aapcs -fno-short-enums -funsigned-char -ffunction-sections -fdata-sections -fomit-frame-pointer -Wno-address -mthumb -mfloat-abi=soft -fno-pic -fno-pie > >> DEFINE GCC_ARM_CC_XIPFLAGS = -mno-unaligned-access > >> -DEFINE GCC_AARCH64_CC_FLAGS = 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-tables -fno-pic -fno-pie -ffixed-x18 > >> +DEFINE GCC_AARCH64_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -Wpointer-arith -mlittle-endian -fno-short-enums -fverbose-asm -funsigned-char -ffunction-sections -fdata-sections -Wno-address -fno-asynchronous-unwind-tables -fno-unwind-tables -fno-pic -fno-pie -ffixed-x18 > >> DEFINE GCC_AARCH64_CC_XIPFLAGS = -mstrict-align -mgeneral-regs-only > >> DEFINE GCC_DLINK_FLAGS_COMMON = -nostdlib --pie > >> DEFINE GCC_DLINK2_FLAGS_COMMON = -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds > >> -- > >> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' > >> > >> > >> > >> > > > > > > > > > > > > > >