Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build darwin-arm64 build during make dist-macos #500

Merged
merged 1 commit into from
Aug 9, 2023

Conversation

asg017
Copy link
Contributor

@asg017 asg017 commented Aug 9, 2023

The PR edits the make dist-macos script to also compile a darwin-arm64 build of litestream.

It works by applying the appropriate GOOS/GOARCH/CGO_ENABLED env vars. But the CC="gcc -target arm64-apple-macos11" env var does the real heavy lifting. The -target is an apple clang-specific flag that allows you to cross compile arm64 M1/M2 targets from a x86_64 computer. I've used it in the past to cross compile Go binaries from a MacOS Github Action runner, in this sqlite-http workflow (binaries available here).

I tested this manually on my MacOS 12.3.1 x86_64 laptop. I then scp'ed the compiled file to my Mac M1 Mini, and was able to successfully run it. Running file litestream on the darwin-arm64 output shows it's a "Mach-O 64-bit executable arm64", while the previous "normal" compiler reports "Mach-O 64-bit executable x86_64".

More than happy to move it to a separate dist-macos-arm64 Makefile target if you'd like. I re-used the gon and openssl from the amd64 target, so I think it will work?

@benbjohnson benbjohnson merged commit a369b05 into benbjohnson:main Aug 9, 2023
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.

2 participants