I am experiencing a build failure when trying to compile MdePkg with EDK2. The error occurs when building the BaseLib module. following this https://github.com/tianocore/tianocore.github.io/wiki/Common-instructions to build on ubuntu 20.04.
Environment:
OS: Ubuntu 20.04
GCC version: 9.4.0
EDK2 version: edk2
Steps
Clone the EDK2 repository
Initialize submodules with "git submodule update --init"
make -C BaseTools
i tried many methods of building it available on inetrnet everytime i got stuck in some kind of build error.
Error:
adding the error part here
testValidUtf8FileWithBom (CheckUnicodeSourceFiles.Tests) ... ok
======================================================================
FAIL: test_FMMT_FMMT (CheckPythonSyntax.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 49, in <lambda>
newmethod = lambda self: self.SingleFileTest(filename)
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 27, in SingleFileTest
self.fail('syntax error: %s, Error is %s' % (filename, str(e)))
AssertionError: syntax error: /home/saman/Downloads/edk2/BaseTools/Source/Python/FMMT/FMMT.py, Error is File "/home/saman/Downloads/edk2/BaseTools/Source/Python/FMMT/FMMT.py", line 51
def __init__(self) -> None:
^
SyntaxError: invalid syntax
======================================================================
FAIL: test_FMMT_core_BinaryFactoryProduct (CheckPythonSyntax.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 49, in <lambda>
newmethod = lambda self: self.SingleFileTest(filename)
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 27, in SingleFileTest
self.fail('syntax error: %s, Error is %s' % (filename, str(e)))
AssertionError: syntax error: /home/saman/Downloads/edk2/BaseTools/Source/Python/FMMT/core/BinaryFactoryProduct.py, Error is File "/home/saman/Downloads/edk2/BaseTools/Source/Python/FMMT/core/BinaryFactoryProduct.py", line 34
type:list = []
^
SyntaxError: invalid syntax
======================================================================
FAIL: test_FMMT_core_BiosTree (CheckPythonSyntax.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 49, in <lambda>
newmethod = lambda self: self.SingleFileTest(filename)
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 27, in SingleFileTest
self.fail('syntax error: %s, Error is %s' % (filename, str(e)))
AssertionError: syntax error: /home/saman/Downloads/edk2/BaseTools/Source/Python/FMMT/core/BiosTree.py, Error is File "/home/saman/Downloads/edk2/BaseTools/Source/Python/FMMT/core/BiosTree.py", line 31
def __init__(self, NodeName: str) -> None:
^
SyntaxError: invalid syntax
======================================================================
FAIL: test_FMMT_core_BiosTreeNode (CheckPythonSyntax.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 49, in <lambda>
newmethod = lambda self: self.SingleFileTest(filename)
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 27, in SingleFileTest
self.fail('syntax error: %s, Error is %s' % (filename, str(e)))
AssertionError: syntax error: /home/saman/Downloads/edk2/BaseTools/Source/Python/FMMT/core/BiosTreeNode.py, Error is File "/home/saman/Downloads/edk2/BaseTools/Source/Python/FMMT/core/BiosTreeNode.py", line 34
def __init__(self, name: str) -> None:
^
SyntaxError: invalid syntax
======================================================================
FAIL: test_FMMT_core_FMMTOperation (CheckPythonSyntax.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 49, in <lambda>
newmethod = lambda self: self.SingleFileTest(filename)
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 27, in SingleFileTest
self.fail('syntax error: %s, Error is %s' % (filename, str(e)))
AssertionError: syntax error: /home/saman/Downloads/edk2/BaseTools/Source/Python/FMMT/core/FMMTOperation.py, Error is File "/home/saman/Downloads/edk2/BaseTools/Source/Python/FMMT/core/FMMTOperation.py", line 16
def ViewFile(inputfile: str, ROOT_TYPE: str, layoutfile: str=None, outputfile: str=None) -> None:
^
SyntaxError: invalid syntax
======================================================================
FAIL: test_FMMT_core_FMMTParser (CheckPythonSyntax.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 49, in <lambda>
newmethod = lambda self: self.SingleFileTest(filename)
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 27, in SingleFileTest
self.fail('syntax error: %s, Error is %s' % (filename, str(e)))
AssertionError: syntax error: /home/saman/Downloads/edk2/BaseTools/Source/Python/FMMT/core/FMMTParser.py, Error is File "/home/saman/Downloads/edk2/BaseTools/Source/Python/FMMT/core/FMMTParser.py", line 15
def __init__(self, name: str, TYPE: str) -> None:
^
SyntaxError: invalid syntax
======================================================================
FAIL: test_FMMT_core_FvHandler (CheckPythonSyntax.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 49, in <lambda>
newmethod = lambda self: self.SingleFileTest(filename)
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 27, in SingleFileTest
self.fail('syntax error: %s, Error is %s' % (filename, str(e)))
AssertionError: syntax error: /home/saman/Downloads/edk2/BaseTools/Source/Python/FMMT/core/FvHandler.py, Error is File "/home/saman/Downloads/edk2/BaseTools/Source/Python/FMMT/core/FvHandler.py", line 16
def ChangeSize(TargetTree, size_delta: int=0) -> None:
^
SyntaxError: invalid syntax
======================================================================
FAIL: test_FMMT_core_GuidTools (CheckPythonSyntax.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 49, in <lambda>
newmethod = lambda self: self.SingleFileTest(filename)
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 27, in SingleFileTest
self.fail('syntax error: %s, Error is %s' % (filename, str(e)))
AssertionError: syntax error: /home/saman/Downloads/edk2/BaseTools/Source/Python/FMMT/core/GuidTools.py, Error is File "/home/saman/Downloads/edk2/BaseTools/Source/Python/FMMT/core/GuidTools.py", line 18
def ExecuteCommand(cmd: list) -> None:
^
SyntaxError: invalid syntax
======================================================================
FAIL: test_FMMT_utils_FvLayoutPrint (CheckPythonSyntax.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 49, in <lambda>
newmethod = lambda self: self.SingleFileTest(filename)
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 27, in SingleFileTest
self.fail('syntax error: %s, Error is %s' % (filename, str(e)))
AssertionError: syntax error: /home/saman/Downloads/edk2/BaseTools/Source/Python/FMMT/utils/FvLayoutPrint.py, Error is File "/home/saman/Downloads/edk2/BaseTools/Source/Python/FMMT/utils/FvLayoutPrint.py", line 9
def GetFormatter(layout_format: str):
^
SyntaxError: invalid syntax
======================================================================
FAIL: test_FirmwareStorageFormat_Common (CheckPythonSyntax.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 49, in <lambda>
newmethod = lambda self: self.SingleFileTest(filename)
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 27, in SingleFileTest
self.fail('syntax error: %s, Error is %s' % (filename, str(e)))
AssertionError: syntax error: /home/saman/Downloads/edk2/BaseTools/Source/Python/FirmwareStorageFormat/Common.py, Error is File "/home/saman/Downloads/edk2/BaseTools/Source/Python/FirmwareStorageFormat/Common.py", line 42
def from_list(self, listformat: list) -> None:
^
SyntaxError: invalid syntax
======================================================================
FAIL: test_FirmwareStorageFormat_FfsFileHeader (CheckPythonSyntax.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 49, in <lambda>
newmethod = lambda self: self.SingleFileTest(filename)
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 27, in SingleFileTest
self.fail('syntax error: %s, Error is %s' % (filename, str(e)))
AssertionError: syntax error: /home/saman/Downloads/edk2/BaseTools/Source/Python/FirmwareStorageFormat/FfsFileHeader.py, Error is File "/home/saman/Downloads/edk2/BaseTools/Source/Python/FirmwareStorageFormat/FfsFileHeader.py", line 41
def FFS_FILE_SIZE(self) -> int:
^
SyntaxError: invalid syntax
======================================================================
FAIL: test_FirmwareStorageFormat_FvHeader (CheckPythonSyntax.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 49, in <lambda>
newmethod = lambda self: self.SingleFileTest(filename)
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 27, in SingleFileTest
self.fail('syntax error: %s, Error is %s' % (filename, str(e)))
AssertionError: syntax error: /home/saman/Downloads/edk2/BaseTools/Source/Python/FirmwareStorageFormat/FvHeader.py, Error is File "/home/saman/Downloads/edk2/BaseTools/Source/Python/FirmwareStorageFormat/FvHeader.py", line 77
def Refine_FV_EXT_ENTRY_OEM_TYPE_Header(nums: int) -> EFI_FIRMWARE_VOLUME_EXT_ENTRY_OEM_TYPE:
^
SyntaxError: invalid syntax
======================================================================
FAIL: test_FirmwareStorageFormat_SectionHeader (CheckPythonSyntax.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 49, in <lambda>
newmethod = lambda self: self.SingleFileTest(filename)
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 27, in SingleFileTest
self.fail('syntax error: %s, Error is %s' % (filename, str(e)))
AssertionError: syntax error: /home/saman/Downloads/edk2/BaseTools/Source/Python/FirmwareStorageFormat/SectionHeader.py, Error is File "/home/saman/Downloads/edk2/BaseTools/Source/Python/FirmwareStorageFormat/SectionHeader.py", line 22
def SECTION_SIZE(self) -> int:
^
SyntaxError: invalid syntax
======================================================================
FAIL: test_build_BuildReport (CheckPythonSyntax.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 49, in <lambda>
newmethod = lambda self: self.SingleFileTest(filename)
File "/home/saman/Downloads/edk2/BaseTools/Tests/CheckPythonSyntax.py", line 27, in SingleFileTest
self.fail('syntax error: %s, Error is %s' % (filename, str(e)))
AssertionError: syntax error: /home/saman/Downloads/edk2/BaseTools/Source/Python/build/BuildReport.py, Error is File "/home/saman/Downloads/edk2/BaseTools/Source/Python/build/BuildReport.py", line 2429
build_command = build_command.replace(f"$({var})", var_value)
^
SyntaxError: invalid syntax
----------------------------------------------------------------------
Ran 302 tests in 0.818s
FAILED (failures=14)
make[1]: Leaving directory '/home/saman/Downloads/edk2/BaseTools/Tests'
edit
this time I go with this configuration
EDK2 version: edk2-stable202305
gcc version 9.4.0
conf > target.txt --> TOOL_CHAIN_TAG = GCC49
python = 3.9 version
now when I compiled I got these error
Error:
pasting the end of error
stable/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf [X64]
Building ... /home/saman/Downloads/edk2-stable/MdeModulePkg/Application/HelloWorld/HelloWorld.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/saman/Downloads/edk2-stable/MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/saman/Downloads/edk2-stable/MdeModulePkg/Universal/CapsulePei/CapsulePei.inf [X64]
/home/saman/Downloads/edk2-stable/MdeModulePkg/Universal/RegularExpressionDxe/oniguruma/src/regexec.c:1124:9: error: unknown type name ‘ptrdiff_t’
1124 | typedef ptrdiff_t StackIndex;
| ^~~~~~~~~
make: Nothing to be done for 'tbuild'.
Building ... /home/saman/Downloads/edk2-stable/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/saman/Downloads/edk2-stable/MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf [X64]
make: Nothing to be done for 'tbuild'.
/home/saman/Downloads/edk2-stable/MdeModulePkg/Universal/RegularExpressionDxe/oniguruma/src/regexec.c: In function ‘sunday_quick_search’:
/home/saman/Downloads/edk2-stable/deModulePkg/Universal/RegularExpressionDxe/oniguruma/src/regexec.c:5023:3: error: unknown type name ‘ptrdiff_t’
5023 | ptrdiff_t target_len;
| ^~~~~~~~~
/home/saman/Downloads/edk2-stable/MdeModulePkg/Universal/RegularExpressionDxe/oniguruma/src/regexec.c:36:1: note: ‘ptrdiff_t’ is defined in header ‘<stddef.h>’; did you forget to ‘#include <stddef.h>’?
35 | #include "regint.h"
+++ |+#include <stddef.h>
36 |
Building ... /home/saman/Downloads/edk2-stable/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf [X64]
Building ... /home/saman/Downloads/edk2-stable/MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/saman/Downloads/edk2-stable/MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf [X64]
make: Nothing to be done for 'tbuild'.
make: Nothing to be done for 'tbuild'.
Building ... /home/saman/Downloads/edk2-stable/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/saman/Downloads/edk2-stable/MdeModulePkg/Universal/PcatSingleSegmentPciCfg2Pei/PcatSingleSegmentPciCfg2Pei.inf [X64]
make: Nothing to be done for 'tbuild'.
Building ... /home/saman/Downloads/edk2-stable/MdeModulePkg/Bus/Usb/UsbBotPei/UsbBotPei.inf [X64]
make: Nothing to be done for 'tbuild'.
make: *** [GNUmakefile:439: /home/saman/Downloads/edk2-stable/Build/MdeModule/DEBUG_GCC49/X64/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe/OUTPUT/oniguruma/src/regexec.obj] Error 1
build.py...
: error 7000: Failed to execute command
make tbuild [/home/saman/Downloads/edk2-stable/Build/MdeModule/DEBUG_GCC49/X64/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe]
build.py...
: error F002: Failed to build module
/home/saman/Downloads/edk2-stable/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf [X64, GCC49, DEBUG]
- Failed -
Build end time: 10:14:08, Jun.21 2023
Build total time: 00:00:13