Skip to content

tests: the stack reserve need not be the last link option (TEST-BUILD-FALLBACK-STACK-OPTION) - #2618

Merged
MoonEyes merged 4 commits into
ProjectLeonida:mainfrom
imShangLi:test/build-fallback-stack-option
Nov 29, 2026
Merged

MoonEyes merged 4 commits into
ProjectLeonida:mainfrom
imShangLi:test/build-fallback-stack-option

Conversation

@imShangLi

Copy link
Copy Markdown
Contributor

Rebased replacement for #2573.

  • Rebased onto ProjectLeonida/mandy@4364a4f.
  • Diff: 1 insertion, 1 deletion in tests/test_build_runtime_fallback.py.
  • The regex now allows additional linker options after /STACK:${GTA6RT_STACK}.
  • Local regex validation passed; full repository tests are covered by CI.
  • The original branch snapshot is retained at Mby159/leonida@backup/pr-2573-ae7a0936a6.

AI-assisted: yes.

@merzleckeier

Copy link
Copy Markdown
Contributor

Independent check of c76c322b on 4364a4fa6. The standalone fallback suite has ten passing cases and one Windows-only skip on Linux, on both unmodified trees. The new regex correctly accepts a valid option after /STACK:${GTA6RT_STACK}. It also accepts source that links a different reserve than the unchanged 8 MiB fallback.

I ran the exact Python assertion with five CMake variants, then linked tiny Windows PEs using each variant’s actual target_link_options with clang-cl/xwin and lld-link. llvm-readobj reported these reserves.

Variation Main assertion PR assertion PE reserve
Current flags Pass Pass 8 MiB
Append /INCREMENTAL:NO Fail Pass 8 MiB
Append 0 directly to ${GTA6RT_STACK} Fail Pass 80 MiB
Comment out the stack option on its own line Fail Pass 1 MiB
Add a later /STACK:16777216 Fail Pass 16 MiB

The existing PE check is a minimum check. I confirmed it rejects the 1 MiB case; it also accepts 16 and 80 MiB. Equality with the fallback still needs the static guard. One tested way to preserve it with the current flat CMake flag list is to split the option block and match the exact stack token once:

link_options = re.search(r"target_link_options\(gta6rt PRIVATE([^)]*)\)", cmake)
self.assertIsNotNone(link_options)
options = re.sub(r"(?m)#.*$", "", link_options[1]).split()
self.assertEqual([opt for opt in options if opt.upper().startswith("/STACK:")],
                 ["/STACK:${GTA6RT_STACK}"])

That passes the two 8 MiB cases, rejects all three mismatches, and passes the full standalone fallback suite with the same Linux skip. AI-assisted with OpenAI Codex (GPT-6).

@imShangLi

Copy link
Copy Markdown
Contributor Author

CI baseline comparison for the current red checks:

  • PR base 4364a4fa61f6bc42eefc94452c3a565fc530dd34 already has failing semantic-tests (ubuntu-latest), translator-tests, stdlib-tests-linux, check, and macos-python jobs.
  • On this PR, semantic-tests fails in test_interp_computed_ij_fallback; translator-tests fails in six tests/test_mesh_serial_waves.py cases. Neither file is touched by this PR.
  • no-game-data, change-scope, and viewer-tests pass.
  • The only changed file is tests/test_build_runtime_fallback.py; local validation confirmed the old regex rejects a valid /STACK option followed by another linker option, while the new regex accepts it.

AI-assisted: yes.

@imShangLi

Copy link
Copy Markdown
Contributor Author

Updated head eace3acd, with current main (eedd72e3) merged into the branch.

The assertion now anchors target_link_options(gta6rt ...) at line start, strips comments from the captured option list, and requires exactly one /STACK:${GTA6RT_STACK} token. This keeps the original equality check while allowing unrelated trailing linker options.

Local validation: two valid variants pass (current flags; appended /INCREMENTAL:NO), and three invalid variants are rejected (wrong reserve suffix, fully commented-out stack option, second overriding /STACK).

AI-assisted: yes.

@merzleckeier

Copy link
Copy Markdown
Contributor

Retested eace3acd on eedd72e30 against the same linked PE fixtures. Stock and the extra unrelated option pass at 8 MiB. The numeric suffix (80 MiB), commented-out option (1 MiB), and later CMake override (16 MiB) are now all rejected.

One analogous case remains in the PowerShell fallback assertion. Appending /stack:16777216 after /STACK:8388608 on the /Fe:gta6rt.exe line passes the Python check. A minimal PE linked with those two flags in that order with lld-link has SizeOfStackReserve = 16777216. Checking the complete list of stack options on both sides would close that gap. I tested replacing just the fallback assertion with:

_, separator, flags = lines[0].partition(" /link ")
self.assertEqual(separator, " /link ")
self.assertEqual(
    [option[1:].upper() for option in flags.split()
     if option.upper().startswith(("/STACK:", "-STACK:"))],
    [f"STACK:{reserve}"],
)

This rejects the fallback override and preserves the other six results. Both standalone runs on Linux passed 10 tests with one Windows-only skip. This used tiny synthetic PEs to verify the link flags. AI-assisted with OpenAI Codex.

@imShangLi

Copy link
Copy Markdown
Contributor Author

Updated head c680918.

The PowerShell fallback assertion now partitions the /link flags and requires exactly one matching stack option, accepting both /STACK: and -STACK: spellings. Local validation passes the current flag, an unrelated trailing option, and -STACK; it rejects a later overriding /stack and a wrong reserve.

AI-assisted: yes.

@TheGeogeo

Copy link
Copy Markdown
Contributor

Tested c680918 merged (no commit) with main 7c330c7: Python 3.12.4, Windows 11 10.0.26300, CPU only.

AI-assisted (Claude Code).

@MoonEyes

Copy link
Copy Markdown
Collaborator

Merging. Head c68091870 has red/green verdicts from reviewers other than the author (above), merges cleanly with main b8346588d, does not force a rebase of #2566, and carries a claim ID. Remaining main CI reds (translator-tests mesh, semantic-tests f16) are pre-existing. Merged by MoonEyes.

AI-assisted (Claude Code).

@MoonEyes
MoonEyes merged commit 2b5a6fd into ProjectLeonida:main Nov 29, 2026
4 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants