[3/8] arm/edk2-firmware: unbreak builds with latest Clang

Message ID 20220225050803.2517279-3-jon.mason@arm.com
State New
Headers show
Series [1/8] arm-toolchain/external-arm-toolchain: fix missing license updates | expand

Commit Message

Jon Mason Feb. 25, 2022, 5:07 a.m. UTC
From: Ross Burton <ross.burton@arm.com>

The latest Clang produced unaligned access warnings, which EDK2 promotes
to errors with -Werror.

  edk2/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h:78:47:
  error: field Guid within 'FPDT_GUID_EVENT_RECORD' is less aligned than 'EFI_GUID'
  and is usually due to 'FPDT_GUID_EVENT_RECORD' being packed, which can lead to
  unaligned accesses [-Werror,-Wunaligned-access]

This has been reported upstream so for now ignore this warning.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 meta-arm/recipes-bsp/uefi/edk2-firmware.inc   |  1 +
 .../recipes-bsp/uefi/files/unaligned.patch    | 27 +++++++++++++++++++
 2 files changed, 28 insertions(+)
 create mode 100644 meta-arm/recipes-bsp/uefi/files/unaligned.patch

Patch

diff --git a/meta-arm/recipes-bsp/uefi/edk2-firmware.inc b/meta-arm/recipes-bsp/uefi/edk2-firmware.inc
index b1595e858b25..dc561eeff971 100644
--- a/meta-arm/recipes-bsp/uefi/edk2-firmware.inc
+++ b/meta-arm/recipes-bsp/uefi/edk2-firmware.inc
@@ -17,6 +17,7 @@  SRC_URI = "\
     ${EDK2_SRC_URI};name=edk2;destsuffix=edk2;nobranch=1 \
     ${EDK2_PLATFORMS_SRC_URI};name=edk2-platforms;destsuffix=edk2/edk2-platforms;nobranch=1 \
     file://0001-Fix-VLA-parameter-warning.patch \
+    file://unaligned.patch \
 "
 
 SRCREV_FORMAT         = "edk2_edk2-platforms"
diff --git a/meta-arm/recipes-bsp/uefi/files/unaligned.patch b/meta-arm/recipes-bsp/uefi/files/unaligned.patch
new file mode 100644
index 000000000000..1930f4c741f9
--- /dev/null
+++ b/meta-arm/recipes-bsp/uefi/files/unaligned.patch
@@ -0,0 +1,27 @@ 
+Latest clang is causing build failures because -Werror is used:
+
+  edk2/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h:78:47:
+  error: field Guid within 'FPDT_GUID_EVENT_RECORD' is less aligned than 'EFI_GUID'
+  and is usually due to 'FPDT_GUID_EVENT_RECORD' being packed, which can lead to
+  unaligned accesses [-Werror,-Wunaligned-access]
+
+This has been reported upstream[1] so until this is resolved, ignore the warnings.
+
+[1] https://edk2.groups.io/g/devel/message/86838
+
+Upstream-Status: Pending
+Signed-off-by: Ross Burton <ross.burton@arm.com>
+
+diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
+index 2e6b382ab6..75bfbc5ae6 100755
+--- a/BaseTools/Conf/tools_def.template
++++ b/BaseTools/Conf/tools_def.template
+@@ -2566,7 +2566,7 @@ DEFINE CLANG38_X64_PREFIX           = ENV(CLANG38_BIN)
+ DEFINE CLANG38_IA32_TARGET          = -target i686-pc-linux-gnu

+ DEFINE CLANG38_X64_TARGET           = -target x86_64-pc-linux-gnu

+ 

+-DEFINE CLANG38_WARNING_OVERRIDES    = -Wno-parentheses-equality -Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare -Wno-empty-body -Wno-unused-const-variable -Wno-varargs -Wno-unknown-warning-option

++DEFINE CLANG38_WARNING_OVERRIDES    = -Wno-parentheses-equality -Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare -Wno-empty-body -Wno-unused-const-variable -Wno-varargs -Wno-unknown-warning-option -Wno-error=unaligned-access

+ DEFINE CLANG38_ALL_CC_FLAGS         = DEF(GCC48_ALL_CC_FLAGS) DEF(CLANG38_WARNING_OVERRIDES) -fno-stack-protector -mms-bitfields -Wno-address -Wno-shift-negative-value -Wno-unknown-pragmas -Wno-incompatible-library-redeclaration -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -msoft-float -mno-implicit-float  -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -funsigned-char -fno-ms-extensions -Wno-null-dereference

+ 

+ ###########################