* [Patch 2/2] BaseTools: Add GCC flags to Basetool build.
@ 2019-04-30 11:07 Bob Feng
2019-04-30 16:06 ` [edk2-devel] " Laszlo Ersek
0 siblings, 1 reply; 2+ messages in thread
From: Bob Feng @ 2019-04-30 11:07 UTC (permalink / raw)
To: devel; +Cc: Bob Feng, Liming Gao
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 <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
---
| 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--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
--
2.20.1.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [edk2-devel] [Patch 2/2] BaseTools: Add GCC flags to Basetool build.
2019-04-30 11:07 [Patch 2/2] BaseTools: Add GCC flags to Basetool build Bob Feng
@ 2019-04-30 16:06 ` Laszlo Ersek
0 siblings, 0 replies; 2+ messages in thread
From: Laszlo Ersek @ 2019-04-30 16:06 UTC (permalink / raw)
To: devel, bob.c.feng; +Cc: Liming Gao
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 <bob.c.feng@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> ---
> 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 <lersek@redhat.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-30 16:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-30 11:07 [Patch 2/2] BaseTools: Add GCC flags to Basetool build Bob Feng
2019-04-30 16:06 ` [edk2-devel] " Laszlo Ersek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox