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

Make build image linux/arm64 compatible #8

Merged
merged 6 commits into from
Sep 26, 2023

Conversation

noizwaves
Copy link
Contributor

@noizwaves noizwaves commented Aug 12, 2023

Hey folks,

I've been exploring sorbet-static builds for the linux aarch64 platform, and part of that work has involved changes to the sorbet-build-image so that an linux/arm64 image can be built.

In summary, the significant changes are:

  1. Upgrade Bazel from 0.21.0 to 3.4.1 (the earliest minor version supporting linux-aarch64)
  2. Install libstdc++6 from ppa:ubuntu-toolchain-r/test (to provide GLIBCXX_3.4.26)
  3. Enhance bazel_loader/bazel to install Bazel binaries on linux/aarch64 (installer scripts are not published for linux/aarch64 unfortunately)

Testing

Testing involves running the .buildkite/build-static-release.sh from the sorbet repository. Unless specified otherwise, Sorbet version 0.5.11010 is the version of the gem being built.

linux/amd64

This test was performed on an Intel 8700K computer running Ubuntu 20.04. See the attached file built_output_amd64.log for complete build output.

Additional characteristics of the sorbet binary:

root@88b32bf99783:/out_gems/sorbet-static-0.5.11010-x86_64-linux/libexec# ldd sorbet
        linux-vdso.so.1 (0x00007ffe985ae000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fa5f4efa000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fa5f4cdb000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fa5f4ad7000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa5f46e6000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fa5f44de000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fa5f5298000)

root@88b32bf99783:/out_gems/sorbet-static-0.5.11010-x86_64-linux/libexec# readelf -W --dyn-syms sorbet | grep GLIBCXX

root@88b32bf99783:/out_gems/sorbet-static-0.5.11010-x86_64-linux/libexec#

linux/arm64

This test was performed on an Apple MacBook Pro M1 running Docker Desktop 4.22 (file sharing: gRPC FUSE, Use Virtualization Framework checked). See built_output_arm64.log for complete build output.

A small modification is required to sorbet's .bazel_rc:

small diff
diff --git a/.bazelrc b/.bazelrc
index 0a66fb710..0be8127cb 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -116,8 +116,8 @@ build:release-linux --config=lto-linux --config=release-common
 #
 # At Stripe: developer laptops run skylake, devboxes run skylake-avx512
 # however some AWS instances in our fleet still run Sandy Bridge (Skylake predecessor), as of 2018.
-build:release-linux           --copt=-march=sandybridge
-build:release-sanitized-linux --copt=-march=sandybridge
+build:release-linux
+build:release-sanitized-linux

 build:release-mac --config=release-common --platforms=@//tools/platforms:darwin_x86_64

Additional characteristics of the binary:

root@8504c539e9df:/out_gems/sorbet-static-0.5.11010-aarch64-linux/libexec# ldd sorbet
        linux-vdso.so.1 (0x0000ffffb3426000)
        libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000ffffb3341000)
        libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000ffffb3315000)
        libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000ffffb3300000)
        libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000ffffb31a7000)
        /lib/ld-linux-aarch64.so.1 (0x0000ffffb33fa000)
        librt.so.1 => /lib/aarch64-linux-gnu/librt.so.1 (0x0000ffffb3190000)

root@8504c539e9df:/out_gems/sorbet-static-0.5.11010-aarch64-linux/libexec# readelf -W --dyn-syms sorbet | grep GLIBCXX

root@8504c539e9df:/out_gems/sorbet-static-0.5.11010-aarch64-linux/libexec#

testing the static gem

The arm64 gem (version 0.5.10983) built by the image successfully runs against Gusto's monolith:

vscode ➜ ~/workspace/zenpayroll (main) $ bin/srb tc --cache-dir=""
No errors! Great job.

@noizwaves
Copy link
Contributor Author

👋 Hey there @jez - I'm not sure of the code of conduct in this repository with respect to pull requests & requesting reviews, but I'd just like the bring this PR to your attention.

@tonybruess
Copy link

This is great, could we get a review @jez?

@noizwaves
Copy link
Contributor Author

I've updated the PR to not upgrade the base image to Ubuntu 20.04, and instead installing a newer version of libstdc++6 👌

@nalgenewaterbottle
Copy link

Great stuff! I'm curious when we can expect this to be merged to support aarch64 / arm64 natively?

@tonybruess
Copy link

Friendly bump on this @froydnj

Copy link

@froydnj froydnj left a comment

Choose a reason for hiding this comment

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

Thanks @noizwaves !

@froydnj froydnj merged commit 3692a57 into sorbet:master Sep 26, 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.

None yet

4 participants