From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.132.183.28, mailfrom: lersek@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Tue, 30 Apr 2019 09:06:54 -0700 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 145E730BC654; Tue, 30 Apr 2019 16:06:54 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-121-42.rdu2.redhat.com [10.10.121.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 33BE76248E; Tue, 30 Apr 2019 16:06:51 +0000 (UTC) Subject: Re: [edk2-devel] [Patch 2/2] BaseTools: Add GCC flags to Basetool build. To: devel@edk2.groups.io, bob.c.feng@intel.com Cc: Liming Gao References: <20190430110701.12360-1-bob.c.feng@intel.com> From: "Laszlo Ersek" Message-ID: Date: Tue, 30 Apr 2019 18:06:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190430110701.12360-1-bob.c.feng@intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Tue, 30 Apr 2019 16:06:54 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 04/30/19 13:07, Bob Feng wrote: > BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1764 > > Some compiler flags restrict the compiler from making > arbitrary decisions while handling undefined C/C++ behaviors. > Therefore they can be used to fix some issues caused by undefined behavior. > > For example, for GCC, the following flags are available: > -fno-delete-null-pointer-checks tells > the compiler NOT to assume that null pointer deference does not exist. > -fwrapv tells the compiler that signed overflow always wraps. > > This patch is going to add these 2 build options to > BaseTool GCC build option. > > Signed-off-by: Bob Feng > Cc: Liming Gao > --- > BaseTools/Source/C/Makefiles/header.makefile | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile > index c2397b796c..eac295b4dd 100644 > --- a/BaseTools/Source/C/Makefiles/header.makefile > +++ b/BaseTools/Source/C/Makefiles/header.makefile > @@ -69,11 +69,12 @@ BUILD_OPTFLAGS = -O2 $(EXTRA_OPTFLAGS) > ifeq ($(DARWIN),Darwin) > # assume clang or clang compatible flags on OS X > BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror \ > -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -g > else > -BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror \ > +BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -fwrapv \ > +-fno-delete-null-pointer-checks -Wall -Werror \ > -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-restrict \ > -Wno-unused-result -nostdlib -g > endif > BUILD_LFLAGS = > BUILD_CXXFLAGS = -Wno-unused-result > Reviewed-by: Laszlo Ersek