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

Switch macOS multi-arch to x86_64+arm64 #1213

Merged
merged 1 commit into from
Aug 3, 2022

Conversation

achernya
Copy link
Collaborator

The previous CI attemtped to use Homebrew for builds, but
unfortunately Homebrew has dropped support for universal packages aka
multiarch (fat) binaries. This means that in order to build an arm64 +
x86_64 package, macports has to be used instead of homebrew.

Unlike Homebrew, MacPorts is not installed by default on the GitHub
Actions runners, so we need to install it ourselves. This means
managing our own instance of the cache, which itself produces
challenges as the gtar binary run by the action doesn't have enough
permissions to restore the MacPorts checkout. So we have to shim gtar
with a sudo wrapper.

With this commit, we produce a Mosh package that works on macOS 11.0
and newer, on both arm64 and x86_64 architectures. The protobuf
library is statically linked, but all other libraries are provided by
the system.

@achernya achernya requested a review from bbarenblat July 19, 2022 02:14
@carlocab
Copy link

carlocab commented Jul 21, 2022

You can keep using brew with a statically linked protobuf by provisioning your own universal libprotobuf.a using thin versions provided by Homebrew.

I did something similar for Neovim recently; see: https://github.com/neovim/neovim/blob/946c8fd2886df9db288797c257bf067b904a3551/.github/workflows/release.yml#L88-L106

Of course, if you're happy with using MacPorts, that works too.

@achernya
Copy link
Collaborator Author

Thanks for the suggestion @carlocab. I'm a bit uncomfortable running lipo on build objects we didn't produce, and I think macports is acceptable. I will definitely keep this solution in mind if we run into issues with macports and need to go back to homebrew.

@carlocab
Copy link

Sure, no problem!

Out of curiosity, do you mind sharing your concerns about using lipo?

@achernya
Copy link
Collaborator Author

I don't have a concern with lipo in general. We use it in mosh's own build process. I am just slightly wary of using it on build products that we aren't directly responsible for.

@carlocab
Copy link

I am just slightly wary of using it on build products that we aren't directly responsible for.

Yes, these are the concerns I was wondering about. (Feel free to say that you have no time or interest to talk about them them.)

@achernya
Copy link
Collaborator Author

I unfortunately don't have a more detailed concern. It's mostly that it feels like an abstraction violation on that the binary merge there with lipo should have been done by the packaging system if that was something it supported. I don't really know as a library consumer if the build settings of the two architectures here are compatible, since it's not documented as explicitly supported. Certainly if homebrew said this was supported I'd feel comfortable using it.

@carlocab
Copy link

carlocab commented Jul 22, 2022

That makes total sense. Thanks for explaining!

@@ -52,16 +53,18 @@ fi
#
# Build archs one by one.
#
for arch in $ARCHS; do
for triple in $ARCH_TRIPLES; do
arch=$(echo $triple | cut -d- -f1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to avoid a fork here, arch=${triple%%-*} does the same thing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally find the bash string-substitution syntax harder to read, and the fork isn't that costly, so I prefer to leave this one as-is.

macosx/port-deps.sh Outdated Show resolved Hide resolved
The previous CI attemtped to use Homebrew for builds, but
unfortunately Homebrew has dropped support for universal packages aka
multiarch (fat) binaries. This means that in order to build an arm64 +
x86_64 package, macports has to be used instead of homebrew.

Unlike Homebrew, MacPorts is not installed by default on the GitHub
Actions runners, so we need to install it ourselves. This means
managing our own instance of the cache, which itself produces
challenges as the `gtar` binary run by the action doesn't have enough
permissions to restore the MacPorts checkout. So we have to shim gtar
with a sudo wrapper.

With this commit, we produce a Mosh package that works on macOS 11.0
and newer, on both arm64 and x86_64 architectures. The protobuf
library is statically linked, but all other libraries are provided by
the system.
@achernya achernya merged commit 4cd2da5 into mobile-shell:master Aug 3, 2022
@achernya achernya deleted the arm64 branch August 3, 2022 23:56
@eminence eminence added this to the 1.4.0 milestone Aug 12, 2022
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.

None yet

4 participants