Skip to content

fix(relinker): preserve inputs behind Windows executable hard links - #6328

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
aaro56:fix/relinker-preserve-input-hardlinks
Oct 18, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
aaro56:fix/relinker-preserve-input-hardlinks

Conversation

@aaro56

@aaro56 aaro56 commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

What

On Windows with the supported MinGW-w64 compiler, an output.exe hard link to input.elf passes the relinker's input-overwrite checks. Conversion returns success and replaces the input ELF with the generated PE executable. The same comparison is used for additional executable inputs and bundled modules.

Use the existing SameOutputFile helper for all three input/output comparisons. It already handles the extension-dependent permission mismatch that makes MinGW's std::filesystem::equivalent miss these hard links. Collisions are rejected before any output is written.

Extend the existing input-preservation test with main/secondary outputs aliased to the main executable, a secondary executable, and a bundled module, for Linux and Windows conversion targets. Windows also exercises read-only aliases. Check original bytes, existing outputs, permissions, link counts and temporary-probe cleanup. A positive control confirms that distinct multiply linked files with identical bytes still convert successfully.

The existing helper conservatively rejects ambiguous read-only identities or unwritable probe directories. Record this limitation in relinker technical debt.

Related: #6127 proposes removing the Windows permission-mismatch workaround from SameOutputFile. This fix relies on that workaround; its removal would restore the input-overwrite failure covered by the new regression.

Tested

Windows 11 Home Single Language 10.0.22631, WinLibs MinGW-w64 GCC 15.2.0 x86_64-ucrt-posix-seh r7, Release, relinker-only build, Python 3.13.12.

  • Unmodified main at 5050a23f38ed03e2601804e90e0565b84ca4f1b5: all 167 registered tests passed. The new regression then failed on that original executable; an independent synthetic reproduction returned success and observed the input bytes being overwritten.
  • Fixed build: the input-preservation, primary/secondary output-collision, and additional-executable test groups passed (4/4). The new matrix contains 24 collision cases and one successful distinct-file control on Windows.
  • Updated to main at 6ea62f9b407b766c5adca63b37f63c70170f7612, rebuilt, and passed all 168 registered tests in 50.54 seconds. The input-preservation test completed in 4.06 seconds.
  • Rebased onto fdea36b83667541516affdc8c04fdc39b3496337 before publication. The relinker, its tests and its build inputs are unchanged from the tested tree; the intervening upstream changes concern AGC graphics.
  • tools/check_conventions.py passed against the exact staged tree and PR description. Whitespace and patch applicability checks passed.

Synthetic fixtures only. No retail game, GPU execution, or Linux/macOS host execution. No performance claim.

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; no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source; no third-party code added
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes — Codex

This was referenced Oct 15, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 docs/dev/debt/relinker.md
PR 6802 core/relinker/main.cpp
PR 6927 core/relinker/main.cpp
PR 6977 docs/dev/debt/relinker.md
PR 7173 docs/dev/debt/relinker.md
PR 7332 core/relinker/main.cpp
docs/dev/debt/relinker.md
PR 7450 core/relinker/main.cpp
docs/dev/debt/relinker.md
PR 7531 docs/dev/debt/relinker.md

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 18, 2026
@adriadam10 adriadam10 self-assigned this Oct 18, 2026
@adriadam10
adriadam10 merged commit 64b57d1 into boykopovar:main Oct 18, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants