ci(conventions): reject alignas above the 8192 bytes MinGW allows #9150

Merged
gdols merged 3 commits from upstream-pr/9150 into main 2026-10-24 23:57:05 +00:00
gdols commented 2026-10-21 13:38:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gdols on 2026-10-21T13:38:42Z.


What

Adds an alignment rule to the Conventions check: an added C++ line with alignas above 8192 fails, whether the argument is an integer literal (decimal, hex, binary or octal, with digit separators and suffixes) or a constexpr integer constant of the same file. A constant is taken from the definition visible at that alignas: the latest one before it in the innermost scope that encloses it, so same-named constants in other functions or blocks don't count. A namespace keeps its identity across reopened blocks, an inline namespace belongs to its parent and an extern "C" block opens no scope.

The required WinLibs GCC 15.2.0 r7 rejects static objects aligned above 8192 bytes (requested alignment '65536' exceeds object file maximum 8192). Linux builds accept them, Windows CI builds only three AGC execution tests, and full builds run on pull requests only on request, so these reach main. Run on the commits of main that added one, the rule reports each of them:

  • d31e35e1a: Flip.cpp:53 alignas(65536)
  • bbde0f468: ColorTargetLayout.cpp:58 alignas(65536)
  • c10401e39: ImageXorSwizzleVolume.cpp:34 alignas(65536)
  • 6b14169a4: GpuIndirectArgumentsMisalignedWriterAhead.cpp:25 alignas(BlockBytes) (#6716)
  • ed599f525: ImageArrayWindowPastLayerLimit.cpp:33 alignas(65536), fixed by #8310

#8310 removed the last one, so on current main the rule reports nothing.

Measured with GCC 15.2.0 r7: a namespace-scope object, a static local and a namespace-scope object of an over-aligned type fail above 8192; an automatic local, a member and a heap-allocated over-aligned type build. The rule reports the alignas itself, so it would also report those three; none exists on main. CONTRIBUTING states the limit next to the extensions rule.

Tested

Windows 11 Pro 26300, Python 3.13.14, WinLibs GCC 15.2.0 r7, on main 1c6e10f17.

  • tools/tests/test_check_conventions_alignment.py: 9 tests pass, including same-named constants in separate and in nested scopes in both orders, and constants of reopened, nested and inline namespaces and of extern "C" blocks. With the limit raised so the rule never fires, 21 of its checks fail; with the earlier file-wide lookup, the scope test through Check.code() fails.
  • Every tools/tests/test_check_conventions_*.py passes, and so does tools/check_test_registration.py --scripts.
  • The rule on the five commits above reports each of them. Over the 3,109 C and C++ files of main 1c6e10f17 it reports nothing. Resolving constants and checking every line takes 0.20 s for the slowest file, the 12,253-line tests/Graphics.cpp (best of three), and 2.8 s for all 606 files with alignas.
  • The GCC cases above, each compiled with g++ -std=c++20 -O2 -c.
  • tools/check_conventions.py --base origin/main with this title and description, tools/check_main_sync.py and tools/pr_overlap.py --branch pass.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4952530758 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9150). Originally posted by [gdols](https://github.com/gdols) on 2026-10-21T13:38:42Z. --- ### What Adds an `alignment` rule to the Conventions check: an added C++ line with `alignas` above 8192 fails, whether the argument is an integer literal (decimal, hex, binary or octal, with digit separators and suffixes) or a `constexpr` integer constant of the same file. A constant is taken from the definition visible at that `alignas`: the latest one before it in the innermost scope that encloses it, so same-named constants in other functions or blocks don't count. A namespace keeps its identity across reopened blocks, an inline namespace belongs to its parent and an `extern "C"` block opens no scope. The required WinLibs GCC 15.2.0 r7 rejects static objects aligned above 8192 bytes (`requested alignment '65536' exceeds object file maximum 8192`). Linux builds accept them, Windows CI builds only three AGC execution tests, and full builds run on pull requests only on request, so these reach `main`. Run on the commits of `main` that added one, the rule reports each of them: - d31e35e1a: `Flip.cpp:53 alignas(65536)` - bbde0f468: `ColorTargetLayout.cpp:58 alignas(65536)` - c10401e39: `ImageXorSwizzleVolume.cpp:34 alignas(65536)` - 6b14169a4: `GpuIndirectArgumentsMisalignedWriterAhead.cpp:25 alignas(BlockBytes)` (#6716) - ed599f525: `ImageArrayWindowPastLayerLimit.cpp:33 alignas(65536)`, fixed by #8310 #8310 removed the last one, so on current `main` the rule reports nothing. Measured with GCC 15.2.0 r7: a namespace-scope object, a `static` local and a namespace-scope object of an over-aligned type fail above 8192; an automatic local, a member and a heap-allocated over-aligned type build. The rule reports the `alignas` itself, so it would also report those three; none exists on `main`. CONTRIBUTING states the limit next to the extensions rule. ### Tested Windows 11 Pro 26300, Python 3.13.14, WinLibs GCC 15.2.0 r7, on `main` 1c6e10f17. - `tools/tests/test_check_conventions_alignment.py`: 9 tests pass, including same-named constants in separate and in nested scopes in both orders, and constants of reopened, nested and inline namespaces and of `extern "C"` blocks. With the limit raised so the rule never fires, 21 of its checks fail; with the earlier file-wide lookup, the scope test through `Check.code()` fails. - Every `tools/tests/test_check_conventions_*.py` passes, and so does `tools/check_test_registration.py --scripts`. - The rule on the five commits above reports each of them. Over the 3,109 C and C++ files of `main` 1c6e10f17 it reports nothing. Resolving constants and checking every line takes 0.20 s for the slowest file, the 12,253-line `tests/Graphics.cpp` (best of three), and 2.8 s for all 606 files with `alignas`. - The GCC cases above, each compiled with `g++ -std=c++20 -O2 -c`. - `tools/check_conventions.py --base origin/main` with this title and description, `tools/check_main_sync.py` and `tools/pr_overlap.py --branch` pass. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!9150
No description provided.