Skip to content

infra: mingw-w64 + lld in the dev container (PE/Mach-O fixtures) - #35

Merged
mahaloz merged 1 commit into
mainfrom
infra/devcontainer-mingw
Jun 25, 2026
Merged

mahaloz merged 1 commit into
mainfrom
infra/devcontainer-mingw

Conversation

@mahaloz

@mahaloz mahaloz commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

What this adds

The dev container (.devcontainer/Dockerfile, image kuna-dev) shipped gcc/clang + every cross-ELF toolchain + Go, but no Windows/Mac toolchain. This adds the non-ELF toolchains the multi-format loader PRs need to build real fixtures:

  • gcc-mingw-w64 — provides x86_64-w64-mingw32-gcc + i686-w64-mingw32-gcc (one package, both drivers + their binutils). Produces idiomatic PE/PE32+ executables that import from DLLs (msvcrt puts/printf) and carry DWARF + Itanium-mangled C++. The cross GCC is 10-win32.
  • lld — already present in the image; this PR documents and verifies its non-ELF backends: lld-link (PE) and the Mach-O backend (ld64.lld-14, also reachable as ld.lld -flavor darwin), which can link a Mach-O executable in-container.

Infra + docs only — no engine code touched, so the three gates (make test / make test-stages / make rust-test) don't apply and weren't run. The image is not committed (env-only Dockerfile + docs).

Before / after

The host and old container could not build an importing PE (no Windows toolchain). Now the container does. The freshly built image links a PE32+ exe whose import table pulls from msvcrt.dll:

$ file /tmp/p.exe
/tmp/p.exe: PE32+ executable (console) x86-64, for MS Windows

$ x86_64-w64-mingw32-objdump -p /tmp/p.exe | sed -n '/DLL Name: msvcrt.dll/,/^$/p'
	DLL Name: msvcrt.dll
	vma:  Hint/Ord Member-Name Bound-To
	...
	d5c0	  956  fprintf
	d606	 1045  puts
	d638	 1123  vfprintf
	...

(puts is imported directly; mingw routes printf through fprintf/vfprintf. The same exe also imports the KERNEL32.dll CRT-startup functions.)

lld Mach-O backend, end-to-end link proof (no Apple SDK needed):

$ clang --target=arm64-apple-macos11 -c /tmp/m.c -o /tmp/m.o
$ ld64.lld-14 -arch arm64 -platform_version macos 11.0 11.0 -e _start -undefined dynamic_lookup -o /tmp/m.macho /tmp/m.o
$ file /tmp/m.macho
/tmp/m.macho: Mach-O 64-bit arm64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE>

Package-name note

The 22.04 lld package ships the Mach-O linker only as the versioned ld64.lld-14 (no unversioned ld64.lld symlink; ld.lld/lld-link are symlinked). Docs use ld64.lld-14 / ld.lld -flavor darwin accordingly.

Loader PRs this unblocks

  • PR-4 — PE import-naming fixture (needs a PE that imports msvcrt puts/printf).
  • PR-11 — PE DWARF (mingw PE carries DWARF + Itanium-mangled C++).
  • PR-7 — Mach-O executable linking in-container (lld Mach-O backend).

🤖 Generated with Claude Code

https://claude.ai/code/session_01FvRnfTgYKoZvS2TEvdYpWb

@mahaloz
mahaloz merged commit 2d824d2 into main Jun 25, 2026
@mahaloz
mahaloz deleted the infra/devcontainer-mingw branch July 29, 2026 08:01
mahaloz added a commit to borancar/kuna that referenced this pull request Nov 14, 2026
mahaloz added a commit to borancar/kuna that referenced this pull request Nov 14, 2026
…ocal head

The fork's merge of origin/main (034a042) carries no code beyond the PR
commit and the same Noelo-Lab#33-Noelo-Lab#35 renumbering already on this head; every
conflict resolves to this head's content.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
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.

1 participant