0

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
  • Which version of edk2 are you using? The latest release (git tag) is edk2-stable202305. – MiSimon Jun 20 '23 at 06:08
  • These are errors in handling Python source code, and my guess is that this is because your host's Python is too old. You should check (1) what version of Python the EDK2 build requires (2) what version of Python you have on your host (3) that you are telling EDK2 the correct Python to use if your host's default Python isn't new enough. – Peter Maydell Jun 20 '23 at 10:02
  • @PeterMaydell, MiSimon kindly check the edit part i #include in regexec.c, but still getting this error.. is gcc49 right? my system has gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1) – Rabia Hussain Jun 22 '23 at 03:20
  • You should really ask the edk2 folks about your build problems. They will have a forum or a mailing list. Then your questions will get read by people who know the answers... – Peter Maydell Jun 22 '23 at 10:25

0 Answers0