Skip to content

[codex] repair Mach-O archive alignment deterministically - #3

Closed
WendellXY wants to merge 1 commit into
mainfrom
codex/deterministic-macho-archive-alignment
Closed

WendellXY wants to merge 1 commit into
mainfrom
codex/deterministic-macho-archive-alignment

Conversation

@WendellXY

Copy link
Copy Markdown
Collaborator

Summary

Add a deterministic archive repair pass for Darwin static libraries so release artifacts guarantee 8-byte-aligned 64-bit Mach-O member payloads.

Root Cause

The 0.2.2 release runner checked out the expected commit with the ranlib change, but the produced libsvga-static-0.2.2.xcframework.zip still has libsvga_zcu.o at payload offset 1660 (4 mod 8). cctools behavior alone is not a stable enough invariant across runner/toolchain versions.

Changes

  • Add tools/align_macho_archive.py to parse BSD ar archives and repair extended-name padding before 64-bit Mach-O payloads.
  • Invoke the repair/verify pass after libtool and ranlib in tools/rearchive_macos.sh.
  • Update README wording to document verified Mach-O archive alignment.

Validation

  • Repaired the known-bad 0.2.2 release archive locally; libsvga_zcu.o moved from offset 1660 to 1672.
  • zig build test
  • zig build -Dtarget=aarch64-ios.15.0 -Doptimize=ReleaseFast -Dbuild-probe=false -p /tmp/libsvga-deterministic-ios-check
  • zig build package-release -Doptimize=ReleaseFast -Drelease-version=0.2.3-deterministic-check -Drelease-dir=/tmp/libsvga-deterministic-release-check
  • Verified all Apple XCFramework slices place libsvga_zcu.o at payload offset 1672, so 1672 % 8 == 0.

@WendellXY

Copy link
Copy Markdown
Collaborator Author

Closing this approach in favor of a safer release-path fix: rebuild Apple release slices with official Apple archive tools and add a read-only archive alignment verifier, without custom byte mutation.

@WendellXY WendellXY closed this May 14, 2026
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