Skip to content

Host tool contamination in edk2

Value

MACHINE=qemux86-64 bitbake oniro-image-base fails to build on systems with HOST gcc 12

Description

When building Oniro on a system with host gcc 12.x, the edk2 build fails with

| make[2]: Entering directory '/media/space/repos/oniroproject/build-oniro-linux-qemux86_64/tmp/work/x86_64-linux/ovmf-native/edk2-stable202111-r0/git/BaseTools/Source/C/GenFfs'
| gcc   -c -isystem/media/space/repos/oniroproject/build-oniro-linux-qemux86_64/tmp/work/x86_64-linux/ovmf-native/edk2-stable202111-r0/recipe-sysroot-native/usr/include  -I . -I ./Include/Common -I ./Include/ -I ./Include/IndustryStandard -I ./Common/ -I .. -I . -I ./Include/X64/  -I .. -I ../Include/Common -I ../Include/ -I ../Include/IndustryStandard -I ../Common/ -I .. -I . -I ../Include/X64/ -isystem/media/space/repos/oniroproject/build-oniro-linux-qemux86_64/tmp/work/x86_64-linux/ovmf-native/edk2-stable202111-r0/recipe-sysroot-native/usr/include -pipe -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 -O2  -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 -O2  GenFfs.c -o GenFfs.o
| In function ‘GetAlignmentFromFile’,
|     inlined from ‘main’ at GenFfs.c:816:20:
| GenFfs.c:545:5: error: pointer ‘InFileHandle’ used after ‘fclose’ [-Werror=use-after-free]
|   545 |     Error(NULL, 0, 4001, "Resource", "memory cannot be allocated  of %s", InFileHandle);
|       |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| GenFfs.c:544:5: note: call to ‘fclose’ here
|   544 |     fclose (InFileHandle);
|       |     ^~~~~~~~~~~~~~~~~~~~~
| cc1: all warnings being treated as errors

This is actually a valid problem, and I've submitted a fix upstream at https://github.com/tianocore/edk2/pull/2602

Nevertheless, chances are we don't want to use host tools - they may result in different bugs for different users.

In scope

Remove host tool contamination

Out of Scope

Fix problems exposed by host tool contamination

Acceptance Criteria

Oniro builds regardless of host gcc version

Applicable Market Segments

All

Applicable Personas

Product Integrator

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information