Skip to content

BaseTools: Ecc: Fix ECC for Python 3.13#12315

Merged
mergify[bot] merged 4 commits intotianocore:masterfrom
os-d:ecc_p3_13
Apr 8, 2026
Merged

BaseTools: Ecc: Fix ECC for Python 3.13#12315
mergify[bot] merged 4 commits intotianocore:masterfrom
os-d:ecc_p3_13

Conversation

@os-d
Copy link
Copy Markdown
Contributor

@os-d os-d commented Mar 19, 2026

Description

Currently, ECC is broken on python 3.13 because the typing module no longer exists:

INFO - Cmd to run is: Ecc -c D:\r\edk2\BaseTools\Source\Python\Ecc\config.ini -e D:\r\edk2\Build\.pytool\Plugin\EccCheck\exception.xml -t D:\r\edk2\Build\.pytool\Plugin\EccCheck\MdeModulePkg\Core\Dxe -r D:\r\edk2\Build\.pytool\Plugin\EccCheck\Ecc.csv
INFO - ------------------------------------------------
INFO - --------------Cmd Output Starting---------------
INFO - ------------------------------------------------
INFO - Traceback (most recent call last):
INFO -   File "<frozen runpy>", line 198, in _run_module_as_main
INFO -   File "<frozen runpy>", line 88, in _run_code
INFO -   File "D:\r\edk2\BaseTools\Source\Python\Ecc\EccMain.py", line 20, in <module>
INFO -     from Ecc.Check import Check
INFO -   File "D:\r\edk2\BaseTools\Source\Python\Ecc\Check.py", line 16, in <module>
INFO -     from Ecc import c
INFO -   File "D:\r\edk2\BaseTools\Source\Python\Ecc\c.py", line 15, in <module>
INFO -     from Ecc import CodeFragmentCollector
INFO -   File "D:\r\edk2\BaseTools\Source\Python\Ecc\CodeFragmentCollector.py", line 20, in <module>
INFO -     from Ecc.CParser4.CLexer import CLexer
INFO -   File "D:\r\edk2\BaseTools\Source\Python\Ecc\CParser4\CLexer.py", line 4, in <module>
INFO -     from typing.io import TextIO
INFO - ModuleNotFoundError: No module named 'typing.io'; 'typing' is not a package

This comes from ANTLR autogenerated files, so the only way to resolve it is to update ANTLR. The latest ANTLR, 4.13.2 is chosen and contains python 3.13 support, as well as backwards compatible support. The autogen files are regenerated and whitespace only changes applied to prevent PatchCheck.py from failing.

While we are here, ANTLR 3 support is dropped because edk2 has not been using ANTLR 3 since at least 2019.

  • Breaking change?
    • Breaking change - Does this PR cause a break in build or boot behavior?
    • Examples: Does it add a new library class or move a module to a different repo.
  • Impacts security?
    • Security - Does this PR have a direct security impact?
    • Examples: Crypto algorithm change or buffer overflow fix.
  • Includes tests?
    • Tests - Does this PR include any explicit test code?
    • Examples: Unit tests or integration tests.

How This Was Tested

Tested on a Windows machine with python 3.13. After this change EccCheck ran correctly and reported the same errors it did with python 3.12 on the pipeline.

Integration Instructions

pip install -r pip-requirements.txt to pick up the new ANTLR runtime.

BaseTools hasn't been using ANTLR3 since at
least 2019. Drop the files.

Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
@os-d
Copy link
Copy Markdown
Contributor Author

os-d commented Apr 3, 2026

@makubacki @mikebeaton @gapalomi @lgao4 @ponchofigueroa @YuweiChen1110 can you please review when you have a chance?

Comment thread BaseTools/Source/Python/Ecc/CParser4/CLexer.py Outdated
@leiflindholm
Copy link
Copy Markdown
Member

Lines changed: 878 additions & 25849 deletions
Glorious.

os-d added 2 commits April 3, 2026 09:28
The ANTLR autogen files are currently created
without an SPDX identifer. Add the BSD-2-Clause-Patent
ID.

While here, correct the command to do the autogeneration
by using the right filename.

Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
ANTLR 4.9 is broken in python 3.13 because
it uses a library in the autogenerated files
that is removed.

This updates to 4.13.2 and also updates the autogen
files, which contain support for python 3.13 as well
as backwards compat.

Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
@os-d
Copy link
Copy Markdown
Contributor Author

os-d commented Apr 3, 2026

@leiflindholm I have fixed the template and regenerated the files, please re-review

@makubacki makubacki added the push Auto push patch series in PR if all checks pass label Apr 8, 2026
@mergify mergify bot added the queued label Apr 8, 2026
@mergify
Copy link
Copy Markdown

mergify bot commented Apr 8, 2026

Merge Queue Status

  • Entered queue2026-04-08 21:18 UTC · Rule: default
  • Checks passed · in-place
  • Merged2026-04-08 22:23 UTC · at 7705587e115d91929bb66aff7408f31de0495de4

This pull request spent 1 hour 5 minutes 18 seconds in the queue, including 1 hour 2 minutes 30 seconds running CI.

Required conditions to merge
  • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
  • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = tianocore.PatchCheck
    • check-neutral = tianocore.PatchCheck
    • check-skipped = tianocore.PatchCheck
  • any of [🛡 GitHub branch protection]:
    • check-success = ArmVirtPkg - Ubuntu GCC - PR
    • check-neutral = ArmVirtPkg - Ubuntu GCC - PR
    • check-skipped = ArmVirtPkg - Ubuntu GCC - PR
  • any of [🛡 GitHub branch protection]:
    • check-success = EmulatorPkg - Ubuntu GCC - PR
    • check-neutral = EmulatorPkg - Ubuntu GCC - PR
    • check-skipped = EmulatorPkg - Ubuntu GCC - PR
  • any of [🛡 GitHub branch protection]:
    • check-success = EmulatorPkg - Windows VS - PR
    • check-neutral = EmulatorPkg - Windows VS - PR
    • check-skipped = EmulatorPkg - Windows VS - PR
  • any of [🛡 GitHub branch protection]:
    • check-success = OvmfPkg - Ubuntu GCC - PR
    • check-neutral = OvmfPkg - Ubuntu GCC - PR
    • check-skipped = OvmfPkg - Ubuntu GCC - PR
  • any of [🛡 GitHub branch protection]:
    • check-success = OvmfPkg - Windows VS - PR
    • check-neutral = OvmfPkg - Windows VS - PR
    • check-skipped = OvmfPkg - Windows VS - PR
  • any of [🛡 GitHub branch protection]:
    • check-success = Windows VS - PR
    • check-neutral = Windows VS - PR
    • check-skipped = Windows VS - PR
  • any of [🛡 GitHub branch protection]:
    • check-success = Ubuntu GCC - PR
    • check-neutral = Ubuntu GCC - PR
    • check-skipped = Ubuntu GCC - PR
  • any of [🛡 GitHub branch protection]:
    • check-success = Validate Pull Request Formatting
    • check-neutral = Validate Pull Request Formatting
    • check-skipped = Validate Pull Request Formatting
  • any of [🛡 GitHub branch protection]:
    • check-success = ArmVirtPkg - Ubuntu - CLANGPDB
    • check-neutral = ArmVirtPkg - Ubuntu - CLANGPDB
    • check-skipped = ArmVirtPkg - Ubuntu - CLANGPDB
  • any of [🛡 GitHub branch protection]:
    • check-success = OvmfPkg - Ubuntu - CLANGPDB
    • check-neutral = OvmfPkg - Ubuntu - CLANGPDB
    • check-skipped = OvmfPkg - Ubuntu - CLANGPDB
  • any of [🛡 GitHub branch protection]:
    • check-success = Ubuntu - CLANGPDB
    • check-neutral = Ubuntu - CLANGPDB
    • check-skipped = Ubuntu - CLANGPDB
  • any of [🛡 GitHub branch protection]:
    • check-success = Windows - CLANGPDB
    • check-neutral = Windows - CLANGPDB
    • check-skipped = Windows - CLANGPDB

@mergify mergify bot merged commit 35c03c1 into tianocore:master Apr 8, 2026
154 of 155 checks passed
@mergify mergify bot removed the queued label Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

push Auto push patch series in PR if all checks pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants