-
Notifications
You must be signed in to change notification settings - Fork 511
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
Support for Ubuntu Linux on ARM64 (aarch64) #4119
Comments
Are there any workarounds for this in the meantime? |
Has there been any updates on this? With the launch of even more M1 ARM-based Macs it's quickly becoming the soon-to-be-default architecture, and if you're running a VM there's no option except aarch64 for Linux (can't emulate x86). |
You could use QEMU to run Sorbet, probably. I was able to make ARM64 builds work for Linux I am not familiar enough with Bazel to add all of the conditionals necessary to make this properly support cross-platform builds, however, my findings:
I also attempted to get Darwin ARM64 support working (and it probably will if these caveats are fixed), however:
Hopefully this helps enable upstream ARM support! |
@korbin QEMU can emulate x64, but it is SLOW, pretty much unusable. |
this is a blocker to teams using sorbet in docker as well - let me know if there's anything I can do to help move this forward; as it stands I believe my workaround has to be forcing EDIT: nope, that doesn't work because of the lack of inotify in qemu and the unsuitability of the "Experimental Virtualization Backend" for our purposes. I'll be working to try to build arm64 native sorbet for my team. |
Can you at least submit a PR for a7cdf0b ? I think the other commits would require some reworking (all the |
I think we'd take a PR for the |
A brief end of week update on my end: I haven't fully inspected the generated gems or run the test suite against them, but building on the work from AngelList above, I seem to have at least runnable The commit logs are a little messy (especially on the bazel-toolchain side), there's decidedly some hackery going on that needs cleaned up because I don't particularly know Bazel well, and just broadly it'll need work before it'll be in a state to work with @korbin @froydnj and co. to upstream it, but it's progress and I'll likely continue poking at this Tuesday, if not over the weekend.
The below output is copied from an M1 Mac, but I was also able to use Docker BuildX to "cross-compile" (very, very, miserably slowly) from my AMD 3900X rig running Void Linux.
|
Currently, Sorbet uses blake2 for wasm builds and libb2 for other builds. Originally, this was because libb2 is heavily optimized but not portable. Since that time, however, libb2 has been extended with optimized builds for common architectures. That means that it's now possible to use the same library everywhere. x86/arm platforms still benefit from optimized vectorized implementations, and other platforms can still use the portable fallback. This change simplifies and slightly speeds up the build, while removing one of the blockers to Linux AArch64 support as described in sorbet#4119.
👋 Any news about this topic? Will there be a new release of the |
Our team is working on support for the M1 macs tracked in this milestone. Based on the investigations posted here, I believe the changes needed for M1 support overlap with most of what is needed for Linux ARM64 as well - other than some configuration bits. The changes in this experimental branch are enough to compile Sorbet to ARM64 on an M1 machine for both debug and release mode. However, we still need to figure out some build failures for the custom Ruby build and emscripten. Additionally, that branch uses the After all of the code changes are merged and the configuration API is finalized on |
please feel free to holler if there's anything we (Dockwa) can do to help, even if it's testing a quick thing. we've been using the linux/amd64 and linux/arm64 gems+docker images generated in https://github.com/dockwa/sorbet/commits/josh/arm64-more for a bit now and, short a PEBKAC issue I introduced with versioning at one point, haven't had issues (mind you, we fall back to upstream gems on Darwin-bare-metal because I never figured out cross-compilation, with Bazel or - experimentally at one point - with Zig's cross-compile-as-a-first-class-citizen toolchain) excited to see this getting upstream traction! |
Note that getting all the necessary changes in to compile on arm64 is one step (and an important one!), but not the complete picture: we also need to cross-compile the appropriate bits on Buildkite (AFAICT, Buildkite does not seem to have native arm64 machines/containers available). |
Certainly native arm64 machines would be ideal, but if those fail, a (somewhat slow) option (that we're using in our fork) is to QEMU around the problem - Docker BuildX sets up a |
Chiming in here again, curious to see what the blockers here are, and what my org could do to help. At this point we're still running my fork from the winter, which means v0.5.9613 (the last version I could get to cleanly rebase), complete with all of our packaging layers to get there. Simplifying back to a simple "bundle install" would be great. |
@klardotsh can you publish your forked version that works with arm64? |
Ah sorry, I realize I'd talked about the WIP above and never mentioned that all this work has been public all along... just without instructions available. Here goes! master of https://github.com/dockwa/sorbet is at v0.5.9613 (this limits you to Tapioca 0.7.x if you use In theory one should be able to apply this to bare-metal aarch64+glibc Linux; pulling the To apply some duck-typing theory: this looks like a hack, walks like a hack, and quacks like a hack, so it's definitely a hack. With some caveats however (notably, that things like Tapioca RBI generation must be done in a consistent environment - for us that's Dockerfile# https://github.com/dockwa/sorbet
FROM ghcr.io/dockwa/sorbet:0.5.9613 AS sorbet-gems
# the bins generated in the buster image are confirmed so far to be
# forward-compatible, so rather than rebuilding a bullseye image, we'll just
# mix and match this particular component
#
# https://github.com/dockwa/docker-watchman
FROM ghcr.io/dockwa/watchman:4.9.0-debian-buster AS watchman
FROM ruby:2.7.5-bullseye
# ...
# this version is/was required for arm64 support due to
# https://github.com/rubygems/rubygems/pull/5092
# (https://github.com/rubygems/rubygems/issues/5088)
RUN gem install bundler:2.2.33
# this (ab)uses awk's conditional print mechanics to find sorbet-static's
# x86_64 gem lock, duplicate it to a new line, and then find-replace over the
# duplicated line, described more in https://unix.stackexchange.com/a/675838
#
# without this, cryptic bundler errors occur in arm64 builds (only): not only
# is a dependency outright missing, but because it's a transient dependency,
# weird offshoots of https://github.com/rubygems/rubygems/pull/5092 (that are
# yet unfixed even in 2.2.33, it appears) pop up, all instances of the famous
# NilClass exception
RUN awk '1; gsub(/x86_64/,"aarch64")' Gemfile.lock > Gemfile.lock.new
RUN mv Gemfile.lock.new Gemfile.lock
# ... and since those issues stemmed from upstream not providing aarch64 bins
# in the first place, we'll provide our own *.gem for all things sorbet, and
# lean on bundler's implicit search path behaviors to avoid looking for this
# upstream (it won't exist)
COPY --from=sorbet-gems /sorbet*.gem ./vendor/cache/
RUN bundle install
# prep watchman (required for sorbet's LSP mode, which is sometimes called in
# this image via docker wrapper scripts hooked up to editors like neovim)
USER root
COPY --from=watchman /usr/local/bin/watchman* /usr/local/bin/
COPY --from=watchman /usr/local/share/doc/watchman-4.9.0 /usr/local/share/doc/watchman-4.9.0
COPY --from=watchman /usr/local/var/run/watchman /usr/local/var/run/watchman
RUN mkdir -p /usr/local/var/run/watchman
RUN touch /usr/local/var/run/watchman/.not-empty \
&& chown -R $(id -u app):$(id -g app) /usr/local/var/run/watchman
USER app Makefile to wrangle BuildX.POSIX:
REGISTRY_BASE ?= REDACTED
REGISTRY_BASE_IMAGE ?= $(shell git describe --always --abbrev)
ifeq ($(PUSH),1)
BASE_PUSH_FLAG := --push
endif
ifeq ($(IS_TRUNK_CI_BUILD),1)
BASE_LATEST_TAG := -t $(REGISTRY_BASE):latest
endif
.PHONY: multiarch-qemu-reset
multiarch-qemu-reset:
# this is PROBABLY dangerous in the event your system already has bin
# handlers or something but whatever, those are *super* uncommon normally
#
# DO NOT run this on GitHub Actions, use docker/setup-qemu-action@v1
# instead!
[ "$$(uname -s)" = "Linux" ] && docker run --rm --privileged multiarch/qemu-user-static --reset -p yes || true
.PHONY: buildx-base-image
buildx-base-image:
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t $(REGISTRY_BASE):$(REGISTRY_BASE_IMAGE) \
$(BASE_PUSH_FLAG) \
$(BASE_LATEST_TAG) \
. Footnotes
|
I should, however, explicitly note now: my org is removing Sorbet from our codebase in the near future; I will likely no longer be maintaining the above forks or Docker images any further, and in particular, will not be continuing the efforts to rebase onto newer Sorbet releases. I have no intentions quite yet of removing the repos, and of course the contributions are all under the same license as Sorbet upstream, so feel free to make your own forks or otherwise remix my work so far 1 :) Cheers y'all! Footnotes
|
For those interested, I took @klardotsh's changes and made them compatible with main (as of Sep 26, 2022) and able to build a static sorbet for linux-arm. You can find the changes here https://gist.github.com/ethankhall/516ddcefd22297a6cb9f736648386292. |
@bhuga this is the ARM64 issue I was telling you about |
Is there any expectation that ARM Linux will be supported in the future? The issue makes Sorbet inoperable for a small team like mine developing on ARM Macs with everything unified into docker 😞. Our CI is also running using ARM and has the same challenge. I would LOVE to add the benefit of sorbet's type system! |
@Nealsoni00 our team got around this by having a separate gemfile for your local machine and docker, you only need sorbet locally.
And then you can use the env variable |
What can we do to help set up the ARM64 Buildkite agent? |
I believe this has to be done by somebody at Stripe. FYI @jez |
Two months ago the last comment on this subject was from @froydnj in Slack:
Until this is prioritized internally at Stripe it feels like we shouldn't expect to see arm64 releases. We may want to consider setting up a community run agent and repo. |
We (well, @jez) has been trying to set up a buildkite agent for arm64 builds, but the current status is that the build is getting peculiar errors while setting up the required Ubuntu PPA repos (it looks like it's trying to fetch from an entirely different PPA than the one specified in the Dockerfile). Things are moving, just maybe not as quickly as one might like. |
Many thanks for this @froydnj & @jez !
Do y'all have any build logs that you can share? Because of the work on sorbet/sorbet-build-image#8 I may be able to help. |
This is the end of the log:
|
Thanks for the extra info @froydnj & @jez. We really appreciate the effort here! The latest code from GitHub builds for me on an M1 laptop with
diff --git a/Dockerfile b/Dockerfile
index 1a79916..4de9908 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -17,7 +17,9 @@ RUN apt-get update && \
echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main" | tee /etc/apt/sources.list.d/llvm.list && \
apt-get update && \
apt-get install --no-install-recommends -y nodejs yarn clang-9 && \
- add-apt-repository --yes ppa:ubuntu-toolchain-r/test && \
+ apt-key adv --no-tty --keyserver keyserver.ubuntu.com --recv-keys 1E9377A2BA9EF27F && \
+ echo "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu bionic main" | tee /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-bionic.list && \
+ echo "# deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu bionic main" | tee -a /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-bionic.list && \
apt-get update && \
apt-get install --yes --only-upgrade libstdc++6 && \
cd bazel_loader && \ |
Hello, Will this solve the problems for people on OSX with M1 chip, too? I'm able to install
|
@eric-christian What does |
Yes, that was indeed on. Without, it works. Thank you! Wonder why i had that on. Has probably something to do with a rails app i work on that requires all gems for all supported platforms to be packed within the vendor/cache. 🤔 |
This sounds close! Thank you again to those that are working on this 😊 |
Hey @froydnj & @jez - hope you are both doing well. I just wanted to check in about this Docker image build issues you were experiencing, and if there were any new blockers? I have some bandwidth to work on this at Gusto, and would love to help out where I can. |
Thanks for checking in @noizwaves ! Whatever issue we were experiencing seemed to be transient; I couldn't reproduce and jez couldn't reproduce it a day or so later. I think the part we got stuck on was tagging the resulting images on Docker Hub. Our current practice right now is tagging the x86-64 image as |
You can make the You'll need to create, tag, and push two architecture specific images, probably
|
There's a way to use the same tag for both architectures and many images out there do, but it's a bit of a pain to set up and troubleshoot to put it mildly. A few random tips having dealt with this recently:
|
I'd second @JamieMagee 's approach. Failing that, it's also possible to skip the multi-platform tag and just use the platform specific tags. This does require some parametrization of the build pipeline, but that can be easier to get working. |
The docs on |
I would love to help as needed too! 😄 What are the relevant roadblocks? |
Hey @tonybruess 👋 , do you have the build process you used for the |
@noizwaves Unfortunately I didn't save the exact steps anywhere. The only note I left for myself is:
My org just decided to remove Sorbet entirely so unfortunately I don't have any bandwidth to support further. :( |
Oh no, that sucks @tonybruess! Thank you for all the help so far on this issue ❤️ |
Ok folks, I was able to get some time this weekend and have set up https://github.com/sorbet-multiarch. It builds the linux/arm64 Sorbet gem on CircleCI and publishes it to Gemfury. It automatically runs nightly, and should provide up to date linux/arm64 gems moving forward. Currently version |
I'm curious if this is going to get official traction. Even with community solutions published and showing a near complete path for implementation, it just doesn't seem like there's room for it. Should we expect to use @noizwaves's implementation ? Which is great, and thank you for putting it forward. |
GREAT WORK! |
does the announcement of new m1 runners for open source projects make this an easier ask? |
I don't think so @X-sam - I think the solutions provided above (from @noizwaves) actually accomplish the asks. It would seem it's more so on the time @jez / @froydnj and team have to maintain and implement it. Something that doesn't seem to be prioritized. But who knows! Maybe that was really the blocker. |
Problem
We are starting to need to use ARM based Linux (using Ubuntu) but we can't use Sorbet since there is not a binary version of Sorbet that will run. When performing a
bundle install
that includessorbet
we get the following error:This is running on Ubuntu 20 LTS
Proposed solution
Add a linux
aarch64
pre-built sorbet-static.The text was updated successfully, but these errors were encountered: