Skip to content

feat: build universal binary for macOS (arm64 + x86_64) - #1

Merged
thorinside merged 1 commit into
mainfrom
feature/universal-binary
Jan 6, 2026
Merged

thorinside merged 1 commit into
mainfrom
feature/universal-binary

Conversation

@thorinside

Copy link
Copy Markdown
Owner

Summary

Builds a universal (fat) binary for macOS containing both arm64 and x86_64 architectures, ensuring the tool works natively on both Intel and Apple Silicon Macs.

Changes

Makefile

  • Added CXXFLAGS_ARCH, CFLAGS_ARCH, LDFLAGS_ARCH variables for cross-compilation
  • Added universal target that:
    1. Builds arm64 binary
    2. Cleans object files
    3. Builds x86_64 binary
    4. Combines both using lipo
  • Added clean-objs helper target

GitHub Workflow

  • Updated macOS build to use make universal instead of plain make
  • Added architecture verification output

Testing

Successfully built and verified locally:

$ file nt-flash
nt-flash: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64:Mach-O 64-bit executable arm64]

Benefits

  • Native performance on Apple Silicon (no Rosetta 2 translation)
  • Single binary works on all modern Macs
  • No user confusion about which binary to download

Add 'make universal' target that builds a fat binary containing both
arm64 and x86_64 architectures using lipo.

Changes:
- Add CXXFLAGS_ARCH/CFLAGS_ARCH/LDFLAGS_ARCH for cross-compilation
- Add 'universal' target that builds both architectures and combines them
- Add 'clean-objs' helper to clean object files between arch builds
- Update GitHub workflow to use 'make universal' for macOS builds

The universal binary works on both Intel and Apple Silicon Macs without
requiring Rosetta 2 translation on Apple Silicon.
@thorinside
thorinside merged commit 8322de0 into main Jan 6, 2026
@thorinside
thorinside deleted the feature/universal-binary branch January 6, 2026 17:34
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