-
Notifications
You must be signed in to change notification settings - Fork 18k
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
cmd/go: add option to create multi-architecture fat binaries on Darwin #40698
Comments
My first guess would be that this would involve the go tool invoking the compiler once for each architecture, and then invoking some tool to package the resulting executables into a fat binary. |
I don't see this happening in the go command in the short term. It would be a major change to juggle multiple architectures during a single command invocation. We've got a lot of modules work left to do for Go 1.16. |
It needn't be a feature of I build & assemble release tarballs for MacOS, Windows, and Linux with a shell script on Linux. That will break down for MacOS without a cross-platform command to create a fat binary. |
My understanding is that given two ordinary binaries, you can create a fat binary using the |
EDIT: Is there a lipo for Linux? I haven't found a man page for one. |
This is about Darwin, not Linux. |
Thanks, but that doesn't help. See #40698 (comment) for why I asked about Linux. |
lipo is open source, so it can be ported. Here's one attempt: |
I'd need to know that the authors of a utility that creates binaries for distribution to end users The only quick way to vet some-random-lipo is to compare its output with MacOS lipo, and then we're back on square zero. |
@networkimprov Sure, but that same problem applies to any utility. We can't put the universe in the Go distribution. |
The fat binary format is simple. You can see the relevant definitions at https://opensource.apple.com/source/xnu/xnu-344.49/EXTERNAL_HEADERS/mach-o/fat.h.auto.html. The file starts with a |
A lipo tool doesn't have to land in Go 1.16; the x/ tree is fine for now. Ian, thanks for the feasibility assessment. |
There's a more recent If you're on a Mac, the header file is at A good reference: https://stackoverflow.com/questions/46965686/parsing-universal-fat-binary-files |
I hacked up a tool that can make fat binaries: https://github.com/randall77/makefat |
\o/ thank you! Readme needs a command line summary. And it could use a test script to build a hello-world app, run makefat, then launch. Would you accept a patch for that? |
Sure. |
I verified my script with GOARCH=386 & =amd64. What should it use for Apple Silicon?
Also, makefat.go needn't panic if the command-line arguments are incorrect, |
The Apple Silicon port doesn't work yet. I'm working on it. |
Wow, it's been exactly an year! I'm sorry for asking, but what's the timeline for progress on this issue? |
See https://github.com/randall77/makefat Hopefully this will land in the golang/x repo someday. |
Duplicate of #53281 |
One of the issues is closed as duplicate of other, while the other was closed by the asking person... I don't think that's correct :) but anyway whatever. That tool works, lipo too. |
Given the Apple silicon announcement, it will soon be common for developers to have to support both arm64le and x86_64 variants of macOS. Rather than shipping multiple binaries, it would be nice to be able to ship macho fat binaries that contain both implementations without having to manually use tools like lipo. Could multi-architecture support be added to the compiler?
The text was updated successfully, but these errors were encountered: