[edk2-devel] [PATCH v1 1/2] BaseTools: Make undefined VFR macro an error (GCC)

Daniel Schaefer daniel.schaefer at hpe.com
Fri Apr 23 08:22:11 UTC 2021


Ok sure, let's make only undef an error, not all other warnings. Then the behaviour will also be the same as on MSVC.
________________________________
From: devel at edk2.groups.io <devel at edk2.groups.io> on behalf of Daniel Schaefer <daniel.schaefer at hpe.com>
Sent: Monday, March 8, 2021 11:44
To: Feng, Bob C <bob.c.feng at intel.com>; devel at edk2.groups.io <devel at edk2.groups.io>
Cc: Liming Gao <gaoliming at byosoft.com.cn>; Chen, Christine <yuwei.chen at intel.com>; Lin, Derek (HPS SW) <derek.lin2 at hpe.com>
Subject: Re: [edk2-devel] [PATCH v1 1/2] BaseTools: Make undefined VFR macro an error (GCC)

It didn't cause any other errors for the huge HPE codebase. Only undefined macros. I don't believe the preprocessor has so many warnings anyways.
So -Werror should be fine.

________________________________
From: Feng, Bob C <bob.c.feng at intel.com>
Sent: Monday, March 8, 2021 09:05
To: devel at edk2.groups.io <devel at edk2.groups.io>; Schaefer, Daniel <daniel.schaefer at hpe.com>
Cc: Liming Gao <gaoliming at byosoft.com.cn>; Chen, Christine <yuwei.chen at intel.com>; Lin, Derek (HPS SW) <derek.lin2 at hpe.com>
Subject: RE: [edk2-devel] [PATCH v1 1/2] BaseTools: Make undefined VFR macro an error (GCC)

Hi Derek,

-Werror.  Make all warnings into errors.

Should here be that only treat undef warning as error?

Thanks,
Bob

-----Original Message-----
From: devel at edk2.groups.io <devel at edk2.groups.io> On Behalf Of Daniel Schaefer
Sent: Tuesday, March 2, 2021 4:22 PM
To: devel at edk2.groups.io
Cc: Feng, Bob C <bob.c.feng at intel.com>; Liming Gao <gaoliming at byosoft.com.cn>; Chen, Christine <yuwei.chen at intel.com>; Derek Lin <derek.lin2 at hpe.com>
Subject: [edk2-devel] [PATCH v1 1/2] BaseTools: Make undefined VFR macro an error (GCC)

VFR successfully compiles if we forget to include a header that defines a macro. In that case the HII option was hidden when it shouldn't be just because the macro was used but not defined.

The behaviour is totally intended by the C/PP standard. When a macro is undefined it evaluates to 0.
GCC, MSVC and Clang have warnings to catch this type of mistake. With this commit we enable this warning and make it a compiler error.

Cc: Bob Feng <bob.c.feng at intel.com>
Cc: Liming Gao <gaoliming at byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen at intel.com>
Cc: Derek Lin <derek.lin2 at hpe.com>
---
 BaseTools/Conf/tools_def.template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
index 933b3160fd2b..728c1d3119e4 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -3,7 +3,7 @@
 #  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>  #  Portions copyright (c) 2011 - 2019, ARM Ltd. All rights reserved.<BR>  #  Copyright (c) 2015, Hewlett-Packard Development Company, L.P.<BR> -#  (C) Copyright 2020, Hewlett Packard Enterprise Development LP<BR>
+#  (C) Copyright 2020-2021, Hewlett Packard Enterprise Development
+LP<BR>
 #  Copyright (c) Microsoft Corporation
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent @@ -1938,7 +1938,7 @@ DEFINE GCC_AARCH64_ASLDLINK_FLAGS  = DEF(GCC_AARCH64_DLINK_FLAGS) -Wl,--entry,Re
 DEFINE GCC_IA32_X64_DLINK_FLAGS    = DEF(GCC_IA32_X64_DLINK_COMMON) --entry _$(IMAGE_ENTRY_POINT) --file-alignment 0x20 --section-alignment 0x20 -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
 DEFINE GCC_ASM_FLAGS               = -c -x assembler -imacros AutoGen.h
 DEFINE GCC_PP_FLAGS                = -E -x assembler-with-cpp -include AutoGen.h
-DEFINE GCC_VFRPP_FLAGS             = -x c -E -P -DVFRCOMPILE --include $(MODULE_NAME)StrDefs.h
+DEFINE GCC_VFRPP_FLAGS             = -x c -E -P -DVFRCOMPILE --include $(MODULE_NAME)StrDefs.h -Wundef -Werror
 DEFINE GCC_ASLPP_FLAGS             = -x c -E -include AutoGen.h
 DEFINE GCC_ASLCC_FLAGS             = -x c
 DEFINE GCC_WINDRES_FLAGS           = -J rc -O coff
--
2.30.0









-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#74385): https://edk2.groups.io/g/devel/message/74385
Mute This Topic: https://groups.io/mt/82306124/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/edk2-devel-archive/attachments/20210423/157e87b0/attachment.htm>


More information about the edk2-devel-archive mailing list