Skip to content

embar: Mach-O archives as Apple's ar writes them (fixes the 0.1.0 macOS release build) - #200

Merged
teo1747 merged 2 commits into
mainfrom
darwin-archive
Nov 9, 2026
Merged

teo1747 merged 2 commits into
mainfrom
darwin-archive

Conversation

@teo1747

@teo1747 teo1747 commented Nov 9, 2026

Copy link
Copy Markdown
Member

The release dry run for 0.1.0 (run) failed on both macOS runners, in the staged compiler's smoke test:

ld: archive member invalid control bits in '.../lib/embcc/0.1.0/aarch64-apple-darwin/librt.a'

The Darwin runtime is new since 0.0.1-beta, so this is the first release that ships it. embar wrote members of odd sizes, so most member headers, which the __.SYMDEF offsets point at, were not on multiples of eight. Xcode 16's ld refuses that. The newer ld on a current Mac accepts it, which is why nothing failed locally.

embar now writes exactly what Apple's ar writes:

  • each member is padded with newlines to a multiple of eight;
  • the name field is sized as Apple sizes it;
  • the table is named __.SYMDEF SORTED, with mode 100644 and its entries sorted by name.

Checked:

  • Byte comparison: identical to ZERO_AR_DATE=1 ar rcs for the runtime, and for embcc objects whose sizes fall in four different residues mod 8, on both Darwin targets.
  • darwin-rt: a new check that every header and every table offset is a multiple of eight (any host), plus the byte comparison on a Mac. Against the old embar it fails, naming the header at offset 1946.
  • Related tests: embar, darwin-rt, darwin-abi, darwin-host, darwin-libsystem and macho pass. The rebuilt runtime links and runs a program.
  • Release workflow: a dry run on this branch, the real test against Xcode 16's ld (linked in a comment below).

After this merges, tag v0.1.0.

The release dry run for 0.1.0 failed on both macOS runners: Xcode 16's
ld refused EmbCC's Darwin runtime, "archive member invalid control bits
in .../librt.a". Our members had odd sizes, so most headers -- which the
__.SYMDEF offsets name -- were not on multiples of eight. The ld on this
Mac (27106) accepts that, so linking here proved nothing.

embar now writes what Apple's ar writes: each member padded with
newlines to a multiple of eight, the name field sized as Apple sizes it,
and the table named "__.SYMDEF SORTED", mode 100644, its entries in the
order of their names. Against `ZERO_AR_DATE=1 ar rcs` it is byte for
byte the same, for the runtime and for embcc objects of every size
modulo eight on both Darwin targets.

darwin-rt checks the alignment on any host and, on a Mac, the byte
comparison with Apple's ar; against the old embar it fails, naming the
header at offset 1946.
@teo1747

teo1747 commented Nov 9, 2026

Copy link
Copy Markdown
Member Author

Release dry run on this branch: run 42546258244. All four builds pass, including both macOS runners' smoke test, which links a program against the new runtime archive with Xcode 16's ld. The same step failed on main (run 42544602528).

@teo1747
teo1747 merged commit e2ec3c6 into main Nov 9, 2026
21 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.

1 participant