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

Added support to centos7 builder for ARM #302

Closed
wants to merge 1 commit into from

Conversation

Taztingo
Copy link
Contributor

@Taztingo Taztingo commented Mar 18, 2022

An additional fix for Issue #53.

  • Updates the centos7 Dockerfile to optionally build for AARCH64
  • Includes a prebuilt shared library libwasmvm.aarch64.so

@Taztingo Taztingo changed the title Added support to centos7 support for ARM Added support to centos7 for ARM Mar 18, 2022
@Taztingo Taztingo changed the title Added support to centos7 for ARM Added support to centos7 builder for ARM Mar 18, 2022
@webmaster128
Copy link
Member

Looks good, thank you.

This works on ARM hosts but not Intel hosts, right? Then we cannot easily integrate it into the CI.

I wonder if we should use cross compilation instead, i.e. an Intel docker image it used to build for the ARM target using the target system of Rust and compile for aarch64-unknown-linux-gnu

@mandrean
Copy link

IMHO it's preferable to extend the official Debian-based Rust builders instead of creating your own based on CentOS. And rust:1.55.0-buster is multi-arch already 👍

Example:
mandrean@71c134c#diff-0ca56967395929aad880cbf98085f6e02276499f945e5ac6ef16b14ab4288a07

@webmaster128
Copy link
Member

IMHO it's preferable to extend the official Debian-based Rust builders instead of creating your own based on CentOS.

Have a look at #293 and #32 for why we choose this system. No matter how we continue from here, we will pick the OS explicitly instead of using whatever we get from the Rust image. This gives us all the flexibility we need.

And rust:1.55.0-buster is multi-arch already 👍

That assumes we want to build ARM libraries on ARM machines. While this is a nice option to squeeze out something locally, we probably want an x86_64 host such that we can build the libraries in CI easily along with all the other images.

@mandrean
Copy link

mandrean commented Mar 21, 2022

That assumes we want to build ARM libraries on ARM machines.

It assumes you're using Docker in your build process on Mac laptops with ARM chips, which is a pretty common use-case imho

My guess is it's even more common than Mac users interacting with the .dylib actually

@ethanfrey
Copy link
Member

It assumes you're using Docker in your build process on Mac laptops with ARM chips, which is a pretty common use-case imho

All artifacts (dlls, static libs) are built in CI not on local dev machines. I don't think circleci has arm machines available? In any case, we need to run the process two times, one for each arch

@iramiller
Copy link

All artifacts (dlls, static libs) are built in CI not on local dev machines.

All official release artifacts are built by CI and a full solution will be required for building those assets on all supported architectures. It is important that native arm builds can be performed as well though for testing and development purposes.

Which ever approach is taken for the official CI pipeline, my hope is that local builds are still possible on the various supported architectures.

@mandrean
Copy link

mandrean commented Mar 21, 2022

I don't think circleci has arm machines available? In any case, we need to run the process two times, one for each arch

Dedicated ARM runners would be even nicer ofc, but IMHO most multi-arch Docker pipelines today use buildx & qemu to achieve the same thing. They run in parallel, but qemu does incur some performance penalty so amd64 usually finishes much quicker than arm64.

Official blog post from Docker about multi-arch builds in Github Actions:
https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/

And the same for Circle CI:
https://www.docker.com/blog/multi-arch-build-what-about-circleci/

And by the way, thanks for all the work you're putting in on adding arm64 support in the first place. Really appreciated!

@iramiller
Copy link

@mandrean / @ethanfrey would you like to see an alternate buildx qemu build solution submitted here?

@webmaster128
Copy link
Member

In #303 I documented roughly what we need. There might be bits and pieces missing as it's getting late and you might find problems along the way. But this is more or less the same we did for the Mac builds just that on Mac we can merge two builds into one file.

@@ -8,7 +9,7 @@ ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH

RUN wget "https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init" \
RUN wget "https://static.rust-lang.org/rustup/dist/${arch}-unknown-linux-gnu/rustup-init" \
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand how this can work. Cent OS 7 only supports x86_64: https://en.wikipedia.org/wiki/CentOS#CentOS_version_7. How can this run an aarch64 binary? This is an ARM binary in an x86 OS. But then again there is ARM64 here: https://hub.docker.com/layers/centos/library/centos/centos7/images/sha256-73f11afcbb50d8bc70eab9f0850b3fa30e61a419bc48cf426e63527d14a8373b?context=explore.

I probably don't understand docker.

Copy link
Contributor Author

@Taztingo Taztingo Mar 22, 2022

Choose a reason for hiding this comment

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

I don't think it only supports x86_64. There are mirrors for Centos7 for aarch64, and your wiki mentions the following:

As of December 2015, AltArch releases of CentOS 7 are available for the ARMv7hl and AArch64 variants of the ARM architecture

I'm using an M1 so I am running on an ARM64 machine. I believe docker chooses the appropriate image. In my case this would be an aarch64 version of centos.

I encountered the opposite problem which it was trying a run an x86_64 binary on an aarch64. That was why I introduced $arch.

Copy link
Member

Choose a reason for hiding this comment

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

As of December 2015, AltArch releases of CentOS 7 are available for the ARMv7hl and AArch64 variants of the ARM architecture

Nice. This was the missing piece. This also affects the discussion in #293.

Choose a reason for hiding this comment

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

Also easy to verify:

❯ docker run --rm -it --platform linux/arm64 centos:7 uname -m
aarch64

❯ docker run --rm -it --platform linux/amd64 centos:7 uname -m
x86_64

There's a multi-arch image published for centos:7:

❯ docker manifest inspect centos:7
{
   "schemaVersion": 2,
   "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
   "manifests": [
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 529,
         "digest": "sha256:dead07b4d8ed7e29e98de0f4504d87e8880d4347859d839686a31da35a3b532f",
         "platform": {
            "architecture": "amd64",
            "os": "linux"
         }
      },
      /.../
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 530,
         "digest": "sha256:73f11afcbb50d8bc70eab9f0850b3fa30e61a419bc48cf426e63527d14a8373b",
         "platform": {
            "architecture": "arm64",
            "os": "linux",
            "variant": "v8"
         }
      }
   ]
}

@webmaster128
Copy link
Member

Thank you for this contribution. I think it got obsolete now, right? We have libwasmvm.aarch64.so available for a long time now. It's automatically committed to get and available in the wasmvm Go project by default. libwasmvm.aarch64.so is cross-built from an x86_64 CentOS 7 image. If this causes any issues, let's discuss them in a new ticket and see if we need a native builder instead.

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.

5 participants